Example #1
0
        internal Guid[] CopyDatabaseGuids()
        {
            bool flag = false;

            Guid[] result;
            try
            {
                int num = 0;
                while (num < 2 && !flag)
                {
                    flag = this.m_rwlock.TryEnterReadLock(DatabaseLocationCache.s_cacheLockTimeout);
                    num++;
                }
                if (flag)
                {
                    Guid[] array = new Guid[this.m_cache.Keys.Count];
                    this.m_cache.Keys.CopyTo(array, 0);
                    result = array;
                }
                else
                {
                    ExAssert.RetailAssert(false, "Timeout waiting for reader lock in DatabaseLocationCache.CopyDatabaseGuids()");
                    result = null;
                }
            }
            finally
            {
                if (flag)
                {
                    this.m_rwlock.ExitReadLock();
                }
            }
            return(result);
        }
Example #2
0
 // Token: 0x06000715 RID: 1813 RVA: 0x0001595C File Offset: 0x00013B5C
 internal void UseIfReady(RequestDetailsLogger logger, Stream responseStream, out bool used)
 {
     ExAssert.RetailAssert(responseStream != null, "responseStream is null");
     used = false;
     if (this.state != SessionDataCacheState.Obsolete)
     {
         bool flag = false;
         RequestDetailsLogger.LogEvent(logger, SessionDataMetadata.SessionDataCacheFirstTimeRetriveveBegin);
         this.InternalUseIfReady(responseStream, out used, out flag);
         RequestDetailsLogger.LogEvent(logger, SessionDataMetadata.SessionDataCacheFirstTimeRetriveveEnd);
         if (flag)
         {
             OwaSingleCounters.SessionDataCacheWaitedForPreload.Increment();
             bool flag2 = this.signalEvent.WaitOne(5000);
             if (!flag2)
             {
                 OwaSingleCounters.SessionDataCacheWaitTimeout.Increment();
             }
             RequestDetailsLogger.LogEvent(logger, SessionDataMetadata.SessionDataCacheSecondTimeRetriveveBegin);
             this.InternalUseIfReady(responseStream, out used, out flag);
             RequestDetailsLogger.LogEvent(logger, SessionDataMetadata.SessionDataCacheSecondTimeRetriveveEnd);
             RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(logger, SessionDataMetadata.SessionDataCacheWaitTimeOut, !flag2);
         }
         if (used)
         {
             OwaSingleCounters.SessionDataCacheUsed.Increment();
         }
         RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(logger, SessionDataMetadata.SessionDataCacheUsed, used);
     }
 }
Example #3
0
        // Token: 0x0600112F RID: 4399 RVA: 0x00063E70 File Offset: 0x00062070
        private GrammarGeneratorTaskContext InitializeTask(RecipientType recipientType, DirectoryProcessorBaseTaskContext context)
        {
            base.Logger.TraceDebug(this, "Entering GrammarGenerator.InitializeTask recipientType='{0}'", new object[]
            {
                recipientType
            });
            UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_GrammarGenerationStarted, null, new object[]
            {
                base.TenantId,
                base.RunId,
                recipientType.ToString()
            });
            GrammarFileDistributionShare.CreateDirectoryProcessorFolder();
            IGrammarGeneratorInterface grammarGeneratorInstance = null;

            if (recipientType != RecipientType.User)
            {
                if (recipientType != RecipientType.Group)
                {
                    ExAssert.RetailAssert(false, "Unsupported recipient type");
                }
                else
                {
                    grammarGeneratorInstance = new DLGrammarGenerator(base.Logger);
                }
            }
            else
            {
                grammarGeneratorInstance = new UserGrammarGenerator(base.Logger, base.OrgId);
            }
            CultureInfo[] grammarCultures = UMGrammarTenantCache.Instance.GetGrammarCultures();
            return(new GrammarGeneratorTaskContext(context.MailboxData, context.Job, context.TaskQueue, context.Step, context.TaskStatus, grammarGeneratorInstance, grammarCultures, base.Logger, context.RunData, context.DeferredFinalizeTasks));
        }
