예제 #1
0
        private static SharepointValidator Create(IConfigurationSession configurationSession, ADObjectId executingUserId, Task.TaskErrorLoggingDelegate writeErrorDelegate, Action <LocalizedString> writeWarningDelegate, Func <LocalizedString, bool> shouldContinueDelegate, string logTag, SourceValidator.Clients client, int existingSitesCount, ExecutionLog logger)
        {
            ArgumentValidator.ThrowIfNull("configurationSession", configurationSession);
            Uri            uri            = null;
            Uri            uri2           = null;
            OrganizationId organizationId = configurationSession.GetOrgContainer().OrganizationId;

            UnifiedPolicyConfiguration.GetInstance().GetTenantSharePointUrls(configurationSession, out uri, out uri2);
            if (uri == null)
            {
                EventNotificationItem.Publish(ExchangeComponent.UnifiedComplianceSourceValidation.Name, "SharepointValidatorUnexpectedError", client.ToString(), string.Format("Tenant {0}, Error:{1}", organizationId.ToExternalDirectoryOrganizationId(), Strings.FailedToGetSpSiteUrlForTenant), ResultSeverityLevel.Error, false);
                throw new SpValidatorException(Strings.FailedToGetSpSiteUrlForTenant);
            }
            ADUser actAsUser = null;

            if (executingUserId != null)
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromExternalDirectoryOrganizationId(new Guid(organizationId.ToExternalDirectoryOrganizationId()));
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 520, "Create", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\UnifiedPolicy\\Validators\\SharepointValidator.cs");
                actAsUser = tenantOrRootOrgRecipientSession.FindADUserByObjectId(executingUserId);
            }
            ICredentials credentials = UnifiedPolicyConfiguration.GetInstance().GetCredentials(configurationSession, actAsUser);

            if (credentials == null)
            {
                EventNotificationItem.Publish(ExchangeComponent.UnifiedComplianceSourceValidation.Name, "SharepointValidatorUnexpectedError", client.ToString(), string.Format("Tenant {0}, Error:{1}", organizationId.ToExternalDirectoryOrganizationId(), Strings.FailedToGetCredentialsForTenant), ResultSeverityLevel.Error, false);
                throw new SpValidatorException(Strings.FailedToGetCredentialsForTenant);
            }
            int maxLimitFromConfig = SourceValidator.GetMaxLimitFromConfig("MaxSitesLimit", 100, existingSitesCount);

            return(new SharepointValidator(uri, credentials, executingUserId != null, writeErrorDelegate, writeWarningDelegate, shouldContinueDelegate, maxLimitFromConfig, logger, logTag, organizationId.ToExternalDirectoryOrganizationId(), client));
        }
예제 #2
0
        protected void EnsureGroupMailboxData(StoreSession session)
        {
            this.ClearExpiredCacheData();
            if (this.groupsCache.ContainsKey(session.MailboxGuid))
            {
                return;
            }
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, session.GetADSessionSettings(), 466, "EnsureGroupMailboxData", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\WorkingSet\\Publisher\\WorkingSetPublisher.cs");
            ADUser            adUser;

            if (session.MailboxOwner.ObjectId != null)
            {
                adUser = tenantOrRootOrgRecipientSession.FindADUserByObjectId(session.MailboxOwner.ObjectId);
            }
            else
            {
                adUser = (tenantOrRootOrgRecipientSession.FindByLegacyExchangeDN(session.MailboxOwner.LegacyDn) as ADUser);
            }
            WorkingSetPublisher.GroupMailboxData groupMailboxData = new WorkingSetPublisher.GroupMailboxData
            {
                TargetUsers = this.CalculateTargetUsers(adUser, tenantOrRootOrgRecipientSession, session),
                TimeStamp   = DateTime.UtcNow
            };
            if (groupMailboxData.TargetUsers.Count > WorkingSetPublisherConfiguration.MaxTargetUsersToCachePerModernGroup)
            {
                groupMailboxData.TimeStamp -= WorkingSetPublisherConfiguration.ModernGroupsDataExpiryTime;
            }
            this.groupsCache[session.MailboxGuid] = groupMailboxData;
        }
