Esempio n. 1
0
 private void WriteMembersToGroupIfRequired(MailboxSession mailboxSession)
 {
     if (this.addedMembers == null && this.removedMembers == null)
     {
         return;
     }
     GroupMailboxAccessLayer.Execute("UpdateGroupMailboxViaXSO.WriteMembersToGroupIfRequired", this.adSession, mailboxSession, delegate(GroupMailboxAccessLayer accessLayer)
     {
         GroupMailboxLocator group = GroupMailboxLocator.Instantiate(this.adSession, this.group);
         accessLayer.SetMembershipState(this.executingUser, this.addedMembers, this.removedMembers, group);
     });
 }
        // 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);
            });
        }
Esempio n. 3
0
        private ADRawEntry[] GetMemberRawEntriesFromMailbox(IRecipientSession recipientSession, ADUser adUser, MailboxSession mailboxSession)
        {
            GroupMailboxLocator groupLocator      = GroupMailboxLocator.Instantiate(recipientSession, adUser);
            List <string>       exchangeLegacyDNs = new List <string>(10);

            GroupMailboxAccessLayer.Execute("Get-GroupMailbox", recipientSession, mailboxSession, delegate(GroupMailboxAccessLayer accessLayer)
            {
                IEnumerable <UserMailbox> members = accessLayer.GetMembers(groupLocator, false, null);
                foreach (UserMailbox userMailbox in members)
                {
                    exchangeLegacyDNs.Add(userMailbox.Locator.LegacyDn);
                }
            });
            string[]          array = exchangeLegacyDNs.ToArray();
            List <ADRawEntry> list  = new List <ADRawEntry>(array.Length);

            try
            {
                Result <ADRawEntry>[] array2 = recipientSession.FindByExchangeLegacyDNs(array, IdentityDetails.Properties);
                for (int i = 0; i < array2.Length; i++)
                {
                    Result <ADRawEntry> result = array2[i];
                    if (result.Error != null)
                    {
                        this.WriteWarning(Strings.WarningUnableToResolveUser(array[i].ToString(), result.Error.ToString()));
                    }
                    else if (result.Data == null)
                    {
                        base.WriteVerbose(Strings.WarningUnableToResolveUser(array[i].ToString(), string.Empty));
                    }
                    else
                    {
                        list.Add(result.Data);
                    }
                }
            }
            catch (LocalizedException ex)
            {
                base.WriteWarning("Unable to retrieve members details from mailbox due exception: " + ex.Message);
            }
            return(list.ToArray());
        }
Esempio n. 4
0
        internal string[] GetMembers(ADUser groupMailbox, IRecipientSession recipientSession, string operation)
        {
            List <string> externalDirectoryObjectIds = new List <string>(10);

            this.WriteVerbose("Getting members from group mailbox: {0}", new object[]
            {
                groupMailbox.Id
            });
            using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(ExchangePrincipal.FromADUser(groupMailbox, RemotingOptions.AllowCrossSite), CultureInfo.InvariantCulture, "Client=Management;Action=" + operation))
            {
                GroupMailboxAccessLayer.Execute(operation, recipientSession, mailboxSession, delegate(GroupMailboxAccessLayer accessLayer)
                {
                    GroupMailboxLocator group         = GroupMailboxLocator.Instantiate(recipientSession, groupMailbox);
                    IEnumerable <UserMailbox> members = accessLayer.GetMembers(group, false, null);
                    foreach (UserMailbox userMailbox in members)
                    {
                        if (string.IsNullOrEmpty(userMailbox.Locator.ExternalId))
                        {
                            this.WriteVerbose("Group member is missing ExternalId: {0}", new object[]
                            {
                                userMailbox.Locator.LegacyDn
                            });
                        }
                        else
                        {
                            externalDirectoryObjectIds.Add(userMailbox.Locator.ExternalId);
                            this.WriteVerbose("Group member: {0}, ExternalDirectoryObjectId={1}", new object[]
                            {
                                userMailbox.Locator.LegacyDn,
                                userMailbox.Locator.ExternalId
                            });
                        }
                    }
                });
            }
            return(externalDirectoryObjectIds.ToArray());
        }