Example #4
0
        protected override void InternalValidate()
        {
            if (base.OptionalIdentityData != null)
            {
                base.OptionalIdentityData.ConfigurationContainerRdn = ClassificationDefinitionConstants.ClassificationDefinitionsRdn;
            }
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            ExAssert.RetailAssert(base.DataObject != null, "DataObject must not be null at this point as it should have been resolved by the base class.");
            if (!ClassificationDefinitionUtils.IsAdObjectAClassificationRuleCollection(base.DataObject))
            {
                base.WriteError(new ClassificationRuleCollectionInvalidObjectException(Strings.ClassificationRuleCollectionInvalidObject), ErrorCategory.InvalidOperation, null);
            }
            if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled&& OrganizationId.ForestWideOrgId.Equals(((IDirectorySession)base.DataSession).SessionSettings.CurrentOrganizationId) && !this.Identity.IsHierarchical)
            {
                base.WriteError(new ClassificationRuleCollectionIllegalScopeException(Strings.ClassificationRuleCollectionIllegalScopedRemoveOperation), ErrorCategory.InvalidOperation, null);
            }
            SortedSet <string> sortedSet     = new SortedSet <string>();
            IList <string>     allRulesInUse = this.GetAllRulesInUse(base.DataObject, sortedSet);

            if (allRulesInUse.Count > 0)
            {
                LocalizedString message = Strings.ClassificationRuleCollectionSharingViolationRemoveOperationVerbose(this.Identity.ToString(), string.Join(Strings.ClassificationRuleCollectionOffendingListSeparator, allRulesInUse), string.Join(Strings.ClassificationRuleCollectionOffendingListSeparator, sortedSet));
                ClassificationRuleCollectionSharingViolationException exception = ClassificationDefinitionUtils.PopulateExceptionSource <ClassificationRuleCollectionSharingViolationException, IList <string> >(new ClassificationRuleCollectionSharingViolationException(message), allRulesInUse);
                base.WriteError(exception, ErrorCategory.InvalidOperation, null);
            }
        }
        // Token: 0x06001274 RID: 4724 RVA: 0x0003B65C File Offset: 0x0003985C
        internal static PswsAuthZUserToken GetAuthZPluginUserToken(UserToken userToken)
        {
            ExAssert.RetailAssert(userToken != null, "[PswsAuthorization.GetAuthZPluginUserToken] userToken can't be null.");
            Microsoft.Exchange.Configuration.Core.AuthenticationType authenticationType = userToken.AuthenticationType;
            SecurityIdentifier userSid            = userToken.UserSid;
            DelegatedPrincipal delegatedPrincipal = userToken.DelegatedPrincipal;

            ExAssert.RetailAssert(userSid != null, "The user sid is invalid (null).");
            PartitionId partitionId = userToken.PartitionId;
            string      text        = AuthenticatedUserCache.CreateKeyForPsws(userSid, userToken.AuthenticationType, partitionId);

            ExTraceGlobals.PublicPluginAPITracer.TraceDebug <string>(0L, "[PswsAuthZHelper.GetAuthZPluginUserToken] User cache key = \"{0}\".", text);
            AuthZPluginUserToken authZPluginUserToken;

            if (!AuthenticatedUserCache.Instance.TryGetValue(text, out authZPluginUserToken))
            {
                ExTraceGlobals.PublicPluginAPITracer.TraceDebug(0L, "[PswsAuthZHelper.GetAuthZPluginUserToken] User not found in cache.");
                IIdentity          identity           = HttpContext.Current.Items["X-Psws-CurrentLogonUser"] as IIdentity;
                SerializedIdentity serializedIdentity = null;
                if (identity is WindowsTokenIdentity)
                {
                    serializedIdentity = ((WindowsTokenIdentity)identity).ToSerializedIdentity();
                }
                ADRawEntry adrawEntry = ExchangeAuthorizationPlugin.FindUserEntry(userSid, null, serializedIdentity, partitionId);
                ExAssert.RetailAssert(adrawEntry != null, "UnAuthorized. Unable to find the user.");
                bool condition = (adrawEntry is MiniRecipient || adrawEntry is ADUser) && (bool)adrawEntry[ADRecipientSchema.RemotePowerShellEnabled];
                ExAssert.RetailAssert(condition, "UnAuthorized. PSWS not enabled user.");
                authZPluginUserToken = new AuthZPluginUserToken(delegatedPrincipal, adrawEntry, authenticationType, userSid.Value);
                AuthenticatedUserCache.Instance.AddUserToCache(text, authZPluginUserToken);
            }
            return(new PswsAuthZUserToken(authZPluginUserToken.DelegatedPrincipal, authZPluginUserToken.UserEntry, authenticationType, authZPluginUserToken.DefaultUserName, userToken.UserName));
        }
Example #6
0
 public static void AssertReturnValueExceptionInconsistency(int returnValue, string methodName, Exception ex)
 {
     if (returnValue == 0)
     {
         ExAssert.RetailAssert(ex == null, Util.GetReturnValueExceptionInconsistencyErrorMessage(methodName, ex));
     }
 }
        internal static ExchangeBuild GetTextProcessorVersion(TextProcessorType textProcessorType, XElement textProcessorElement)
        {
            if (textProcessorElement == null)
            {
                throw new ArgumentNullException("textProcessorElement");
            }
            ExAssert.RetailAssert(TextProcessorType.Function <= textProcessorType && textProcessorType <= TextProcessorType.Fingerprint, "The specified textProcessorType '{0}' is out-of-range", new object[]
            {
                textProcessorType.ToString()
            });
            ExchangeBuild result = ClassificationDefinitionConstants.DefaultVersion;

            if (ClassificationDefinitionConstants.TextProcessorTypeToVersions.ContainsKey(textProcessorType))
            {
                result = ClassificationDefinitionConstants.TextProcessorTypeToVersions[textProcessorType];
            }
            else if (textProcessorType == TextProcessorType.Function)
            {
                string value = textProcessorElement.Attribute("id").Value;
                ExAssert.RetailAssert(value != null, "The functionName in the specfied textProcessorElement is null", new object[]
                {
                    textProcessorElement.ToString()
                });
                if (ClassificationDefinitionConstants.FunctionNameToVersions.ContainsKey(value))
                {
                    result = ClassificationDefinitionConstants.FunctionNameToVersions[value];
                }
            }
            return(result);
        }