예제 #3
0
        // Token: 0x06001517 RID: 5399 RVA: 0x00078898 File Offset: 0x00076A98
        protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
        {
            MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession;

            mailboxSession.Mailbox.Load(GroupMailboxAssistantType.ExtendedProperties);
            if (mailboxSession.MailboxOwner.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox)
            {
                GroupMailboxAssistant.Tracer.TraceError((long)this.GetHashCode(), "ActivityId : {0} ; Mailbox : TypeDetail {1} , SmtpAddress {2}, ExchangeGuid {3} cannot be processed by GroupMailboxAssistant, Parameters {4}", new object[]
                {
                    invokeArgs.ActivityId,
                    mailboxSession.MailboxOwner.RecipientTypeDetails,
                    mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                    mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid,
                    invokeArgs.Parameters
                });
                customDataToLog.Add(new KeyValuePair <string, object>("GroupMailboxAssistantInfo", "Mailbox cannot be processed by GroupMailboxAssistant"));
                return;
            }
            this.UpdateGroupMailboxMembership(mailboxSession);
            IRecipientSession adrecipientSession = mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent);
            ADUser            adUser             = adrecipientSession.FindADUserByObjectId(mailboxSession.MailboxOwner.ObjectId);

            this.UploadDefaultPhoto(adrecipientSession, adUser, invokeArgs, customDataToLog);
            this.PublishExchangeResourcesToAAD(adrecipientSession, adUser, invokeArgs, customDataToLog);
        }
예제 #4
0
        public static IAuthenticator Create(OrganizationId organizationId, ADObjectId executingUserId)
        {
            ArgumentValidator.ThrowIfNull("organizationId", organizationId);
            ArgumentValidator.ThrowIfNull("executingUserId", executingUserId);
            ADSessionSettings sessionSettings = ADSessionSettings.FromExternalDirectoryOrganizationId(new Guid(organizationId.ToExternalDirectoryOrganizationId()));
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 54, "Create", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\EOPRecipient\\Authenticator.cs");
            ADUser            actAsUser = tenantOrRootOrgRecipientSession.FindADUserByObjectId(executingUserId);
            OAuthCredentials  oauthCredentialsForAppActAsToken = OAuthCredentials.GetOAuthCredentialsForAppActAsToken(organizationId, actAsUser, null);

            return(new Authenticator(oauthCredentialsForAppActAsToken));
        }
        // Token: 0x06001534 RID: 5428 RVA: 0x00079274 File Offset: 0x00077474
        private void PerformDataReplication(MailboxSession mailboxSession, InvokeArgs invokeArgs)
        {
            IRecipientSession adSession            = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, mailboxSession.GetADSessionSettings(), 139, "PerformDataReplication", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\MailboxAssociation\\MailboxAssociationReplicationAssistant.cs");
            string            operationDescription = MailboxAssociationReplicationAssistant.GetOperationDescription(invokeArgs.Parameters);

            GroupMailboxAccessLayer.Execute(operationDescription, adSession, mailboxSession, delegate(GroupMailboxAccessLayer accessLayer)
            {
                ADObjectId objectId = invokeArgs.StoreSession.MailboxOwner.ObjectId;
                MailboxAssociationReplicationAssistant.Tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "MailboxAssociationReplicationAssistant.InvokeInternal - Replicating associations via MailboxAssistant for mailbox with ID {0}", objectId);
                ADUser aduser = adSession.FindADUserByObjectId(objectId);
                if (aduser == null)
                {
                    string text = string.Format("MailboxAssociationReplicationAssistant.InvokeInternal - Couldn't find AdUser with AdObjectId {0}.", objectId);
                    MailboxAssociationReplicationAssistant.Tracer.TraceDebug((long)this.GetHashCode(), text);
                    LocalAssociationStore.SaveMailboxSyncStatus(mailboxSession, new ExDateTime?(ExDateTime.Now.Add(MailboxAssociationReplicationAssistant.TimeToWaitForAdReplication)), null);
                    accessLayer.Logger.LogEvent(new SchemaBasedLogEvent <MailboxAssociationLogSchema.Error>
                    {
                        {
                            MailboxAssociationLogSchema.Error.Context,
                            "MailboxAssociationReplicationAssistant"
                        },
                        {
                            MailboxAssociationLogSchema.Error.Exception,
                            text
                        }
                    });
                    return;
                }
                if (aduser.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox && aduser.RecipientTypeDetails != RecipientTypeDetails.UserMailbox)
                {
                    MailboxAssociationReplicationAssistant.Tracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "Skipping mailbox with guid {0} and display name {1} since this is a {2} and not a GroupMailbox or UserMailbox", mailboxSession.MailboxGuid, mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxOwner.RecipientTypeDetails.ToString());
                    return;
                }
                MailboxAssociationReplicationAssistant.Tracer.TraceDebug <string, string>((long)this.GetHashCode(), "MailboxAssociationReplicationAssistant.InvokeInternal - Master Mailbox: ExternalID {0}, LegDN {1}", aduser.ExternalDirectoryObjectId, aduser.LegacyExchangeDN);
                ICollection <IMailboxLocator> associationsToReplicate = MailboxAssociationReplicationAssistant.GetAssociationsToReplicate(invokeArgs.Parameters, adSession);
                if (associationsToReplicate == null)
                {
                    MailboxAssociationReplicationAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "MailboxAssociationReplicationAssistant.InvokeInternal - No locators provided in RunNow parameters, replicating all out-of-sync associations");
                    this.ReplicateOutOfSyncAssociations(mailboxSession, aduser, adSession, accessLayer);
                    return;
                }
                MailboxAssociationReplicationAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "MailboxAssociationReplicationAssistant.InvokeInternal - Found slave locators in RunNow parameters, replicating only provided associations");
                this.ReplicateAssociations(aduser, adSession, associationsToReplicate, accessLayer);
            });
        }
