public void ReplicateQueuedAssociations() { QueuedInProcessAssociationReplicator.Tracer.TraceDebug((long)this.GetHashCode(), "MailboxTaskProcessor.ReplicateQueuedAssociations: Processing associations."); ADUser mailboxAdUser = this.mailbox.FindAdUser(); IDiagnosticsFrameFactory <IExtensibleLogger, IMailboxAssociationPerformanceTracker> diagnosticsFrameFactory = this.diagnosticsFrameFactoryCreator(); IMailboxAssociationPerformanceTracker performanceTracker = diagnosticsFrameFactory.CreatePerformanceTracker(null); IExtensibleLogger logger = diagnosticsFrameFactory.CreateLogger(mailboxAdUser.ExchangeGuid, mailboxAdUser.OrganizationId); IAssociationReplicator replicator = this.immediateReplicatorCreator(logger, performanceTracker); using (MailboxAssociationDiagnosticsFrameFactory.Default.CreateDiagnosticsFrame("QueuedInProcessAssociationReplicator", "ReplicateAssociations", logger, performanceTracker)) { bool inProcessReplicationSucceeded = true; GroupMailboxAccessLayerHelper.ExecuteOperationWithRetry(logger, "QueuedInProcessAssociationReplicator.ReplicateAssociations", delegate { IStoreBuilder storeBuilder = this.storeBuilderCreator(logger, this.clientInfoString); using (IAssociationStore associationStore = storeBuilder.Create(this.mailbox, performanceTracker)) { QueuedInProcessAssociationReplicator.Tracer.TraceDebug <string>((long)this.GetHashCode(), "QueuedInProcessAssociationReplicator.ReplicateAssociationsImplementation: Created store provider. Mailbox={0}.", mailboxAdUser.ExternalDirectoryObjectId); UserAssociationAdaptor masterAdaptor = new UserAssociationAdaptor(associationStore, this.adSession, this.mailbox); while (this.pendingAssociations.Count > 0) { MailboxAssociation association = this.pendingAssociations.Dequeue(); inProcessReplicationSucceeded &= this.ReplicateSingleAssociation(replicator, masterAdaptor, association); } if (!inProcessReplicationSucceeded) { IReplicationAssistantInvoker replicationAssistantInvoker = this.replicationAssistantInvokerCreator(logger, this.replicationServerFqdn); replicationAssistantInvoker.Invoke("QueuedInProcessAssociationReplicatorRpcReplication", masterAdaptor, new MailboxAssociation[0]); } } }, new Predicate <Exception>(GrayException.IsGrayException)); } QueuedInProcessAssociationReplicator.Tracer.TraceDebug((long)this.GetHashCode(), "MailboxTaskProcessor.SendNotificationImplementation: Task completed."); }
internal GroupMailbox GetGroupMailbox(GroupMailboxLocator group, UserMailboxLocator user, bool loadAllDetails = false) { GroupMailbox mailbox; using (IAssociationStore associationStore = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { UserAssociationAdaptor userAssociationAdaptor = new UserAssociationAdaptor(associationStore, this.adSession, group); MailboxAssociation association = userAssociationAdaptor.GetAssociation(user); GroupMailboxBuilder groupMailboxBuilder = new GroupMailboxBuilder(group); groupMailboxBuilder.BuildFromAssociation(association); if (loadAllDetails) { ADUser aduser = group.FindAdUser(); if (aduser == null) { GroupMailboxAccessLayer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "GroupMailboxAccessLayer::GetGroupMailbox. Unable to find group. LegacyDN={0}", group.LegacyDn); throw new MailboxNotFoundException(ServerStrings.ADUserNotFoundId(group.LegacyDn)); } GroupMailboxAccessLayer.Tracer.TraceDebug <string, bool, string>((long)this.GetHashCode(), "GroupMailboxAccessLayer::GetGroupMailbox. Found ADUser for group. LegacyDN={0}, IsCached={1}, OriginatingServer={2}", group.LegacyDn, aduser.IsCached, aduser.OriginatingServer); groupMailboxBuilder.BuildFromDirectory(aduser); } mailbox = groupMailboxBuilder.Mailbox; } return(mailbox); }
private IEnumerable <UserMailbox> GetEscalatedMembersInternal(IAssociationStore storeProvider, GroupMailboxLocator group, bool loadAllDetails = false) { UserAssociationAdaptor adaptor = new UserAssociationAdaptor(storeProvider, this.adSession, group); GetEscalatedAssociations getEscalatedAssociations = new GetEscalatedAssociations(adaptor); IEnumerable <MailboxAssociation> associations = getEscalatedAssociations.Execute(null); return(this.mailboxCollectionBuilder.BuildUserMailboxes(group, associations, loadAllDetails)); }
public void SetEscalate(UserMailboxLocator user, GroupMailboxLocator group, bool shouldEscalate, SmtpAddress userSmtpAddress, int maxNumberOfSubscribers = 400) { using (IAssociationStore associationStore = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { this.LogCommandExecution("SetEscalate", group, new UserMailboxLocator[] { user }); UserAssociationAdaptor masterAdaptor = new UserAssociationAdaptor(associationStore, this.adSession, group); SetEscalate setEscalate = new SetEscalate(this.Logger, shouldEscalate, userSmtpAddress, masterAdaptor, user, maxNumberOfSubscribers); setEscalate.Execute(); } }
public void SetLastVisitedDate(UserMailboxLocator user, GroupMailboxLocator group, ExDateTime lastVisitedDate) { using (IAssociationStore associationStore = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { this.LogCommandExecution("SetLastVisitedDate", group, new UserMailboxLocator[] { user }); UserAssociationAdaptor masterAdaptor = new UserAssociationAdaptor(associationStore, this.adSession, group); SetLastVisitedDate setLastVisitedDate = new SetLastVisitedDate(this.Logger, lastVisitedDate, masterAdaptor, user); setLastVisitedDate.Execute(); } }
public IEnumerable <UserMailbox> GetMembers(GroupMailboxLocator group, IEnumerable <UserMailboxLocator> users, bool loadAllDetails = false) { using (IAssociationStore storeProvider = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { UserAssociationAdaptor adaptor = new UserAssociationAdaptor(storeProvider, this.adSession, group); IEnumerable <UserMailbox> mailboxes = this.mailboxCollectionBuilder.BuildUserMailboxes(group, from u in users select new GetMemberAssociation(adaptor, u).Execute(), loadAllDetails); foreach (UserMailbox mailbox in mailboxes) { yield return(mailbox); } } yield break; }
public IEnumerable <UserMailbox> GetGroupPinners(GroupMailboxLocator group, bool loadAllDetails = false) { using (IAssociationStore storeProvider = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { UserAssociationAdaptor adaptor = new UserAssociationAdaptor(storeProvider, this.adSession, group); GetPinAssociations command = new GetPinAssociations(adaptor); IEnumerable <MailboxAssociation> pinAssociations = command.Execute(null); IEnumerable <UserMailbox> mailboxes = this.mailboxCollectionBuilder.BuildUserMailboxes(group, pinAssociations, loadAllDetails); foreach (UserMailbox mailbox in mailboxes) { yield return(mailbox); } } yield break; }
public UserMailbox GetMember(GroupMailboxLocator group, UserMailboxLocator user, bool loadAllDetails = false) { UserMailbox result; using (IAssociationStore associationStore = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { UserAssociationAdaptor adaptor = new UserAssociationAdaptor(associationStore, this.adSession, group); GetMemberAssociation getMemberAssociation = new GetMemberAssociation(adaptor, user); MailboxAssociation item = getMemberAssociation.Execute(); result = this.mailboxCollectionBuilder.BuildUserMailboxes(group, new List <MailboxAssociation>(1) { item }, loadAllDetails).FirstOrDefault <UserMailbox>(); } return(result); }
public void SetMembershipState(ADRecipient joinedBy, UserMailboxLocator[] joiningUsers, UserMailboxLocator[] departingUsers, GroupMailboxLocator group) { string joinedBy2 = string.Empty; if (joinedBy != null) { joinedBy2 = ((SmtpAddress)joinedBy[ADRecipientSchema.PrimarySmtpAddress]).ToString(); } using (IAssociationStore associationStore = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { ADUser groupMailbox = group.FindAdUser(); WelcomeToGroupMessageTemplate messageComposerBuilder = new WelcomeToGroupMessageTemplate(groupMailbox, associationStore.MailboxOwner, joinedBy); EmailNotificationHandler joinNotificationHandler = new EmailNotificationHandler(groupMailbox, associationStore.MailboxOwner, this.clientString, messageComposerBuilder); QueuedInProcessAssociationReplicator associationReplicator = new QueuedInProcessAssociationReplicator(group, this.adSession, associationStore.ServerFullyQualifiedDomainName, this.clientString); try { UserAssociationAdaptor userAssociationAdaptor = new UserAssociationAdaptor(associationStore, this.adSession, group); if (departingUsers != null && departingUsers.Length > 0) { this.LogCommandExecution("LeaveGroup", group, departingUsers); SetUserMembershipState setUserMembershipState = new SetUserMembershipState(this.Logger, associationReplicator, false, joinedBy2, userAssociationAdaptor, this.adSession, departingUsers); setUserMembershipState.Execute(); } if (joiningUsers != null && joiningUsers.Length > 0) { this.LogCommandExecution("JoinGroup", group, joiningUsers); userAssociationAdaptor.OnAfterJoin += joinNotificationHandler.AddNotificationRecipient; SetUserMembershipState setUserMembershipState2 = new SetUserMembershipState(this.Logger, associationReplicator, true, joinedBy2, userAssociationAdaptor, this.adSession, joiningUsers); setUserMembershipState2.Execute(); userAssociationAdaptor.OnAfterJoin -= joinNotificationHandler.AddNotificationRecipient; } } finally { Task.Run(delegate() { associationReplicator.ReplicateQueuedAssociations(); }).ContinueWith(delegate(Task t) { joinNotificationHandler.SendNotification(); }); } } }
public IEnumerable <UserMailbox> GetMembers(GroupMailboxLocator group, bool loadAllDetails = false, int?maxItems = null) { using (IAssociationStore storeProvider = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { UserAssociationAdaptor adaptor = new UserAssociationAdaptor(storeProvider, this.adSession, group); GetAssociationCommand command = new GetMembershipAssociations(adaptor); IEnumerable <MailboxAssociation> members = command.Execute(maxItems); RpcAssociationReplicator rpcReplicator = new RpcAssociationReplicator(this.Logger, storeProvider.ServerFullyQualifiedDomainName); ReplicatorEnabledAssociationEnumerator eventualConsistencyEnumerator = new ReplicatorEnabledAssociationEnumerator(rpcReplicator, members, storeProvider); try { IEnumerable <UserMailbox> mailboxes = this.mailboxCollectionBuilder.BuildUserMailboxes(group, eventualConsistencyEnumerator, loadAllDetails); foreach (UserMailbox mailbox in mailboxes) { yield return(mailbox); } } finally { eventualConsistencyEnumerator.TriggerReplication(adaptor); } } yield break; }