Example #8
0
        private void OnAuthenticateRequest(object source, EventArgs e)
        {
            HttpContext httpContext = HttpContext.Current;

            if (!(httpContext.User.Identity is WindowsIdentity))
            {
                return;
            }
            WindowsIdentity windowsIdentity = (WindowsIdentity)httpContext.User.Identity;

            if (windowsIdentity.User == null)
            {
                string value = string.Format("UnExpected: WindowsIdentity.User = null, AuthNType = {0}, Name = {1}", windowsIdentity.AuthenticationType, windowsIdentity.Name);
                HttpLogger.SafeAppendGenericError("WindowsIdentityToGenericIdentityModule", value, true);
                HttpApplication httpApplication = (HttpApplication)source;
                httpContext.Response.StatusCode = 401;
                httpApplication.CompleteRequest();
                return;
            }
            ExAssert.RetailAssert(httpContext.User != null && httpContext.User.Identity != null && httpContext.User.Identity.Name != null, "HttpContext.User.Identity.Name should not be null.");
            GenericIdentity identity = new GenericIdentity(httpContext.User.Identity.Name.ToLower(), "Converted-" + httpContext.User.Identity.AuthenticationType);

            httpContext.User = new GenericPrincipal(identity, new string[0]);
            using (WinRMDataSender winRMDataSender = new WinRMDataSender(httpContext, null))
            {
                WinRMInfo winRMInfo = httpContext.Items["X-RemotePS-WinRMInfo"] as WinRMInfo;
                if (winRMInfo != null)
                {
                    winRMDataSender.SessionId = winRMInfo.FomattedSessionId;
                }
                winRMDataSender.RequestId = HttpLogger.ActivityScope.ActivityId.ToString();
                winRMDataSender.UserToken = new UserToken(AuthenticationType.Kerberos, null, null, windowsIdentity.Name, windowsIdentity.User, null, OrganizationId.ForestWideOrgId, null, false, new CommonAccessToken(windowsIdentity));
                winRMDataSender.Send();
            }
        }
 public static void GetOrganizationMailboxesByCapability(IRecipientSession session, OrganizationCapability capability, ADObjectId siteId, out List <ADUser> filteredList, out List <ADUser> completeList)
 {
     ExAssert.RetailAssert(!OrganizationMailbox.IsMultiTenantEnvironment(), "GetOrganizationMailboxesByCapability (site-based) should not be used in Datacenter Multitenant environment");
     ExTraceGlobals.StorageTracer.TraceDebug <OrganizationCapability>(0L, "Entering GetOrganizationMailboxByCapability capability='{0}'", capability);
     if (siteId == null)
     {
         throw new ArgumentNullException("siteId");
     }
     completeList = OrganizationMailbox.GetOrganizationMailboxesByCapability(session, capability);
     ExTraceGlobals.StorageTracer.TraceDebug <int, OrganizationCapability>(0L, "GetOrganizationMailboxByCapability -completeList of mailbox, count='{0}', capability='{1}'", completeList.Count, capability);
     filteredList = new List <ADUser>();
     if (completeList.Count > 0)
     {
         ExTraceGlobals.StorageTracer.TraceDebug <OrganizationCapability>(0L, "GetOrganizationMailboxByCapability -GetCurrentServiceTopology capability='{0}'", capability);
         ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\OrganizationMailbox\\OrganizationMailbox.cs", "GetOrganizationMailboxesByCapability", 137);
         foreach (ADUser aduser in completeList)
         {
             ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(session.SessionSettings, aduser, RemotingOptions.AllowCrossSite);
             string            serverFqdn        = exchangePrincipal.MailboxInfo.Location.ServerFqdn;
             ExTraceGlobals.StorageTracer.TraceDebug <string, OrganizationCapability>(0L, "GetOrganizationMailboxByCapability calling GetSite with Prinicipal.ServerFQDN='{0}', capability='{1}'", serverFqdn, capability);
             Site site       = currentServiceTopology.GetSite(serverFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\OrganizationMailbox\\OrganizationMailbox.cs", "GetOrganizationMailboxesByCapability", 151);
             Guid objectGuid = site.Id.ObjectGuid;
             ExTraceGlobals.StorageTracer.TraceDebug <string, Guid, OrganizationCapability>(0L, "GetOrganizationMailboxByCapability  GetSite called with Prinicipal.ServerFQDN='{0}', Site='{1}'capability='{2}'", serverFqdn, objectGuid, capability);
             if (siteId.ObjectGuid.Equals(objectGuid))
             {
                 filteredList.Add(aduser);
             }
         }
     }
 }
Example #10
0
        Guid IMailbox.StartIsInteg(List <uint> mailboxCorruptionTypes)
        {
            ExAssert.RetailAssert(mailboxCorruptionTypes != null, "IMailbox.StartIsInteg input must be non-null");
            Guid result = Guid.Empty;

            using (ExRpcAdmin rpcAdmin = base.GetRpcAdmin())
            {
                using (base.RHTracker.Start())
                {
                    MrsTracer.Provider.Debug("Starting IsInteg task \"{0}\" in MDB {1}", new object[]
                    {
                        base.TraceMailboxId,
                        base.MdbGuid
                    });
                    PropValue[][] array = rpcAdmin.StoreIntegrityCheckEx(base.MdbGuid, base.MailboxGuid, Guid.Empty, 1U, 20U, mailboxCorruptionTypes.ToArray(), IsInteg.JobPropTags);
                    foreach (PropValue[] propValues in array)
                    {
                        StoreIntegrityCheckJob storeIntegrityCheckJob = new StoreIntegrityCheckJob(propValues);
                        result = storeIntegrityCheckJob.RequestGuid;
                        MrsTracer.Provider.Debug("Started Store IsInteg task: {0}", new object[]
                        {
                            storeIntegrityCheckJob.ToString()
                        });
                    }
                }
            }
            return(result);
        }
        protected override LoadContainer BuildTopology(TopologyExtractorFactoryContext topologyExtractorContext)
        {
            TopologyExtractorFactory loadBalancingLocalFactory = topologyExtractorContext.GetLoadBalancingLocalFactory(false);
            DirectoryServer          localServer   = base.ServiceContext.Directory.GetLocalServer();
            TopologyExtractor        extractor     = loadBalancingLocalFactory.GetExtractor(localServer);
            LoadContainer            loadContainer = extractor.ExtractTopology();

            ExAssert.RetailAssert(loadContainer != null, "Extracted toplogy for server '{0}' should never be null.", new object[]
            {
                localServer
            });
            DatabaseCollector databaseCollector = new DatabaseCollector();

            loadContainer.Accept(databaseCollector);
            IOperationRetryManager operationRetryManager = LoadBalanceOperationRetryManager.Create(1, TimeSpan.Zero, base.ServiceContext.Logger);

            foreach (LoadContainer loadContainer2 in databaseCollector.Databases)
            {
                DirectoryDatabase directoryDatabase = loadContainer2.DirectoryObject as DirectoryDatabase;
                if (directoryDatabase != null)
                {
                    DatabaseProcessor @object = new DatabaseProcessor(base.ServiceContext.Settings, base.ServiceContext.DrainControl, base.ServiceContext.Logger, directoryDatabase);
                    operationRetryManager.TryRun(new Action(@object.ProcessDatabase));
                }
            }
            return(loadContainer);
        }
        protected override bool EvaluateMatch(Tuple <TransportRule, XDocument> rulePackDataObject, Func <string, CultureInfo, CompareOptions, bool> objectPropertyMatchOperator)
        {
            ExAssert.RetailAssert(rulePackDataObject != null && rulePackDataObject.Item1 != null && rulePackDataObject.Item2 != null, "The rule pack data object passed to the name matcher must not be null");
            bool flag = false;

            DlpUtils.DataClassificationQueryContext dataClassificationQueryContext = new DlpUtils.DataClassificationQueryContext(rulePackDataObject.Item1.OrganizationId, ClassificationDefinitionsDiagnosticsReporter.Instance)
            {
                CurrentRuleCollectionTransportRuleObject = rulePackDataObject.Item1,
                CurrentRuleCollectionXDoc = rulePackDataObject.Item2
            };
            XElement operationArgument;

            if (!DlpUtils.TryExecuteOperation <XmlException, XDocument, XElement>(dataClassificationQueryContext, new Func <XDocument, XElement>(XmlProcessingUtils.GetRulePackageMetadataElement), dataClassificationQueryContext.CurrentRuleCollectionXDoc, out operationArgument))
            {
                return(flag);
            }
            ClassificationRuleCollectionLocalizableDetails classificationRuleCollectionLocalizableDetails;

            if (!DlpUtils.TryExecuteOperation <XmlException, XElement, ClassificationRuleCollectionLocalizableDetails>(dataClassificationQueryContext, new Func <XElement, ClassificationRuleCollectionLocalizableDetails>(XmlProcessingUtils.ReadDefaultRulePackageMetadata), operationArgument, out classificationRuleCollectionLocalizableDetails))
            {
                return(flag);
            }
            flag = objectPropertyMatchOperator(classificationRuleCollectionLocalizableDetails.Name, classificationRuleCollectionLocalizableDetails.Culture, CompareOptions.IgnoreCase);
            if (!flag)
            {
                Dictionary <CultureInfo, ClassificationRuleCollectionLocalizableDetails> source;
                if (!DlpUtils.TryExecuteOperation <XmlException, XElement, Dictionary <CultureInfo, ClassificationRuleCollectionLocalizableDetails> >(dataClassificationQueryContext, new Func <XElement, Dictionary <CultureInfo, ClassificationRuleCollectionLocalizableDetails> >(XmlProcessingUtils.ReadAllRulePackageMetadata), operationArgument, out source))
                {
                    return(flag);
                }
                flag = source.Any((KeyValuePair <CultureInfo, ClassificationRuleCollectionLocalizableDetails> localizedDetail) => objectPropertyMatchOperator(localizedDetail.Value.Name, localizedDetail.Key, CompareOptions.IgnoreCase));
            }
            return(flag);
        }
Example #13
0
        // Token: 0x06001060 RID: 4192 RVA: 0x0005FB2C File Offset: 0x0005DD2C
        private string GetMetadataFileName(RecipientType recipientType)
        {
            string text = null;

            if (recipientType != RecipientType.User)
            {
                if (recipientType != RecipientType.Group)
                {
                    ExAssert.RetailAssert(false, "Unsupported recipient type");
                }
                else
                {
                    text = "DistributionList.xml";
                }
            }
            else
            {
                text = "User.xml";
            }
            base.Logger.TraceDebug(this, "GetMetadataFileName fileName='{0}'", new object[]
            {
                text
            });
            return(text);
        }
Example #14
0
        // Token: 0x0600105C RID: 4188 RVA: 0x0005F8C4 File Offset: 0x0005DAC4
        private IRecipientSession CreateWritableSession(OrganizationId orgId)
        {
            ExAssert.RetailAssert(orgId == OrganizationId.ForestWideOrgId, "organizationId should be ForestWideOrgId");
            ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), orgId, null, false);

            return(DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, 0, false, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 474, "CreateWritableSession", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\DirectoryProcessor\\DtmfMapGenerator\\DtmfMapGenerator.cs"));
        }
        private static void ValidateRulePackIdentifier(bool isOobRuleCollection, bool isFingerprintsRuleCollection, string rulePackIdentifier)
        {
            ExAssert.RetailAssert(rulePackIdentifier != null, "Rule package ID must be specified for rule package ID validation.");
            bool flag = rulePackIdentifier.StartsWith("00000000-0000-0000-0001");

            if ((isFingerprintsRuleCollection && !flag) || (!isFingerprintsRuleCollection && flag))
            {
                LocalizedString message = Strings.ClassificationRuleCollectionReservedFingerprintRulePackIdViolation(rulePackIdentifier);
                throw new ClassificationRuleCollectionIdentifierValidationException(message);
            }
            if (isFingerprintsRuleCollection)
            {
                return;
            }
            if (!VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
            {
                return;
            }
            bool flag2 = rulePackIdentifier.StartsWith("00000000", StringComparison.OrdinalIgnoreCase);

            if (!isOobRuleCollection && flag2)
            {
                LocalizedString message2 = Strings.ClassificationRuleCollectionReservedRulePackIdViolation(rulePackIdentifier, "00000000");
                throw new ClassificationRuleCollectionIdentifierValidationException(message2);
            }
            if (isOobRuleCollection && !flag2)
            {
                LocalizedString message3 = Strings.ClassificationRuleCollectionOobRulePackIdViolation(rulePackIdentifier, "00000000");
                throw new ClassificationRuleCollectionIdentifierValidationException(message3);
            }
        }
Example #16
0
 private static void ValidateRegexProcessorsPerformance(XDocument rulePackXDocument, DataClassificationConfig dataClassificationConfig)
 {
     ExAssert.RetailAssert(dataClassificationConfig != null, "Must specify DataClassificationConfig instance when calling ValidateRegexProcessorsPerformance");
     foreach (KeyValuePair <string, string> keyValuePair in XmlProcessingUtils.GetRegexesInRulePackage(rulePackXDocument))
     {
         try
         {
             if (keyValuePair.Value.Length > dataClassificationConfig.RegExLength)
             {
                 LocalizedString localizedString = Strings.ClassificationRuleCollectionPatternTooLong(dataClassificationConfig.RegExLength);
                 throw new ValidationArgumentException(localizedString, null);
             }
             if (dataClassificationConfig.RegExGrammarLimit)
             {
                 Pattern.ValidatePatternDoesNotBeginOrEndWithWildcards(keyValuePair.Value);
                 Pattern.ValidatePatternDoesNotContainGroupsOrAssertionsWithWildcards(keyValuePair.Value);
                 Pattern.ValidatePatternDoesNotContainMultiMatchOnGroupsOrAssertions(keyValuePair.Value);
                 Pattern.ValidatePatternDoesNotHaveSequentialIdenticalMultiMatches(keyValuePair.Value);
                 Pattern.ValidatePatternDoesNotContainEmptyAlternations(keyValuePair.Value);
             }
         }
         catch (ValidationArgumentException ex)
         {
             LocalizedString message = Strings.ClassificationRuleCollectionRegexPerformanceValidationFailure(keyValuePair.Key, ex.Message);
             throw new ClassificationRuleCollectionRegexValidationException(message, ex);
         }
     }
 }
Example #17
0
        public static StoreObjectId OptUserIn(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator)
        {
            snapshot = ClutterUtilities.LoadSnapshotIfNeeded(session, snapshot);
            StoreObjectId storeObjectId = null;

            if (!session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClutterEnabled, false) || !session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false))
            {
                using (MailboxSession mailboxSession = ClutterUtilities.OpenAdminSession(session))
                {
                    StoreObjectId storeObjectId2 = ClutterUtilities.SetClassificationEnabled(mailboxSession, true);
                    ClutterUtilities.AddClutterToFavorite(session);
                    ClutterUtilities.VerifyReadyVersionInCrumb(mailboxSession);
                    storeObjectId = session.RefreshDefaultFolder(DefaultFolderType.Clutter);
                    ClutterUtilities.RefreshInferenceProperties(session, true);
                    using (NotificationManager notificationManager = new NotificationManager(session, snapshot, frontEndLocator))
                    {
                        notificationManager.SendNotification(ClutterNotificationType.OptedIn, DefaultFolderType.Inbox);
                        notificationManager.ScheduleNotification(ClutterNotificationType.FirstReminder, 5, DayOfWeek.Monday);
                        notificationManager.CancelScheduledNotification(ClutterNotificationType.AutoEnablementNotice);
                        notificationManager.Save();
                    }
                    ExAssert.RetailAssert(mailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClutterEnabled, false), "InferenceClutterEnabled should have been set to true in admin session");
                    ExAssert.RetailAssert(mailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false), "InferenceClassificationEnabled should have been set to true in admin session");
                    ExAssert.RetailAssert(storeObjectId2 != null, "Clutter folder id created in admin session should not be null");
                    ExAssert.RetailAssert(storeObjectId2.Equals(storeObjectId), "Clutter folder id created in admin session should equal the id created by refreshing the user session");
                    goto IL_FD;
                }
            }
            storeObjectId = ClutterUtilities.ValidateClutterFolder(session);