예제 #6
0
        internal static ICredentials GetCredentialAndConfigureClientContext(ADRawEntry actAsUser, OrganizationId actAsUserOrgId, ClientContext context, bool createAppTokenOnly, out bool isOAuthCredential)
        {
            if (!createAppTokenOnly && actAsUser == null)
            {
                throw new ArgumentNullException("actAsUser");
            }
            if (actAsUserOrgId == null)
            {
                throw new ArgumentNullException("actAsUserOrgId");
            }
            int num = 0;

            isOAuthCredential = true;
            RegistryKey registryKey = null;

            try
            {
                registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\MSExchangeRPC\\ParametersSystem", RegistryKeyPermissionCheck.ReadSubTree);
                if (registryKey != null)
                {
                    num = (int)registryKey.GetValue("TMPublishHttpDebugEnabled", 0);
                    if ((int)registryKey.GetValue("TMOAuthEnabled", 1) == 0)
                    {
                        isOAuthCredential = false;
                        return(null);
                    }
                }
            }
            catch (SecurityException)
            {
                return(null);
            }
            catch (IOException)
            {
                return(null);
            }
            catch (UnauthorizedAccessException)
            {
                return(null);
            }
            finally
            {
                if (registryKey != null)
                {
                    registryKey.Close();
                }
            }
            ICredentials credentials;

            if (createAppTokenOnly)
            {
                credentials = OAuthCredentials.GetOAuthCredentialsForAppToken(actAsUserOrgId, "PlaceHolder");
            }
            else
            {
                ADObjectId        id = actAsUser.Id;
                ADSessionSettings sessionSettings = ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(id);
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 552, "GetCredentialAndConfigureClientContext", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\TeamMailbox\\TeamMailboxHelper.cs");
                ADUser            aduser = tenantOrRootOrgRecipientSession.FindADUserByObjectId(id);
                credentials = OAuthCredentials.GetOAuthCredentialsForAppActAsToken(actAsUserOrgId, aduser, null);
            }
            if (context != null)
            {
                context.Credentials = credentials;
                context.FormDigestHandlingEnabled = false;
                context.ExecutingWebRequest      += delegate(object sender, WebRequestEventArgs args)
                {
                    args.WebRequestExecutor.RequestHeaders.Add(HttpRequestHeader.Authorization, "Bearer");
                    args.WebRequestExecutor.RequestHeaders.Add("client-request-id", Guid.NewGuid().ToString());
                    args.WebRequestExecutor.RequestHeaders.Add("return-client-request-id", "true");
                    args.WebRequestExecutor.WebRequest.PreAuthenticate = true;
                    args.WebRequestExecutor.WebRequest.UserAgent       = Utils.GetUserAgentStringForSiteMailboxRequests();
                };
                if (num == 1)
                {
                    context.ExecutingWebRequest += delegate(object sender, WebRequestEventArgs args)
                    {
                        args.WebRequestExecutor.WebRequest.Proxy = new WebProxy("127.0.0.1", 8888);
                    };
                }
            }
            return(credentials);
        }
