Exemple #1
0
        protected override MailboxAssociation CreateMailboxAssociationFromItem(IPropertyBag item, bool setExtendedProperties = false)
        {
            UserMailboxLocator          user           = new UserMailboxLocator(base.AdSession, base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationBaseSchema.ExternalId, string.Empty), base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationBaseSchema.LegacyDN, string.Empty));
            string                      valueOrDefault = base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationBaseSchema.SmtpAddress, null);
            MailboxAssociationFromStore mailboxAssociationFromStore = new MailboxAssociationFromStore
            {
                User               = user,
                Group              = (base.MasterLocator as GroupMailboxLocator),
                ItemId             = base.AssociationStore.GetValueOrDefault <VersionedId>(item, ItemSchema.Id, null),
                UserSmtpAddress    = (string.IsNullOrEmpty(valueOrDefault) ? SmtpAddress.Empty : new SmtpAddress(valueOrDefault)),
                IsMember           = base.AssociationStore.GetValueOrDefault <bool>(item, MailboxAssociationBaseSchema.IsMember, false),
                ShouldEscalate     = base.AssociationStore.GetValueOrDefault <bool>(item, MailboxAssociationBaseSchema.ShouldEscalate, false),
                IsAutoSubscribed   = base.AssociationStore.GetValueOrDefault <bool>(item, MailboxAssociationBaseSchema.IsAutoSubscribed, false),
                IsPin              = base.AssociationStore.GetValueOrDefault <bool>(item, MailboxAssociationBaseSchema.IsPin, false),
                JoinDate           = base.AssociationStore.GetValueOrDefault <ExDateTime>(item, MailboxAssociationBaseSchema.JoinDate, default(ExDateTime)),
                LastVisitedDate    = base.AssociationStore.GetValueOrDefault <ExDateTime>(item, MailboxAssociationUserSchema.LastVisitedDate, default(ExDateTime)),
                LastModified       = base.AssociationStore.GetValueOrDefault <ExDateTime>(item, StoreObjectSchema.LastModifiedTime, default(ExDateTime)),
                SyncedVersion      = base.AssociationStore.GetValueOrDefault <int>(item, MailboxAssociationBaseSchema.SyncedVersion, 0),
                CurrentVersion     = base.AssociationStore.GetValueOrDefault <int>(item, MailboxAssociationBaseSchema.CurrentVersion, 0),
                SyncedIdentityHash = base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationBaseSchema.SyncedIdentityHash, null)
            };

            if (setExtendedProperties)
            {
                mailboxAssociationFromStore.JoinedBy            = base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationUserSchema.JoinedBy, string.Empty);
                mailboxAssociationFromStore.SyncAttempts        = base.AssociationStore.GetValueOrDefault <int>(item, MailboxAssociationBaseSchema.SyncAttempts, 0);
                mailboxAssociationFromStore.SyncedSchemaVersion = base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationBaseSchema.SyncedSchemaVersion, string.Empty);
                mailboxAssociationFromStore.LastSyncError       = base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationBaseSchema.LastSyncError, string.Empty);
            }
            this.Tracer.TraceDebug <bool, MailboxAssociationFromStore>((long)this.GetHashCode(), "UserAssociationAdaptor.CreateMailboxAssociationFromItem: Creating association from information found in store item. SetExtendedProperties={0}, Association={1}", setExtendedProperties, mailboxAssociationFromStore);
            return(mailboxAssociationFromStore);
        }
        public static UserMailboxLocator Instantiate(IRecipientSession adSession, ProxyAddress proxyAddress)
        {
            UserMailboxLocator userMailboxLocator = new UserMailboxLocator(adSession);

            userMailboxLocator.InitializeFromAd(proxyAddress);
            return(userMailboxLocator);
        }
        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);
        }
        public static UserMailboxLocator Instantiate(IRecipientSession adSession, ADUser adUser)
        {
            UserMailboxLocator userMailboxLocator = new UserMailboxLocator(adSession);

            userMailboxLocator.InitializeFromAd(adUser);
            return(userMailboxLocator);
        }
        public static List <UserMailboxLocator> Instantiate(IRecipientSession adSession, params ProxyAddress[] proxyAddresses)
        {
            ArgumentValidator.ThrowIfNull("adSession", adSession);
            ArgumentValidator.ThrowIfNull("proxyAddresses", proxyAddresses);
            ArgumentValidator.ThrowIfZeroOrNegative("proxyAddresses.Length", proxyAddresses.Length);
            Result <ADUser>[]         array = adSession.FindByProxyAddresses <ADUser>(proxyAddresses);
            List <UserMailboxLocator> list  = new List <UserMailboxLocator>(proxyAddresses.Length);

            if (array == null)
            {
                MailboxLocator.Tracer.TraceDebug(0L, "UserMailboxLocator::Instantiate. FindByProxyAddresses returned no results");
                return(null);
            }
            for (int i = 0; i < proxyAddresses.Length; i++)
            {
                Result <ADUser> result = array[i];
                if (result.Data == null)
                {
                    MailboxLocator.Tracer.TraceError <string, ProviderError>(0L, "UserMailboxLocator::Instantiate. FindByProxyAddresses returned error for address {0}. Error: {1}", proxyAddresses[i].ProxyAddressString, result.Error);
                    throw new MailboxNotFoundException(ServerStrings.InvalidAddressError(proxyAddresses[i].ProxyAddressString));
                }
                UserMailboxLocator userMailboxLocator = new UserMailboxLocator(adSession);
                userMailboxLocator.InitializeFromAd(result.Data);
                list.Add(userMailboxLocator);
                MailboxLocator.Tracer.TraceDebug <string, UserMailboxLocator>(0L, "UserMailboxLocator::Instantiate. FindByProxyAddresses found user. Address: {0}. Locator: {1}", proxyAddresses[i].ProxyAddressString, userMailboxLocator);
            }
            return(list);
        }
