private ExchangePrincipal InternalFromADUser(IGenericADUser user, RemotingOptions remotingOptions)
        {
            ADObjectId mdb;
            bool       asArchive = this.UpdateArchiveStatus(user.MailboxGuid, user, out mdb);

            return(this.InternalFromADUser(user, mdb, null, remotingOptions, asArchive, false, null));
        }
        public ExchangePrincipal(IGenericADUser adUser, IEnumerable <IMailboxInfo> allMailboxes, Func <IMailboxInfo, bool> mailboxSelector, RemotingOptions remotingOptions)
        {
            ArgumentValidator.ThrowIfNull("adUser", adUser);
            ArgumentValidator.ThrowIfNull("mailboxes", allMailboxes);
            ArgumentValidator.ThrowIfNull("mailboxSelector", mailboxSelector);
            EnumValidator <RemotingOptions> .ThrowIfInvalid(remotingOptions);

            this.MailboxInfo = allMailboxes.FirstOrDefault(mailboxSelector);
            if (this.MailboxInfo == null && (remotingOptions & RemotingOptions.AllowHybridAccess) != RemotingOptions.AllowHybridAccess)
            {
                throw new UserHasNoMailboxException();
            }
            this.AllMailboxes = allMailboxes;
            this.ObjectId     = adUser.ObjectId;
            this.LegacyDn     = adUser.LegacyDn;
            this.Alias        = (adUser.Alias ?? string.Empty);
            this.DefaultPublicFolderMailbox = adUser.DefaultPublicFolderMailbox;
            this.Sid = adUser.Sid;
            this.MasterAccountSid = adUser.MasterAccountSid;
            this.SidHistory       = adUser.SidHistory;
            this.Delegates        = from delegateUser in adUser.GrantSendOnBehalfTo
                                    where delegateUser != null
                                    select delegateUser;

            this.PreferredCultures         = ((adUser.Languages == null) ? Enumerable.Empty <CultureInfo>() : new PreferredCultures(adUser.Languages));
            this.RecipientType             = adUser.RecipientType;
            this.RecipientTypeDetails      = adUser.RecipientTypeDetails;
            this.IsResource                = adUser.IsResource;
            this.ModernGroupType           = adUser.ModernGroupType;
            this.PublicToGroupSids         = adUser.PublicToGroupSids;
            this.ExternalDirectoryObjectId = adUser.ExternalDirectoryObjectId;
            this.AggregatedMailboxGuids    = (adUser.AggregatedMailboxGuids ?? ((IEnumerable <Guid>)Array <Guid> .Empty));
            this.remotingOptions           = remotingOptions;
        }
Example #3
0
        public static MailboxLocationType?GetMailboxLocationType(this IGenericADUser user, Guid mailboxGuid)
        {
            MailboxLocationType?result = null;

            if (user.IsArchiveMailbox(mailboxGuid))
            {
                result = new MailboxLocationType?(MailboxLocationType.MainArchive);
            }
            else if (user.IsAggregatedMailbox(mailboxGuid))
            {
                result = new MailboxLocationType?(MailboxLocationType.Aggregated);
            }
            else if (user.MailboxGuid == mailboxGuid)
            {
                result = new MailboxLocationType?(MailboxLocationType.Primary);
            }
            else if (user.MailboxLocations != null)
            {
                foreach (IMailboxLocationInfo mailboxLocationInfo in user.MailboxLocations)
                {
                    if (mailboxLocationInfo.MailboxGuid == mailboxGuid)
                    {
                        result = new MailboxLocationType?(mailboxLocationInfo.MailboxLocationType);
                        break;
                    }
                }
            }
            return(result);
        }