예제 #7
0
        protected override void InternalProcessRecord()
        {
            IRecipientSession recipientSession = (IRecipientSession)base.DataSession;

            this.groupMailboxContext = new GroupMailboxContext(this.DataObject, base.CurrentOrganizationId, recipientSession, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADGroup>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.ErrorLoggerDelegate(base.WriteError));
            if (this.ExecutingUser != null)
            {
                this.groupMailboxContext.SetExecutingUser(this.ExecutingUser);
                this.executingUserIsOwner = this.DataObject.Owners.Any((ADObjectId ownerId) => ADObjectId.Equals(this.groupMailboxContext.ExecutingUser.Id, ownerId));
            }
            else
            {
                this.executingUserIsOwner = true;
            }
            if (base.Fields.IsChanged(ADObjectSchema.Name))
            {
                this.ThrowIfNotOwner("Name");
                this.DataObject.Name = (string)base.Fields[ADObjectSchema.Name];
            }
            if (base.Fields.IsChanged(ADRecipientSchema.DisplayName))
            {
                this.ThrowIfNotOwner("DisplayName");
                this.DataObject.DisplayName = (string)base.Fields[ADRecipientSchema.DisplayName];
            }
            if (base.Fields.IsChanged(ADRecipientSchema.Description))
            {
                this.ThrowIfNotOwner("Description");
                this.DataObject.Description.Clear();
                this.DataObject.Description.Add((string)base.Fields[ADRecipientSchema.Description]);
            }
            bool flag = false;

            if (base.Fields.IsChanged(ADUserSchema.Owners) && this.Owners != null)
            {
                this.ThrowIfNotOwner("Owners");
                flag |= this.groupMailboxContext.SetOwners(this.Owners);
            }
            if (base.Fields.IsModified("AddOwners") && this.AddOwners != null)
            {
                this.ThrowIfNotOwner("AddOwners");
                flag |= this.groupMailboxContext.AddOwners(this.AddOwners);
            }
            if (base.Fields.IsModified("RemoveOwners") && this.RemoveOwners != null)
            {
                this.ThrowIfNotOwner("RemoveOwners");
                flag |= this.groupMailboxContext.RemoveOwners(this.RemoveOwners);
            }
            if (base.Fields.IsChanged(ADMailboxRecipientSchema.DelegateListLink))
            {
                this.ThrowIfNotOwner("PublicToGroups");
                this.DataObject.DelegateListLink.Clear();
                this.groupMailboxContext.AddPublicToGroups(this.PublicToGroups);
            }
            if (base.Fields.IsChanged(ADRecipientSchema.ModernGroupType))
            {
                this.DataObject.ModernGroupType = (ModernGroupObjectType)base.Fields[ADRecipientSchema.ModernGroupType];
            }
            if (base.Fields.IsChanged("RequireSenderAuthenticationEnabled"))
            {
                this.ThrowIfNotOwner("RequireSenderAuthenticationEnabled");
                this.DataObject.RequireAllSendersAreAuthenticated = this.RequireSenderAuthenticationEnabled;
            }
            if (base.Fields.IsChanged("YammerGroupEmailAddress"))
            {
                this.DataObject.YammerGroupAddress = this.YammerGroupEmailAddress;
            }
            if (base.Fields.IsChanged("AutoSubscribeNewGroupMembers"))
            {
                this.ThrowIfNotOwner("AutoSubscribeNewGroupMembers");
                this.DataObject.AutoSubscribeNewGroupMembers = this.AutoSubscribeNewGroupMembers;
            }
            if (base.Fields.IsChanged("Language") && this.Language != null)
            {
                this.DataObject.Languages.Clear();
                this.DataObject.Languages.Add(this.Language);
            }
            if (this.MembersChanged)
            {
                this.AuthorizeAddedAndRemovedMembers(this.groupMailboxContext.ExecutingUser);
                this.groupMailboxContext.AddAndRemoveMembers(this.AddedMembers, this.RemovedMembers);
            }
            if (base.Fields.IsModified(ADMailboxRecipientSchema.SharePointUrl))
            {
                this.ThrowIfNotOwner("SharePointUrl");
                if (this.DataObject.SharePointResources == null)
                {
                    this.DataObject.SharePointResources = new MultiValuedProperty <string>();
                }
                else
                {
                    foreach (string text in this.DataObject.SharePointResources)
                    {
                        if (text.StartsWith("SiteUrl=", StringComparison.OrdinalIgnoreCase))
                        {
                            this.DataObject.SharePointResources.Remove(text);
                            break;
                        }
                    }
                }
                if (this.SharePointUrl != null)
                {
                    this.DataObject.SharePointResources.Add("SiteUrl=" + this.SharePointUrl);
                }
            }
            if (base.Fields.IsModified(ADMailboxRecipientSchema.SharePointResources))
            {
                this.ThrowIfNotOwner("SharePointResources");
                this.DataObject.SharePointResources = this.SharePointResources;
                this.DataObject.SharePointUrl       = null;
            }
            if (base.Fields.IsModified("PermissionsVersion"))
            {
                this.groupMailboxContext.SetPermissionsVersion(this.PermissionsVersion);
            }
            GroupMailboxConfigurationActionType groupMailboxConfigurationActionType = (GroupMailboxConfigurationActionType)0;

            if (base.Fields.IsModified("ConfigurationActions") && this.ConfigurationActions != null)
            {
                foreach (GroupMailboxConfigurationActionType groupMailboxConfigurationActionType2 in this.ConfigurationActions)
                {
                    groupMailboxConfigurationActionType |= groupMailboxConfigurationActionType2;
                }
            }
            Exception             ex;
            ExchangeErrorCategory?exchangeErrorCategory;

            this.groupMailboxContext.SetGroupMailbox(groupMailboxConfigurationActionType, out ex, out exchangeErrorCategory);
            if (ex != null)
            {
                base.WriteError(new GroupMailboxFailedToLogonException(Strings.ErrorUnableToLogonGroupMailbox(this.DataObject.ExchangeGuid, string.Empty, recipientSession.LastUsedDc, ex.Message)), exchangeErrorCategory.GetValueOrDefault(ExchangeErrorCategory.ServerTransient), null);
            }
            bool flag2 = false;

            if (!this.FromSyncClient)
            {
                if (base.Fields.IsChanged(GroupMailboxSchema.PrimarySmtpAddress))
                {
                    this.DataObject.PrimarySmtpAddress = this.PrimarySmtpAddress;
                    flag2 = true;
                }
                if (base.Fields.IsChanged(GroupMailboxSchema.EmailAddresses))
                {
                    this.DataObject.EmailAddresses = this.EmailAddresses;
                    flag2 = true;
                }
            }
            else if (base.Fields.IsChanged(GroupMailboxSchema.EmailAddresses))
            {
                foreach (ProxyAddress proxyAddress in this.EmailAddresses)
                {
                    if (!this.DataObject.EmailAddresses.Contains(proxyAddress))
                    {
                        if (proxyAddress.IsPrimaryAddress && proxyAddress is SmtpProxyAddress)
                        {
                            this.DataObject.EmailAddresses.Add(proxyAddress.ToSecondary());
                        }
                        else
                        {
                            this.DataObject.EmailAddresses.Add(proxyAddress);
                        }
                        flag2 = true;
                    }
                }
            }
            if (flag2 && this.DataObject.EmailAddressPolicyEnabled)
            {
                this.DataObject.EmailAddressPolicyEnabled = false;
            }
            if (base.Fields.IsModified(ADRecipientSchema.ExternalDirectoryObjectId))
            {
                this.DataObject.ExternalDirectoryObjectId = this.ExternalDirectoryObjectId;
            }
            base.InternalProcessRecord();
            this.DataObject = recipientSession.FindADUserByObjectId(this.DataObject.ObjectId);
            if (flag)
            {
                this.groupMailboxContext.RefreshStoreCache();
            }
            if (!this.DataObject.GroupMailboxExternalResourcesSet || this.ForcePublishExternalResources)
            {
                this.groupMailboxContext.SetExternalResources(this.FromSyncClient);
            }
            this.groupMailboxContext.EnsureGroupIsInDirectoryCache("SetGroupMailbox.InternalProcessRecord");
        }