IL_FD:
            ExAssert.RetailAssert(session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClutterEnabled, false), "InferenceClutterEnabled should have been set to true in user session");
            ExAssert.RetailAssert(session.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false), "InferenceClassificationEnabled should have been set to true in user session");
            ExAssert.RetailAssert(storeObjectId != null, "Clutter folder could not be created");
            return(storeObjectId);
        }
Example #18
0
        private static void IPAddressFamilySetter(object value, IPropertyBag propertyBag)
        {
            int num = (int)propertyBag[UMIPGatewaySchema.UMIPGatewaySet];
            UMIPGatewayFlags2 umipgatewayFlags = (UMIPGatewayFlags2)propertyBag[UMIPGatewaySchema.UMIPGatewaySet2];
            IPAddressFamily   ipaddressFamily  = (IPAddressFamily)value;

            if (ipaddressFamily == Microsoft.Exchange.Data.Directory.IPAddressFamily.Any)
            {
                num |= 4;
                umipgatewayFlags |= UMIPGatewayFlags2.IPv4Enabled;
            }
            else if (ipaddressFamily == Microsoft.Exchange.Data.Directory.IPAddressFamily.IPv6Only)
            {
                num |= 4;
                umipgatewayFlags &= ~UMIPGatewayFlags2.IPv4Enabled;
            }
            else if (ipaddressFamily == Microsoft.Exchange.Data.Directory.IPAddressFamily.IPv4Only)
            {
                num &= -5;
                umipgatewayFlags |= UMIPGatewayFlags2.IPv4Enabled;
            }
            else
            {
                ExAssert.RetailAssert(false, "IPAddressFamily set value must be Any, IPv6Only, or IPv4Only");
            }
            propertyBag[UMIPGatewaySchema.UMIPGatewaySet]  = num;
            propertyBag[UMIPGatewaySchema.UMIPGatewaySet2] = (int)umipgatewayFlags;
        }