Example #4
0
 public MailboxConfiguration(IGenericADUser adUser)
 {
     ArgumentValidator.ThrowIfNull("adUser", adUser);
     this.SharePointUrl                     = adUser.SharePointUrl;
     this.IsMapiEnabled                     = adUser.IsMapiEnabled;
     this.IsOwaEnabled                      = adUser.IsOwaEnabled;
     this.IsMowaEnabled                     = adUser.IsMowaEnabled;
     this.ThrottlingPolicy                  = adUser.ThrottlingPolicy;
     this.OwaMailboxPolicy                  = adUser.OwaMailboxPolicy;
     this.MobileDeviceMailboxPolicy         = adUser.MobileDeviceMailboxPolicy;
     this.AddressBookPolicy                 = adUser.AddressBookPolicy;
     this.IsPersonToPersonMessagingEnabled  = adUser.IsPersonToPersonMessagingEnabled;
     this.IsMachineToPersonMessagingEnabled = adUser.IsMachineToPersonMessagingEnabled;
     this.SkuCapability                     = adUser.SkuCapability;
     this.SkuAssigned                  = adUser.SkuAssigned;
     this.IsMailboxAuditEnabled        = adUser.IsMailboxAuditEnabled;
     this.BypassAudit                  = adUser.BypassAudit;
     this.MailboxAuditLogAgeLimit      = adUser.MailboxAuditLogAgeLimit;
     this.AuditAdminOperations         = adUser.AuditAdminOperations;
     this.AuditDelegateOperations      = adUser.AuditDelegateOperations;
     this.AuditDelegateAdminOperations = adUser.AuditDelegateAdminOperations;
     this.AuditOwnerOperations         = adUser.AuditOwnerOperations;
     this.AuditLastAdminAccess         = adUser.AuditLastAdminAccess;
     this.AuditLastDelegateAccess      = adUser.AuditLastDelegateAccess;
     this.AuditLastExternalAccess      = adUser.AuditLastExternalAccess;
 }
        public ExchangePrincipal FromLegacyDNByMiniRecipient(IRecipientSession recipientSession, string legacyDN, RemotingOptions remotingOptions, PropertyDefinition[] miniRecipientProperties, out StorageMiniRecipient miniRecipient)
        {
            Util.ThrowOnNullArgument(recipientSession, "recipientSession");
            Util.ThrowOnNullArgument(legacyDN, "legacyDN");
            EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions");
            if (legacyDN.Length == 0)
            {
                throw new ArgumentException("legacyDN has zero length", "legacyDN");
            }
            Guid mbxGuid;

            legacyDN = this.TryToExtractArchiveOrAggregatedMailboxGuid(legacyDN, out mbxGuid);
            IGenericADUser genericADUser = this.directoryAccessor.FindMiniRecipientByProxyAddress(recipientSession, ProxyAddressPrefix.LegacyDN.GetProxyAddress(legacyDN, true), miniRecipientProperties, out miniRecipient);

            if (genericADUser == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            ADObjectId mdb;
            bool       asArchive             = this.UpdateArchiveStatus(mbxGuid, genericADUser, out mdb);
            Guid?      aggregatedMailboxGuid = null;

            if (genericADUser.AggregatedMailboxGuids != null)
            {
                aggregatedMailboxGuid = (genericADUser.AggregatedMailboxGuids.Any((Guid mailbox) => mailbox == mbxGuid) ? new Guid?(mbxGuid) : null);
            }
            IMailboxLocation  mailboxLocation   = new OnDemandMailboxLocation(() => new MailboxDatabaseLocation(this.databaseLocationProvider.GetLocationInfo(mdb.ObjectGuid, false, (remotingOptions & RemotingOptions.AllowCrossSite) == RemotingOptions.AllowCrossSite)));
            ExchangePrincipal exchangePrincipal = this.InternalFromMiniRecipient(genericADUser, mdb, mailboxLocation, remotingOptions, asArchive, aggregatedMailboxGuid);

            if (mbxGuid != Guid.Empty && !exchangePrincipal.MailboxInfo.IsAggregated && !exchangePrincipal.MailboxInfo.IsArchive)
            {
                throw new ObjectNotFoundException(ServerStrings.AggregatedMailboxNotFound(mbxGuid.ToString()));
            }
            return(exchangePrincipal);
        }
 public ExchangePrincipal FromADUser(ADSessionSettings adSettings, IGenericADUser user, RemotingOptions remotingOptions, string domainController = null)
 {
     Util.ThrowOnNullArgument(adSettings, "adSettings");
     EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions");
     Util.ThrowOnNullArgument(user, "user");
     return(this.InternalFromADUser(user, remotingOptions));
 }
        public ExchangePrincipal FromLocalServerMailboxGuid(IRecipientSession recipientSession, Guid mdbGuid, Guid mailboxGuid, DatabaseLocationInfo databaseLocationInfo, bool isContentIndexing)
        {
            Util.ThrowOnNullArgument(recipientSession, "recipientSession");
            Util.ThrowOnNullArgument(databaseLocationInfo, "databaseLocationInfo");
            if (mdbGuid == Guid.Empty)
            {
                throw new ArgumentException("Should not be Empty", "mdbGuid");
            }
            if (mailboxGuid == Guid.Empty)
            {
                throw new ArgumentException("Guid-less mailboxes are not supported by this factory method", "mailboxGuid");
            }
            IGenericADUser genericADUser = this.directoryAccessor.FindByExchangeGuid(recipientSession, mailboxGuid, true);

            if (genericADUser == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            if (genericADUser.RecipientType == RecipientType.SystemMailbox)
            {
                return(this.FromADSystemMailbox(recipientSession, genericADUser, databaseLocationInfo.ServerFqdn, databaseLocationInfo.ServerLegacyDN));
            }
            ADObjectId mdb;
            bool       asArchive = this.UpdateArchiveStatus(genericADUser.RecipientType, mailboxGuid, genericADUser.ArchiveGuid, new ADObjectId(mdbGuid), genericADUser.ArchiveDatabase, out mdb);

            return(this.InternalFromADUser(genericADUser, mdb, databaseLocationInfo, RemotingOptions.LocalConnectionsOnly, asArchive, isContentIndexing, new Guid?(mailboxGuid)));
        }
Example #8
0
        private void UpdateDelegationTokenRequest(TokenTarget tokenTarget, Uri autodiscoveryEndpoint, IGenericADUser user)
        {
            IGenericADUser organizationFederatedMailbox = this.GetOrganizationFederatedMailbox();

            this.xropUserFederatedIdentity = user.GetFederatedIdentity();
            this.xropUserEmailAddress      = user.GetFederatedSmtpAddress().ToString();
            if (organizationFederatedMailbox != null)
            {
                this.xropTokenRequest = new DelegationTokenRequest
                {
                    FederatedIdentity = organizationFederatedMailbox.GetFederatedIdentity(),
                    EmailAddress      = organizationFederatedMailbox.GetFederatedSmtpAddress().ToString(),
                    Target            = tokenTarget,
                    Offer             = Offer.XropLogon
                };
                this.autoDiscoveryTokenRequest = new DelegationTokenRequest
                {
                    FederatedIdentity = organizationFederatedMailbox.GetFederatedIdentity(),
                    EmailAddress      = organizationFederatedMailbox.GetFederatedSmtpAddress().ToString(),
                    Target            = tokenTarget,
                    Offer             = Offer.Autodiscover
                };
            }
            this.autoDiscoveryEndpoint = autodiscoveryEndpoint;
        }
Example #9
0
        private void UpdateCrossPremiseStatusRemoteMailbox(IGenericADUser user)
        {
            if (user.ExternalEmailAddress.Prefix != ProxyAddressPrefix.Smtp || !SmtpAddress.IsValidSmtpAddress(user.ExternalEmailAddress.AddressString))
            {
                StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_XtcInvalidSmtpAddress, user.LegacyDn, new object[]
                {
                    user.LegacyDn
                });
                ExTraceGlobals.XtcTracer.TraceError <string>(0L, "User's external email address is not a valid SMTP address - remote mailbox/archive access will be disabled. User: {0}.", user.LegacyDn);
                return;
            }
            SmtpAddress smtpAddress = new SmtpAddress(user.ExternalEmailAddress.AddressString);
            TokenTarget tokenTarget;
            Uri         autodiscoveryEndpoint;

            if (!this.TryGetAutodiscoveryEndpoint(user, smtpAddress.Domain, out tokenTarget, out autodiscoveryEndpoint))
            {
                return;
            }
            this.UpdateDelegationTokenRequest(tokenTarget, autodiscoveryEndpoint, user);
            if (this.isCrossPremiseArchiveEnabled && user.ArchiveGuid == Guid.Empty)
            {
                StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_XtcArchiveGuidMissing, user.LegacyDn, new object[]
                {
                    user.LegacyDn
                });
                ExTraceGlobals.XtcTracer.TraceError <string>(0L, "User's archive GUID is not configured properly - remote archive access will be disabled. User: {0}.", user.LegacyDn);
            }
        }
        private ExchangePrincipal CreateExchangePrincipal(IGenericADUser user, ADObjectId mdb, IMailboxLocation mailboxLocation, RemotingOptions remotingOptions, bool asArchive, Guid?aggregatedMailboxGuid, IDatabaseLocationProvider databaseLocationProvider, bool isContentIndexing = false)
        {
            ExchangePrincipalBuilder exchangePrincipalBuilder = ((remotingOptions & RemotingOptions.AllowHybridAccess) == RemotingOptions.AllowHybridAccess) ? new RemoteUserMailboxPrincipalBuilder(user) : this.GetExchangePrincipalBuilder(user);

            exchangePrincipalBuilder.SetRemotingOptions(remotingOptions);
            exchangePrincipalBuilder.SetDatabaseLocationProvider(databaseLocationProvider);
            if (!mdb.IsNullOrEmpty())
            {
                exchangePrincipalBuilder.SetSelectedMailboxDatabase(mdb.ObjectGuid);
            }
            if (mailboxLocation != null)
            {
                exchangePrincipalBuilder.SetSelectedMailboxLocation(mailboxLocation);
            }
            if (asArchive)
            {
                exchangePrincipalBuilder.SelectArchiveMailbox();
            }
            exchangePrincipalBuilder.BypassRecipientTypeValidation(isContentIndexing);
            if (aggregatedMailboxGuid != null && aggregatedMailboxGuid != Guid.Empty)
            {
                exchangePrincipalBuilder.SelectMailbox(aggregatedMailboxGuid.Value);
            }
            return(exchangePrincipalBuilder.Build());
        }
