Exemple #1
0
        public static ADUser ReadUser(IRecipientSession session, ulong puid, bool mservOnly)
        {
            ADUser result;

            try
            {
                ((IAggregateSession)session).MbxReadMode      = (mservOnly ? MbxReadMode.NoMbxRead : MbxReadMode.OnlyIfLocatorDataAvailable);
                ((IAggregateSession)session).BackendWriteMode = BackendWriteMode.NoWrites;
                result = session.FindADUserByExternalDirectoryObjectId(ConsumerIdentityHelper.GetExchangeGuidFromPuid(puid).ToString());
            }
            catch (ADDriverStoreAccessPermanentException ex)
            {
                if (!(ex.InnerException is MapiExceptionMdbOffline) && !(ex.InnerException is MapiExceptionUserInformationNotFound))
                {
                    throw;
                }
                ((IAggregateSession)session).MbxReadMode      = MbxReadMode.NoMbxRead;
                ((IAggregateSession)session).BackendWriteMode = BackendWriteMode.NoWrites;
                result = session.FindADUserByExternalDirectoryObjectId(ConsumerIdentityHelper.GetExchangeGuidFromPuid(puid).ToString());
            }
            return(result);
        }
Exemple #2
0
        private static ADRawEntry FindAdUserByExternalDirectoryObjectId(Guid userGuid, IRecipientSession recipientSession, IRoutingDiagnostics diagnostics)
        {
            DateTime   utcNow = DateTime.UtcNow;
            ADRawEntry result;

            try
            {
                result = recipientSession.FindADUserByExternalDirectoryObjectId(userGuid.ToString());
            }
            finally
            {
                diagnostics.AddAccountForestLatency(DateTime.UtcNow - utcNow);
            }
            return(result);
        }
Exemple #3
0
        private static ADUser GetAdUser(IRecipientSession recipientSession, string scope, bool throwIfNotFound)
        {
            LegacyDN legacyDN;
            ADUser   aduser;

            if (LegacyDN.TryParse(scope, out legacyDN))
            {
                aduser = (recipientSession.FindByLegacyExchangeDN(scope) as ADUser);
            }
            else
            {
                aduser = recipientSession.FindADUserByExternalDirectoryObjectId(scope);
            }
            if (aduser == null && throwIfNotFound)
            {
                throw new ComplianceTaskPermanentException("Recipient not found: " + scope, UnifiedPolicyErrorCode.FailedToOpenContainer);
            }
            return(aduser);
        }
Exemple #4
0
        private ADObjectId FindUserObjectId()
        {
            ADRecipient       adrecipient      = null;
            IRecipientSession recipientSession = AccessingUserInfo.GetRecipientSession(this.organizationId);

            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            if (this.LegacyExchangeDN != null)
            {
                adrecipient = recipientSession.FindByLegacyExchangeDN(this.LegacyExchangeDN);
            }
            else if (this.ExternalDirectoryObjectId != null)
            {
                adrecipient = recipientSession.FindADUserByExternalDirectoryObjectId(this.ExternalDirectoryObjectId);
            }
            if (adrecipient == null)
            {
                return(null);
            }
            return(adrecipient.Id);
        }
Exemple #5
0
        private ADUser GetOwnerFromAAD(ADUser groupMailbox, IRecipientSession recipientSession)
        {
            Group     group     = null;
            AADClient aadclient = AADClientFactory.Create(base.OrganizationId, GraphProxyVersions.Version14);

            if (aadclient == null)
            {
                base.WriteError(new TaskException(Strings.ErrorUnableToSessionWithAAD), ExchangeErrorCategory.Client, null);
            }
            try
            {
                group = aadclient.GetGroup(groupMailbox.ExternalDirectoryObjectId, true);
                aadclient.Service.LoadProperty(group, "owners");
            }
            catch (AADException ex)
            {
                base.WriteVerbose("Failed to get group owner from AAD with exception: {0}", new object[]
                {
                    ex
                });
                base.WriteError(new TaskException(Strings.ErrorUnableToGetGroupOwners), base.GetErrorCategory(ex), null);
            }
            if (group.owners != null)
            {
                foreach (DirectoryObject directoryObject in group.owners)
                {
                    ADUser aduser = recipientSession.FindADUserByExternalDirectoryObjectId(directoryObject.objectId);
                    if (aduser != null)
                    {
                        return(aduser);
                    }
                }
            }
            base.WriteError(new TaskException(Strings.ErrorUnableToGetGroupOwners), ExchangeErrorCategory.Client, null);
            return(null);
        }
        protected override ADRawEntry LoadADRawEntry()
        {
            IRecipientSession recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.organizationId), 62, "LoadADRawEntry", "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\AnchorMailbox\\ExternalDirectoryObjectIdAnchorMailbox.cs");
            ADRawEntry        ret = DirectoryHelper.InvokeAccountForest(base.RequestContext.LatencyTracker, () => recipientSession.FindADUserByExternalDirectoryObjectId(this.externalDirectoryObjectId));

            return(base.CheckForNullAndThrowIfApplicable <ADRawEntry>(ret));
        }