Example #19
0
 protected override void InternalValidate(XDocument rulePackXDocument)
 {
     ExAssert.RetailAssert(rulePackXDocument != null, "Extra rule package validation must take place after XML schema validation passed!");
     DataClassificationLocalizedInfoValidator.ValidateDefaultValueCount(rulePackXDocument);
     this.ValidateAllRulesLangCodes(rulePackXDocument);
     DataClassificationLocalizedInfoValidator.ValidateDefaultValueLangCodesConsistency(rulePackXDocument);
 }
        private static void IPAddressFamilySetter(object value, IPropertyBag propertyBag)
        {
            SIPFEServerConfigurationSchema.SIPFEServerSetFlags sipfeserverSetFlags = (SIPFEServerConfigurationSchema.SIPFEServerSetFlags)propertyBag[SIPFEServerConfigurationSchema.SIPFEServerSet];
            IPAddressFamily ipaddressFamily = (IPAddressFamily)value;

            if (ipaddressFamily == Microsoft.Exchange.Data.Directory.IPAddressFamily.Any)
            {
                sipfeserverSetFlags |= SIPFEServerConfigurationSchema.SIPFEServerSetFlags.IPv4Enabled;
                sipfeserverSetFlags |= SIPFEServerConfigurationSchema.SIPFEServerSetFlags.IPv6Enabled;
            }
            else if (ipaddressFamily == Microsoft.Exchange.Data.Directory.IPAddressFamily.IPv6Only)
            {
                sipfeserverSetFlags &= ~SIPFEServerConfigurationSchema.SIPFEServerSetFlags.IPv4Enabled;
                sipfeserverSetFlags |= SIPFEServerConfigurationSchema.SIPFEServerSetFlags.IPv6Enabled;
            }
            else if (ipaddressFamily == Microsoft.Exchange.Data.Directory.IPAddressFamily.IPv4Only)
            {
                sipfeserverSetFlags |= SIPFEServerConfigurationSchema.SIPFEServerSetFlags.IPv4Enabled;
                sipfeserverSetFlags &= ~SIPFEServerConfigurationSchema.SIPFEServerSetFlags.IPv6Enabled;
            }
            else
            {
                ExAssert.RetailAssert(false, "IPAddressFamily set value must be Any, IPv6Only, or IPv4Only");
            }
            propertyBag[SIPFEServerConfigurationSchema.SIPFEServerSet] = (int)sipfeserverSetFlags;
        }