Exemple #6
0
 internal static UserLocatorType Convert(UserMailboxLocator locator)
 {
     ArgumentValidator.ThrowIfNull("locator", locator);
     return(new UserLocatorType
     {
         ExternalDirectoryObjectId = locator.ExternalId,
         LegacyDn = locator.LegacyDn
     });
 }
 public void SetGroupPinState(UserMailboxLocator user, GroupMailboxLocator group, bool isPinned, bool isModernGroupsNewArchitecture)
 {
     using (IAssociationStore associationStore = this.storeProviderBuilder.Create(user, this.PerformanceTracker))
     {
         this.LogCommandExecution(isPinned ? "PinGroup" : "UnpinGroup", group, new UserMailboxLocator[]
         {
             user
         });
         GroupAssociationAdaptor masterAdaptor    = new GroupAssociationAdaptor(associationStore, this.adSession, user);
         SetGroupPinState        setGroupPinState = new SetGroupPinState(this.Logger, null, isPinned, masterAdaptor, group, this.PerformanceTracker, isModernGroupsNewArchitecture);
         setGroupPinState.Execute();
     }
 }
 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 <GroupMailbox> GetPinnedGroups(UserMailboxLocator user, bool loadAllDetails = false)
 {
     using (IAssociationStore storeProvider = this.storeProviderBuilder.Create(user, this.PerformanceTracker))
     {
         GroupAssociationAdaptor          adaptor         = new GroupAssociationAdaptor(storeProvider, this.adSession, user);
         GetPinAssociations               command         = new GetPinAssociations(adaptor);
         IEnumerable <MailboxAssociation> pinAssociations = command.Execute(null);
         IEnumerable <GroupMailbox>       mailboxes       = this.mailboxCollectionBuilder.BuildGroupMailboxes(pinAssociations, loadAllDetails);
         foreach (GroupMailbox mailbox in mailboxes)
         {
             yield return(mailbox);
         }
     }
     yield break;
 }
        public static List <UserMailboxLocator> Instantiate(IRecipientSession adSession, params ADUser[] users)
        {
            ArgumentValidator.ThrowIfNull("adSession", adSession);
            ArgumentValidator.ThrowIfNull("users", users);
            ArgumentValidator.ThrowIfZeroOrNegative("users.Length", users.Length);
            List <UserMailboxLocator> list = new List <UserMailboxLocator>(users.Length);

            foreach (ADUser adUser in users)
            {
                UserMailboxLocator userMailboxLocator = new UserMailboxLocator(adSession);
                userMailboxLocator.InitializeFromAd(adUser);
                list.Add(userMailboxLocator);
            }
            return(list);
        }
        protected override MailboxAssociation CreateMailboxAssociationFromItem(IPropertyBag item, bool setExtendedProperties = false)
        {
            UserMailboxLocator          user = new UserMailboxLocator(base.AdSession, base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationBaseSchema.ExternalId, string.Empty), base.AssociationStore.GetValueOrDefault <string>(item, MailboxAssociationBaseSchema.LegacyDN, string.Empty));
            MailboxAssociationFromStore mailboxAssociationFromStore = new MailboxAssociationFromStore
            {
                User            = user,
                Group           = (base.MasterLocator as GroupMailboxLocator),
                IsMember        = base.AssociationStore.GetValueOrDefault <bool>(item, MailboxAssociationBaseSchema.IsMember, false),
                JoinDate        = base.AssociationStore.GetValueOrDefault <ExDateTime>(item, MailboxAssociationBaseSchema.JoinDate, default(ExDateTime)),
                LastVisitedDate = base.AssociationStore.GetValueOrDefault <ExDateTime>(item, MailboxAssociationUserSchema.LastVisitedDate, default(ExDateTime))
            };

            this.Tracer.TraceDebug <bool, MailboxAssociationFromStore>((long)this.GetHashCode(), "UnseenDataUserAssociationAdaptor .CreateMailboxAssociationFromItem: Creating association from information found in store item. SetExtendedProperties={0}, Association={1}", setExtendedProperties, mailboxAssociationFromStore);
            return(mailboxAssociationFromStore);
        }
        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);
        }