Example #11
0
 private void UpdateCrossPremiseStatus(IGenericADUser user)
 {
     if (this.isRemotingStatusInitialized)
     {
         return;
     }
     this.autoDiscoveryEndpoint     = null;
     this.autoDiscoveryTokenRequest = null;
     this.xropUserFederatedIdentity = null;
     this.xropUserEmailAddress      = null;
     this.xropTokenRequest          = null;
     if (user == null || !VariantConfiguration.InvariantNoFlightingSnapshot.DataStorage.RepresentRemoteMailbox.Enabled)
     {
         this.isRemotingStatusInitialized = true;
         return;
     }
     if (user.RecipientType == RecipientType.MailUser && user.MailboxDatabase.IsNullOrEmpty() && (user.RecipientTypeDetails & (RecipientTypeDetails)((ulong)-2147483648)) == (RecipientTypeDetails)((ulong)-2147483648) && user.ExternalEmailAddress != null)
     {
         this.isMailboxCrossPremise = true;
         this.isArchiveCrossPremise = true;
     }
     if (!this.isMailboxCrossPremise && user.ArchiveDomain != null)
     {
         this.isArchiveCrossPremise = true;
     }
     if (!this.isMailboxCrossPremise && !this.isArchiveCrossPremise)
     {
         this.isRemotingStatusInitialized = true;
         return;
     }
     if (!this.IsExternalAuthenticationEnabled())
     {
         StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ExternalAuthDisabledExchangePrincipal, user.LegacyDn, new object[]
         {
             user.LegacyDn
         });
         ExTraceGlobals.XtcTracer.TraceError <string>(0L, "External authentification is disabled, remote mailbox/archive access for user {0} will be disabled.", user.LegacyDn);
         this.isRemotingStatusInitialized = true;
         return;
     }
     this.isCrossPremiseArchiveEnabled = ((user.ArchiveStatus & ArchiveStatusFlags.Active) == ArchiveStatusFlags.Active);
     if (this.isMailboxCrossPremise)
     {
         this.UpdateCrossPremiseStatusRemoteMailbox(user);
     }
     else if (this.isCrossPremiseArchiveEnabled)
     {
         this.UpdateCrossPremiseStatusRemoteArchive(user);
     }
     else
     {
         StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ExternalArchiveDisabled, user.LegacyDn, new object[]
         {
             user.LegacyDn
         });
         ExTraceGlobals.XtcTracer.TraceError <string>(0L, "Remote archive access is disabled for user {0}.", user.LegacyDn);
     }
     this.isRemotingStatusInitialized = true;
 }
 public RemoteUserMailboxPrincipal(IGenericADUser adUser, IEnumerable <IMailboxInfo> allMailboxes, Func <IMailboxInfo, bool> mailboxSelector, RemotingOptions remotingOptions) : base(adUser, allMailboxes, mailboxSelector, remotingOptions)
 {
     this.UserPrincipalName  = adUser.UserPrincipalName;
     this.WindowsLiveId      = adUser.WindowsLiveID;
     this.NetId              = adUser.NetId;
     this.PrimarySmtpAddress = adUser.PrimarySmtpAddress;
     this.DisplayName        = adUser.DisplayName;
 }
 private ExchangePrincipal InternalFromADUser(IGenericADUser user, ADObjectId mdb, DatabaseLocationInfo databaseLocationInfo, RemotingOptions remotingOptions, bool asArchive, bool isContentIndexing = false, Guid?aggregatedMailboxGuid = null)
 {
     if (databaseLocationInfo == null && mdb != null)
     {
         databaseLocationInfo = this.databaseLocationProvider.GetLocationInfo(mdb.ObjectGuid, false, (remotingOptions & RemotingOptions.AllowCrossSite) == RemotingOptions.AllowCrossSite);
     }
     return(this.CreateExchangePrincipal(user, mdb, this.CreateMailboxLocation(databaseLocationInfo), remotingOptions, asArchive, aggregatedMailboxGuid, this.databaseLocationProvider, isContentIndexing));
 }
 private ExchangePrincipalBuilder GetExchangePrincipalBuilder(IGenericADUser recipient)
 {
     if (recipient is ADGroupGenericWrapper)
     {
         return(new GroupPrincipalBuilder(recipient));
     }
     return(new UserPrincipalBuilder(recipient));
 }
        public ExchangePrincipal FromMiniRecipient(IGenericADUser miniRecipient, RemotingOptions remotingOptions)
        {
            EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions");
            Util.ThrowOnNullArgument(miniRecipient, "miniRecipient");
            ADObjectId mdb;
            bool       asArchive = this.UpdateArchiveStatus(miniRecipient.MailboxGuid, miniRecipient, out mdb);

            return(this.InternalFromMiniRecipient(miniRecipient, mdb, null, remotingOptions, asArchive, null));
        }
        public ExchangePrincipal FromADUser(IGenericADUser user, DatabaseLocationInfo databaseLocationInfo, RemotingOptions remotingOptions)
        {
            EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions");
            Util.ThrowOnNullArgument(user, "user");
            ADObjectId mdb;
            bool       asArchive = this.UpdateArchiveStatus(user.MailboxGuid, user, out mdb);

            return(this.InternalFromADUser(user, mdb, databaseLocationInfo, remotingOptions, asArchive, false, null));
        }
        private IGenericADUser TranslateMiniRecipient(StorageMiniRecipient recipient)
        {
            IGenericADUser result = null;

            if (recipient != null)
            {
                result = new MiniRecipientGenericWrapper(recipient);
            }
            return(result);
        }
        private static byte[] CalculateEffectiveId(IGenericADUser adUser)
        {
            byte[]             result             = null;
            SecurityIdentifier securityIdentifier = IdentityHelper.CalculateEffectiveSid(adUser.Sid, adUser.MasterAccountSid);

            if (securityIdentifier != null)
            {
                result = ValueConvertor.ConvertValueToBinary(securityIdentifier, null);
            }
            return(result);
        }