Example #21
0
        internal void AddPendingRequestNotifier(IPendingRequestNotifier notifier)
        {
            LockCookie?lockCookie = null;

            try
            {
                if (notifier == null)
                {
                    throw new ArgumentNullException("notifier");
                }
                this.notifiersStateLock.LockWriterElastic(5000);
                this.notifierDataAvaiableState.Add(notifier, new PendingRequestManager.PendingNotifierState());
                notifier.DataAvailable += this.OnNotifierDataAvailable;
            }
            finally
            {
                if (this.notifiersStateLock.IsWriterLockHeld)
                {
                    if (lockCookie != null)
                    {
                        LockCookie value = lockCookie.Value;
                        this.notifiersStateLock.DowngradeFromWriterLock(ref value);
                    }
                    else
                    {
                        this.notifiersStateLock.ReleaseWriterLock();
                    }
                }
                if (lockCookie != null && !this.notifiersStateLock.IsReaderLockHeld)
                {
                    ExAssert.RetailAssert(true, "Lost readerwriterlock that was acquired before entering the method");
                }
            }
        }
Example #22
0
        internal static CommonAccessToken CommonAccessTokenForCmdletProxy(this UserToken userToken, int targetVersion)
        {
            CommonAccessToken commonAccessToken = userToken.CommonAccessToken;

            if (commonAccessToken != null)
            {
                if (userToken.AuthenticationType == AuthenticationType.OAuth && targetVersion < Server.E15MinVersion)
                {
                    OAuthIdentity               oauthIdentity = OAuthIdentitySerializer.ConvertFromCommonAccessToken(commonAccessToken);
                    SidOAuthIdentity            sidIdentity   = SidOAuthIdentity.Create(oauthIdentity);
                    CertificateSidTokenAccessor certificateSidTokenAccessor = CertificateSidTokenAccessor.Create(sidIdentity);
                    commonAccessToken = certificateSidTokenAccessor.GetToken();
                }
            }
            else
            {
                commonAccessToken = new CommonAccessToken(AccessTokenType.CertificateSid);
                ExAssert.RetailAssert(userToken.UserSid != null, "UserToken.UserSid is expected to NOT NULL when CommonAccessToken doesn't exist. UserToken = " + userToken);
                commonAccessToken.ExtensionData["UserSid"] = userToken.UserSid.ToString();
                if (userToken.PartitionId != null)
                {
                    commonAccessToken.ExtensionData["Partition"] = userToken.PartitionId.ToString();
                }
            }
            commonAccessToken.IsCompressed = true;
            return(commonAccessToken);
        }
