Esempio n. 1
0
        internal static MasterMailboxType CreateMasterMailboxData(IMailboxLocator master)
        {
            ArgumentValidator.ThrowIfNull("master", master);
            ADUser            aduser            = master.FindAdUser();
            MasterMailboxType masterMailboxType = new MasterMailboxType
            {
                Alias       = aduser.Alias,
                DisplayName = aduser.DisplayName,
                SmtpAddress = aduser.PrimarySmtpAddress.ToString(),
                MailboxType = master.LocatorType
            };
            GroupMailboxLocator groupMailboxLocator = master as GroupMailboxLocator;

            if (groupMailboxLocator != null)
            {
                MailboxUrls mailboxUrls = new MailboxUrls(ExchangePrincipal.FromADUser(aduser, RemotingOptions.AllowCrossSite), false);
                masterMailboxType.GroupType          = EwsAssociationDataConverter.Convert(groupMailboxLocator.GetGroupType());
                masterMailboxType.GroupTypeSpecified = true;
                masterMailboxType.Description        = ((aduser.Description != null && aduser.Description.Count > 0) ? aduser.Description[0] : string.Empty);
                masterMailboxType.Photo            = groupMailboxLocator.GetThumbnailPhoto();
                masterMailboxType.SharePointUrl    = ((aduser.SharePointUrl != null) ? aduser.SharePointUrl.ToString() : string.Empty);
                masterMailboxType.InboxUrl         = mailboxUrls.InboxUrl;
                masterMailboxType.CalendarUrl      = mailboxUrls.CalendarUrl;
                masterMailboxType.DomainController = aduser.OriginatingServer;
            }
            return(masterMailboxType);
        }
Esempio n. 2
0
 internal static UpdateMailboxAssociationType CreateUpdateMailboxAssociationType(IMailboxLocator master, MailboxAssociation association)
 {
     ArgumentValidator.ThrowIfNull("association", association);
     return(new UpdateMailboxAssociationType
     {
         Master = InProcessAssociationReplicator.CreateMasterMailboxData(master),
         Association = EwsAssociationDataConverter.Convert(association)
     });
 }
Esempio n. 3
0
 internal static MailboxAssociation Convert(MailboxAssociationType associationType, IRecipientSession adSession)
 {
     ArgumentValidator.ThrowIfNull("associationType", associationType);
     ArgumentValidator.ThrowIfNull("adSession", adSession);
     return(new MailboxAssociation
     {
         Group = EwsAssociationDataConverter.Convert(associationType.Group, adSession),
         User = EwsAssociationDataConverter.Convert(associationType.User, adSession),
         IsMember = associationType.IsMember,
         IsPin = associationType.IsPin,
         JoinDate = (ExDateTime)associationType.JoinDate,
         JoinedBy = associationType.JoinedBy
     });
 }
Esempio n. 4
0
 internal static MailboxAssociationType Convert(MailboxAssociation association)
 {
     ArgumentValidator.ThrowIfNull("association", association);
     return(new MailboxAssociationType
     {
         User = EwsAssociationDataConverter.Convert(association.User),
         Group = EwsAssociationDataConverter.Convert(association.Group),
         IsMember = association.IsMember,
         IsMemberSpecified = true,
         IsPin = association.IsPin,
         IsPinSpecified = true,
         JoinDate = (DateTime)association.JoinDate,
         JoinDateSpecified = true,
         JoinedBy = association.JoinedBy
     });
 }
Esempio n. 5
0
        internal static MailboxLocatorType Convert(IMailboxLocator locator)
        {
            ArgumentValidator.ThrowIfNull("locator", locator);
            GroupMailboxLocator groupMailboxLocator = locator as GroupMailboxLocator;

            if (groupMailboxLocator != null)
            {
                return(EwsAssociationDataConverter.Convert(groupMailboxLocator));
            }
            UserMailboxLocator userMailboxLocator = locator as UserMailboxLocator;

            if (userMailboxLocator != null)
            {
                return(EwsAssociationDataConverter.Convert(userMailboxLocator));
            }
            throw new NotImplementedException(string.Format("Conversion of '{0}' is not yet supported.", locator.GetType()));
        }