Exemple #14
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()));
        }
        private MailboxAssociation CreateMailboxAssociationWithDefaultValues(UserMailboxLocator user, GroupMailboxLocator group)
        {
            MailboxAssociation mailboxAssociation = new MailboxAssociation
            {
                User            = user,
                Group           = group,
                UserSmtpAddress = SmtpAddress.Empty,
                IsMember        = false,
                ShouldEscalate  = false,
                IsPin           = false,
                JoinedBy        = string.Empty,
                JoinDate        = default(ExDateTime),
                LastVisitedDate = default(ExDateTime)
            };

            GroupMailboxAccessLayer.Tracer.TraceDebug <MailboxAssociation>((long)this.GetHashCode(), "GroupMailboxAccessLayer.CreateMailboxAssociationWithDefaultValues: Creating new association with default values. Association={0}", mailboxAssociation);
            return(mailboxAssociation);
        }
Exemple #16
0
 public GroupAssociationAdaptor(IAssociationStore associationStore, IRecipientSession adSession, UserMailboxLocator currentUser) : base(associationStore, adSession, currentUser)
 {
 }
 public UserMailboxBuilder(UserMailboxLocator locator, IEnumerable <ADObjectId> owners = null)
 {
     ArgumentValidator.ThrowIfNull("locator", locator);
     this.Mailbox = new UserMailbox(locator);
     this.owners  = ((owners != null) ? new HashSet <ADObjectId>(owners) : new HashSet <ADObjectId>());
 }
Exemple #18
0
 public SetEscalate(IExtensibleLogger logger, bool shouldEscalate, SmtpAddress userSmtpAddress, IUserAssociationAdaptor masterAdaptor, UserMailboxLocator itemLocator, int maxEscalatedMembers = 400) : base(logger, masterAdaptor, new IMailboxLocator[]
 {
     itemLocator
 })
 {
     this.shouldEscalate      = shouldEscalate;
     this.userSmtpAddress     = userSmtpAddress;
     this.maxEscalatedMembers = maxEscalatedMembers;
 }
 public SetLastVisitedDate(IExtensibleLogger logger, ExDateTime lastVisitedDate, IUserAssociationAdaptor masterAdaptor, UserMailboxLocator itemLocator) : base(logger, masterAdaptor, new IMailboxLocator[]
 {
     itemLocator
 })
 {
     this.lastVisitedDate = lastVisitedDate;
 }
 public void ReplicateOutOfSyncAssociation(UserMailboxLocator masterLocator)
 {
     this.ReplicateOutOfSyncAssociation((IAssociationStore storeProvider) => new GroupAssociationAdaptor(storeProvider, this.adSession, masterLocator), masterLocator);
 }
Exemple #21
0
 public UserMailbox(UserMailboxLocator locator)
 {
     this.Locator = locator;
 }