Example #23
0
        // Token: 0x06001242 RID: 4674 RVA: 0x000395D0 File Offset: 0x000377D0
        private void OnAuthenticate(object source, EventArgs args)
        {
            ExTraceGlobals.AccessCheckTracer.TraceDebug((long)this.GetHashCode(), "[PswsAuthNModule.OnAuthenticate] Enter");
            HttpApplication httpApplication = (HttpApplication)source;
            HttpContext     context         = httpApplication.Context;
            HttpRequest     request         = context.Request;

            if (!request.IsAuthenticated)
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug((long)this.GetHashCode(), "[PswsAuthNModule.OnAuthenticate] Request is not authenticated. Skip.");
                return;
            }
            UserToken userToken = context.CurrentUserToken();

            if (userToken == null)
            {
                ExTraceGlobals.AccessCheckTracer.TraceError((long)this.GetHashCode(), "[PswsAuthNModule.OnAuthenticate] user token is null. Skip.");
                throw new InvalidOperationException("Unexpected condition: userToken from HttpContext is null.");
            }
            context.Items["X-Psws-CurrentLogonUser"] = context.User.Identity;
            string pswsMembershipId = PswsAuthZHelper.GetPswsMembershipId(userToken, request.Headers);

            ExAssert.RetailAssert(!string.IsNullOrWhiteSpace(pswsMembershipId), "userIdWithMembershipId can't be null or blank.");
            string text = "PswsMembership-" + userToken.AuthenticationType;

            ExTraceGlobals.AccessCheckTracer.TraceDebug((long)this.GetHashCode(), string.Format("[PswsAuthNModule.OnAuthenticate] userId = \"{0}\", userType = \"{1}\".", pswsMembershipId, text));
            context.User = new GenericPrincipal(new GenericIdentity(pswsMembershipId, text), null);
            ExTraceGlobals.AccessCheckTracer.TraceDebug((long)this.GetHashCode(), "[PswsAuthNModule.OnAuthenticate] Leave");
        }
        // Token: 0x0600017E RID: 382 RVA: 0x0000A5F4 File Offset: 0x000087F4
        private AssistantTaskContext DoWork(AssistantTaskContext context)
        {
            ELCAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "ElcAssistant.InitialStep");
            MailboxSession     mailboxSession     = context.Args.StoreSession as MailboxSession;
            ElcDataTaskContext elcDataTaskContext = context as ElcDataTaskContext;

            ExAssert.RetailAssert(mailboxSession != null, "Collection step invoked with an invalid session. {0}", new object[]
            {
                (context.Args.StoreSession == null) ? "null" : context.Args.StoreSession.GetType().FullName
            });
            ExAssert.RetailAssert(elcDataTaskContext != null, "Collection step invoked with an invalid task context. {0}", new object[]
            {
                context.GetType().FullName
            });
            elcDataTaskContext.RetriesAttempted++;
            bool flag = this.InvokeInternalAssistant(mailboxSession, context.Args, context.CustomDataToLog, elcDataTaskContext.RetriesAttempted);

            if (flag)
            {
                ELCAssistant.Tracer.TraceDebug <IExchangePrincipal, int>((long)this.GetHashCode(), "ELCAssistant is not done processing, this mailbox will be retried, mailbox {0} , Total attempts {1}", mailboxSession.MailboxOwner, elcDataTaskContext.RetriesAttempted);
                return(new ElcDataTaskContext(context.MailboxData, context.Job, new AssistantStep(this.DoWork), elcDataTaskContext.RetriesAttempted));
            }
            ELCAssistant.Tracer.TraceDebug <IExchangePrincipal, int>((long)this.GetHashCode(), "ELCAssistant is done processing mailbox {0} , Total attempts {1}", mailboxSession.MailboxOwner, elcDataTaskContext.RetriesAttempted);
            return(null);
        }
        // Token: 0x06001CCB RID: 7371 RVA: 0x00073480 File Offset: 0x00071680
        public static void HandleRecoResult(string result, RequestParameters parameters, HttpContext httpContext, UserContext userContext, out string jsonResponse, out SpeechRecognitionProcessor.SpeechHttpStatus httpStatus)
        {
            jsonResponse = null;
            httpStatus   = SpeechRecognitionProcessor.SpeechHttpStatus.Success;
            if (string.IsNullOrEmpty(result))
            {
                return;
            }
            IMobileSpeechRecognitionResultHandler mobileSpeechRecognitionResultHandler = null;

            switch (parameters.RequestType)
            {
            case MobileSpeechRecoRequestType.FindPeople:
                mobileSpeechRecognitionResultHandler = new FindPeopleSpeechRecognitionResultHandler(parameters, userContext, httpContext);
                goto IL_95;

            case MobileSpeechRecoRequestType.CombinedScenarios:
                mobileSpeechRecognitionResultHandler = new CombinedScenarioRecognitionResultHandler(parameters, userContext, httpContext);
                goto IL_95;

            case MobileSpeechRecoRequestType.DaySearch:
                mobileSpeechRecognitionResultHandler = new DaySearchRecognitionResultHandler(parameters.TimeZone);
                goto IL_95;

            case MobileSpeechRecoRequestType.AppointmentCreation:
                mobileSpeechRecognitionResultHandler = new DateTimeandDurationRecognitionResultHandler(parameters.TimeZone);
                goto IL_95;
            }
            ExAssert.RetailAssert(false, "Invalid request type '{0}'", new object[]
            {
                parameters.RequestType
            });
IL_95:
            mobileSpeechRecognitionResultHandler.ProcessAndFormatSpeechRecognitionResults(result, out jsonResponse, out httpStatus);
        }
        public DataClassificationConfig GetDataClassificationConfig(OrganizationId organizationId, IConfigurationSession currentDataSession)
        {
            if (object.ReferenceEquals(null, organizationId))
            {
                throw new ArgumentNullException("organizationId");
            }
            if (currentDataSession == null)
            {
                throw new ArgumentNullException("currentDataSession");
            }
            if (!VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled || OrganizationId.ForestWideOrgId.Equals(organizationId))
            {
                return(null);
            }
            if (!organizationId.Equals(currentDataSession.SessionSettings.CurrentOrganizationId))
            {
                throw new ArgumentException(new ArgumentException().Message, "currentDataSession");
            }
            SharedConfiguration   sharedConfiguration = SharedConfiguration.GetSharedConfiguration(organizationId);
            IConfigurationSession configurationSession;

            if (sharedConfiguration != null)
            {
                configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.PartiallyConsistent, sharedConfiguration.GetSharedConfigurationSessionSettings(), 1186, "GetDataClassificationConfig", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\ClassificationDefinitions\\ClassificationDefinitionUtils.cs");
            }
            else
            {
                configurationSession = currentDataSession;
            }
            DataClassificationConfig[] array = configurationSession.Find <DataClassificationConfig>(null, QueryScope.SubTree, null, null, 1);
            ExAssert.RetailAssert(array != null && 1 == array.Length, "There should be one and only one DataClassificationConfig applicable to a particular tenant.");
            return(array[0]);
        }