Example #19
0
        public static SmtpAddress GetFederatedSmtpAddress(this IGenericADUser genericAdUser, SmtpAddress preferredSmtpAddress)
        {
            OrganizationId           key = genericAdUser.OrganizationId ?? OrganizationId.ForestWideOrgId;
            OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(key);

            if (organizationIdCacheValue.FederatedDomains == null)
            {
                throw new UserWithoutFederatedProxyAddressException();
            }
            if (organizationIdCacheValue.DefaultFederatedDomain != null)
            {
                foreach (ProxyAddress proxyAddress in genericAdUser.EmailAddresses)
                {
                    if (proxyAddress.Prefix == ProxyAddressPrefix.Smtp)
                    {
                        SmtpAddress result = new SmtpAddress(proxyAddress.AddressString);
                        if (StringComparer.OrdinalIgnoreCase.Equals(result.Domain, organizationIdCacheValue.DefaultFederatedDomain))
                        {
                            return(result);
                        }
                    }
                }
            }
            List <string> source         = new List <string>(organizationIdCacheValue.FederatedDomains);
            bool          isValidAddress = preferredSmtpAddress.IsValidAddress;

            if (isValidAddress && !genericAdUser.EmailAddresses.Contains(new SmtpProxyAddress(preferredSmtpAddress.ToString(), false)))
            {
                throw new ArgumentException("preferredSmtpAddress");
            }
            if (isValidAddress)
            {
                if (source.Contains(preferredSmtpAddress.Domain, StringComparer.OrdinalIgnoreCase))
                {
                    return(preferredSmtpAddress);
                }
                if (genericAdUser.PrimarySmtpAddress.IsValidAddress && !StringComparer.OrdinalIgnoreCase.Equals(genericAdUser.PrimarySmtpAddress.Domain, preferredSmtpAddress.Domain) && source.Contains(genericAdUser.PrimarySmtpAddress.Domain, StringComparer.OrdinalIgnoreCase))
                {
                    return(genericAdUser.PrimarySmtpAddress);
                }
            }
            foreach (ProxyAddress proxyAddress2 in genericAdUser.EmailAddresses)
            {
                if (proxyAddress2.Prefix == ProxyAddressPrefix.Smtp)
                {
                    SmtpAddress result2 = new SmtpAddress(proxyAddress2.AddressString);
                    if (source.Contains(result2.Domain, StringComparer.OrdinalIgnoreCase))
                    {
                        return(result2);
                    }
                }
            }
            throw new UserWithoutFederatedProxyAddressException();
        }
        public IGenericADUser FindByLegacyExchangeDn(IRecipientSession recipientSession, string legacyExchangeDn)
        {
            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            IGenericADUser adUser = null;

            this.DoAdCallAndTranslateExceptions(delegate
            {
                adUser = this.TranslateADRecipient(recipientSession.FindByLegacyExchangeDN(legacyExchangeDn), false);
            }, "DirectoryAccessor::FindByLegacyExchangeDn");
            return(adUser);
        }
        public IGenericADUser FindByObjectId(IRecipientSession recipientSession, ADObjectId directoryEntry)
        {
            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            IGenericADUser adUser = null;

            this.DoAdCallAndTranslateExceptions(delegate
            {
                adUser = this.TranslateADRecipient(recipientSession.Read(directoryEntry), false);
            }, "DirectoryAccessor::FindByObjectId");
            return(adUser);
        }
        public IGenericADUser FindByExchangeGuid(IRecipientSession recipientSession, Guid mailboxGuid, bool includeSystemMailbox)
        {
            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            IGenericADUser adUser = null;

            this.DoAdCallAndTranslateExceptions(delegate
            {
                adUser = this.TranslateADRecipient(recipientSession.FindByExchangeGuidIncludingAlternate(mailboxGuid), includeSystemMailbox);
            }, "DirectoryAccessor::FindByExchangeGuid");
            return(adUser);
        }
        public IGenericADUser FindBySid(IRecipientSession recipientSession, SecurityIdentifier sid)
        {
            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            IGenericADUser adUser = null;

            this.DoAdCallAndTranslateExceptions(delegate
            {
                adUser = this.TranslateADRecipient(recipientSession.FindBySid(sid), false);
            }, "DirectoryAccessor::FindBySid");
            return(adUser);
        }
        public IGenericADUser FindByProxyAddress(IRecipientSession recipientSession, ProxyAddress proxyAddress)
        {
            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            IGenericADUser adUser = null;

            this.DoAdCallAndTranslateExceptions(delegate
            {
                adUser = this.TranslateADRecipient(recipientSession.FindByProxyAddress(proxyAddress), false);
            }, "DirectoryAccessor::FindByProxyAddress");
            return(adUser);
        }