Esempio n. 6
0
 private static RpcAssociationReplicatorRunNowParameters Instantiate(List <MailboxLocatorType> locators, IRecipientSession adSession)
 {
     ArgumentValidator.ThrowIfNull("adSession", adSession);
     if (locators != null && locators.Count > 0)
     {
         List <IMailboxLocator> list = new List <IMailboxLocator>(locators.Count);
         for (int i = 0; i < locators.Count; i++)
         {
             list.Add(EwsAssociationDataConverter.Convert(locators[i], adSession));
         }
         return(new RpcAssociationReplicatorRunNowParameters
         {
             SlaveMailboxes = list
         });
     }
     return(new RpcAssociationReplicatorRunNowParameters());
 }
Esempio n. 7
0
        internal static MailboxLocator Convert(MailboxLocatorType locatorType, IRecipientSession adSession)
        {
            ArgumentValidator.ThrowIfNull("locatorType", locatorType);
            ArgumentValidator.ThrowIfNull("adSession", adSession);
            GroupLocatorType groupLocatorType = locatorType as GroupLocatorType;

            if (groupLocatorType != null)
            {
                return(EwsAssociationDataConverter.Convert(groupLocatorType, adSession));
            }
            UserLocatorType userLocatorType = locatorType as UserLocatorType;

            if (userLocatorType != null)
            {
                return(EwsAssociationDataConverter.Convert(userLocatorType, adSession));
            }
            throw new InvalidOperationException("Unsupported type of Mailbox Locator");
        }
Esempio n. 8
0
        public override string ToString()
        {
            List <MailboxLocatorType> list = new List <MailboxLocatorType>(this.SlaveMailboxes.Count);

            foreach (IMailboxLocator locator in this.SlaveMailboxes)
            {
                list.Add(EwsAssociationDataConverter.Convert(locator));
            }
            SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(list.GetType());
            string            result;

            using (StringWriter stringWriter = new StringWriter())
            {
                safeXmlSerializer.Serialize(stringWriter, list);
                result = stringWriter.ToString();
            }
            return(result);
        }
        public void UpdateSlaveDataFromMailboxAssociation(MasterMailboxType masterMailboxData, MailboxAssociationType associationType)
        {
            GroupMailboxAccessLayer.Tracer.TraceDebug <MasterMailboxType, MailboxAssociationType>((long)this.GetHashCode(), "GroupMailboxAccessLayer::UpdateSlaveDataFromMailboxAssociation. Replicating data from mailbox: {0}. Association data: {1}", masterMailboxData, associationType);
            if (masterMailboxData.MailboxType != UserMailboxLocator.MailboxLocatorType && masterMailboxData.MailboxType != GroupMailboxLocator.MailboxLocatorType)
            {
                throw new InvalidOperationException("UpdateSlaveDataFromMailboxAssociation: Invalid MasterMailboxType");
            }
            MailboxAssociation mailboxAssociation = EwsAssociationDataConverter.Convert(associationType, this.adSession);
            IMailboxLocator    mailboxLocator;

            if (!(masterMailboxData.MailboxType == GroupMailboxLocator.MailboxLocatorType))
            {
                IMailboxLocator group = mailboxAssociation.Group;
                mailboxLocator = group;
            }
            else
            {
                mailboxLocator = mailboxAssociation.User;
            }
            IMailboxLocator targetMailbox = mailboxLocator;

            using (IAssociationStore associationStore = this.storeProviderBuilder.Create(targetMailbox, this.PerformanceTracker))
            {
                this.LogCommandExecution("UpdateSlaveDataFromMailboxAssociation", mailboxAssociation.Group, new UserMailboxLocator[]
                {
                    mailboxAssociation.User
                });
                BaseAssociationAdaptor baseAssociationAdaptor = (masterMailboxData.MailboxType == GroupMailboxLocator.MailboxLocatorType) ? new GroupAssociationAdaptor(associationStore, this.adSession, mailboxAssociation.User) : new UserAssociationAdaptor(associationStore, this.adSession, mailboxAssociation.Group);
                baseAssociationAdaptor.UseAlternateLocatorLookup = true;
                baseAssociationAdaptor.MasterMailboxData         = masterMailboxData;
                baseAssociationAdaptor.ReplicateAssociation(mailboxAssociation);
                if (masterMailboxData.MailboxType == GroupMailboxLocator.MailboxLocatorType && mailboxAssociation.IsMember)
                {
                    TimeSpan latency = ExDateTime.UtcNow - mailboxAssociation.JoinDate;
                    this.LogPerformanceCounter(MailboxAssociationLogSchema.PerformanceCounterName.JoinGroupAssociationReplication, latency, "Group={0}, User={1}", new object[]
                    {
                        mailboxAssociation.Group.ExternalId,
                        mailboxAssociation.User.ExternalId
                    });
                }
            }
        }