Example #27
0
 // Token: 0x06000714 RID: 1812 RVA: 0x00015830 File Offset: 0x00013A30
 internal void CompleteBuilding()
 {
     try
     {
         Monitor.Enter(this.lockObject);
         ExAssert.RetailAssert(this.state == SessionDataCacheState.Building || this.state == SessionDataCacheState.Obsolete, "Ready building session data in an invalid state: " + this.state);
         if (this.state == SessionDataCacheState.Obsolete)
         {
             this.InternalDispose(true);
         }
         else
         {
             this.lastSessionDataBuildEndTime = ExDateTime.Now;
             this.state = SessionDataCacheState.Ready;
             this.signalEvent.Set();
             Timer staleTimer = null;
             staleTimer = new Timer(delegate(object param0)
             {
                 this.Dispose();
                 DisposeGuard.DisposeIfPresent(staleTimer);
             }, null, SessionDataCache.FreshnessTime, Timeout.InfiniteTimeSpan);
         }
     }
     finally
     {
         if (Monitor.IsEntered(this.lockObject))
         {
             Monitor.Exit(this.lockObject);
         }
         ExTraceGlobals.SessionDataHandlerTracer.TraceDebug((long)this.GetHashCode(), string.Format("[SessionDataCache] Ready building session data cache. StartTime = {0}, EndTime = {1}, state = {2}", this.lastSessionDataBuildStartTime.ToString(), this.lastSessionDataBuildEndTime.ToString(), this.state));
         OwaSingleCounters.SessionDataCacheBuildsCompleted.Increment();
     }
 }
Example #28
0
        internal static Dictionary <string, HashSet <string> > GetAllClassificationIdentifiers(OrganizationId organizationId, IConfigurationSession openedDataSession = null, Func <TransportRule, bool> inclusiveFilter = null, QueryFilter additionalFilter = null, IClassificationDefinitionsDataReader dataReader = null, IClassificationDefinitionsDiagnosticsReporter classificationDefinitionsDiagnosticsReporter = null)
        {
            IClassificationDefinitionsDiagnosticsReporter classificationDefinitionsDiagnosticsReporter2 = classificationDefinitionsDiagnosticsReporter ?? ClassificationDefinitionsDiagnosticsReporter.Instance;
            Dictionary <string, HashSet <string> >        dictionary = new Dictionary <string, HashSet <string> >(ClassificationDefinitionConstants.RuleCollectionIdComparer);

            foreach (Tuple <TransportRule, XDocument> tuple in DlpUtils.AggregateOobAndCustomClassificationDefinitions(organizationId, openedDataSession, inclusiveFilter, additionalFilter, dataReader, classificationDefinitionsDiagnosticsReporter2))
            {
                TransportRule item  = tuple.Item1;
                XDocument     item2 = tuple.Item2;
                ExAssert.RetailAssert(item2 != null, "XDocument instance returned from AggregateOobAndCustomClassificationDefinitions should never be null!");
                string           rulePackId;
                HashSet <string> value;
                try
                {
                    rulePackId = XmlProcessingUtils.GetRulePackId(item2);
                    value      = new HashSet <string>(XmlProcessingUtils.GetAllRuleIds(item2), ClassificationDefinitionConstants.RuleIdComparer);
                }
                catch (XmlException ex)
                {
                    ClassificationDefinitionsDiagnosticsReporter.Instance.WriteCorruptRulePackageDiagnosticsInformation(0, organizationId, item.DistinguishedName, new AggregateException(new Exception[]
                    {
                        ex
                    }).Flatten());
                    continue;
                }
                ExAssert.RetailAssert(!dictionary.ContainsKey(rulePackId), "Duplicate classification rule collection ID '{0}' under tenant's organization '{1}' is a should never ever happen case", new object[]
                {
                    rulePackId,
                    organizationId.ToString()
                });
                dictionary.Add(rulePackId, value);
            }
            return(dictionary);
        }
Example #29
0
        protected virtual void Initialize()
        {
            ExAssert.RetailAssert(this.StoredRuleCollection != null, "The stored transport rule instance for classification rule collection presentation object must not be null");
            XDocument ruleCollectionDocumentFromTransportRule = ClassificationDefinitionUtils.GetRuleCollectionDocumentFromTransportRule(this.StoredRuleCollection);

            this.Initialize(ruleCollectionDocumentFromTransportRule);
        }
Example #30
0
        internal void Add(Guid databaseId, DatabaseLocationInfo dbLocationInfo)
        {
            bool flag = false;

            try
            {
                int num = 0;
                while (num < 2 && !flag)
                {
                    flag = this.m_rwlock.TryEnterWriteLock(DatabaseLocationCache.s_cacheLockTimeout);
                    num++;
                }
                if (flag)
                {
                    this.m_cache[databaseId] = new TimedDbInfo(dbLocationInfo);
                }
                else
                {
                    ExAssert.RetailAssert(false, "Timeout waiting for write lock in DatabaseLocationCache.Add()");
                }
            }
            finally
            {
                if (flag)
                {
                    this.m_rwlock.ExitWriteLock();
                }
            }
        }