Example #25
0
        public static IConstraintProvider GetContext(this IGenericADUser adUser, ExchangeConfigurationUnit configurationUnit = null)
        {
            if (configurationUnit == null)
            {
                string rampId = string.IsNullOrEmpty(adUser.ExternalDirectoryObjectId) ? "Global" : adUser.ExternalDirectoryObjectId;
                return(new GenericADUserConstraintProvider(adUser, rampId, false));
            }
            string rampId2        = ExchangeConfigurationUnitVariantConfigurationParser.GetRampId(configurationUnit);
            bool   isFirstRelease = ExchangeConfigurationUnitVariantConfigurationParser.IsFirstRelease(configurationUnit);

            return(new GenericADUserConstraintProvider(adUser, rampId2, isFirstRelease));
        }
Example #26
0
 private static string GetOrganization(IGenericADUser adUser)
 {
     if (adUser == null)
     {
         throw new ArgumentNullException("adUser");
     }
     if (adUser.OrganizationId != null && adUser.OrganizationId.OrganizationalUnit != null && adUser.OrganizationId.OrganizationalUnit.Name != null)
     {
         return(adUser.OrganizationId.OrganizationalUnit.Name);
     }
     return(string.Empty);
 }
Example #27
0
 private static VariantConfigurationUserType GetUserType(IGenericADUser adUser)
 {
     if (adUser == null || adUser.OrganizationId == null)
     {
         return(VariantConfigurationUserType.None);
     }
     if (!Globals.IsConsumerOrganization(adUser.OrganizationId))
     {
         return(VariantConfigurationUserType.Business);
     }
     return(VariantConfigurationUserType.Consumer);
 }
        public ExchangePrincipal FromDirectoryObjectId(IRecipientSession session, ADObjectId directoryEntry, RemotingOptions remoteOptions = RemotingOptions.LocalConnectionsOnly)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(directoryEntry, "directoryEntry");
            IGenericADUser genericADUser = this.directoryAccessor.FindByObjectId(session, directoryEntry);

            if (genericADUser == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            return(this.InternalFromADUser(genericADUser, remoteOptions));
        }
Example #29
0
        protected virtual bool TryGetAutodiscoveryEndpoint(IGenericADUser user, string domain, out TokenTarget tokenTarget, out Uri autodiscoveryEndpoint)
        {
            tokenTarget           = null;
            autodiscoveryEndpoint = null;
            OrganizationRelationship organizationRelationship = this.directoryAccessor.GetOrganizationRelationship(user.OrganizationId ?? OrganizationId.ForestWideOrgId, domain);

            if (this.CheckOrgRelationshipFromRemoteConnection(organizationRelationship, user, domain))
            {
                tokenTarget           = organizationRelationship.GetTokenTarget();
                autodiscoveryEndpoint = organizationRelationship.TargetAutodiscoverEpr;
                return(true);
            }
            return(false);
        }
        public ExchangePrincipal FromUserSid(IRecipientSession recipientSession, SecurityIdentifier userSid, RemotingOptions remotingOptions)
        {
            Util.ThrowOnNullArgument(recipientSession, "recipientSession");
            Util.ThrowOnNullArgument(userSid, "userSid");
            EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions");
            this.CheckNoCrossPremiseAccess(remotingOptions);
            IGenericADUser genericADUser = this.directoryAccessor.FindBySid(recipientSession, userSid);

            if (genericADUser == null)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
            }
            return(this.InternalFromADUser(genericADUser, remotingOptions));
        }