예제 #8
0
        // Token: 0x060008FA RID: 2298 RVA: 0x0003CBC0 File Offset: 0x0003ADC0
        internal void UpdateAllUserSettings(IRecipientSession recipientSession, long cookie, Initiating.ActOnUserSettingsDelegate updateUserSettings, Predicate <ADRawEntry> validate)
        {
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, ADMailboxRecipientSchema.Database, new ADObjectId(base.Context.Guid)),
                new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientType, RecipientType.UserMailbox)
            });
            ADPagedReader <ADRawEntry> adpagedReader = recipientSession.FindPagedADRawEntry(null, QueryScope.SubTree, filter, null, 0, new PropertyDefinition[]
            {
                ADObjectSchema.Id,
                ADRecipientSchema.TextMessagingState,
                IADMailStorageSchema.ExchangeGuid
            });

            using (IEnumerator <ADRawEntry> enumerator = adpagedReader.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ADRawEntry recipient = enumerator.Current;
                    if (!base.ShouldContinue(cookie))
                    {
                        break;
                    }
                    if (validate == null || validate(recipient))
                    {
                        if (this.mailboxTable == null)
                        {
                            this.mailboxTable = base.Context.GetMailboxTable(ClientType.EventBased, new PropertyTagPropertyDefinition[0]);
                        }
                        if (!this.mailboxTable.Exists((MailboxInformation mbxInfo) => mbxInfo.MailboxGuid == (Guid)recipient[IADMailStorageSchema.ExchangeGuid]))
                        {
                            ADUser aduser = recipientSession.FindADUserByObjectId((ADObjectId)recipient[ADObjectSchema.Id]);
                            if (aduser != null)
                            {
                                ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(aduser, null);
                                MailboxSession    mailboxSession    = null;
                                try
                                {
                                    mailboxSession = base.Context.GetMailbox(exchangePrincipal, ClientType.EventBased, "UpdateAllUserSettings");
                                    if (!base.ShouldContinue(cookie))
                                    {
                                        break;
                                    }
                                    updateUserSettings(mailboxSession, recipientSession, aduser);
                                }
                                catch (NotSupportedException arg)
                                {
                                    ExTraceGlobals.AssistantTracer.TraceError <string, NotSupportedException>((long)this.GetHashCode(), "Exception is caught during syncing text messaging settings to AD user object for {0}: {1}", exchangePrincipal.LegacyDn, arg);
                                }
                                catch (Exception ex)
                                {
                                    if (!CalendarNotificationAssistant.TryHandleException((long)this.GetHashCode(), "Update all user's settings", exchangePrincipal.LegacyDn, ex))
                                    {
                                        throw;
                                    }
                                }
                                finally
                                {
                                    if (mailboxSession != null)
                                    {
                                        mailboxSession.Dispose();
                                        mailboxSession = null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }