// Token: 0x06000011 RID: 17 RVA: 0x000024D8 File Offset: 0x000006D8
 private static MailboxConnectivity CheckMailboxConnectivity(MailboxConnectivity mailboxConnectivity)
 {
     try
     {
         mailboxConnectivity.Message = "Getting ADSessionSettings";
         ADSessionSettings adsessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(mailboxConnectivity.TenantAcceptedDomain);
         if (adsessionSettings == null)
         {
             mailboxConnectivity.Message = "ADSessionSettings were not found.";
             return(mailboxConnectivity);
         }
         mailboxConnectivity.Message = "Creating IRecipientSession";
         IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, adsessionSettings, 223, "CheckMailboxConnectivity", "f:\\15.00.1497\\sources\\dev\\Management\\src\\ServiceHost\\Servicelets\\AuditLogSearch\\Program\\AuditLogSearchHealthHandler.cs");
         if (tenantOrRootOrgRecipientSession == null)
         {
             mailboxConnectivity.Message = "IRecipientSession was not found.";
             return(mailboxConnectivity);
         }
         bool   flag = mailboxConnectivity.ExchangeUserId.CompareTo(Guid.Empty) == 0;
         ADUser aduser;
         if (flag)
         {
             mailboxConnectivity.Message = "Getting OrganizationId";
             OrganizationId organizationId = OrganizationId.FromAcceptedDomain(mailboxConnectivity.TenantAcceptedDomain);
             mailboxConnectivity.Message = "Finding arbitration mailbox";
             aduser = AdminAuditLogHelper.GetTenantArbitrationMailbox(organizationId);
             mailboxConnectivity.ExchangeUserId = aduser.ExchangeGuid;
         }
         else
         {
             mailboxConnectivity.Message = "Finding ADRecipient";
             ADRecipient adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuidIncludingAlternate(mailboxConnectivity.ExchangeUserId);
             aduser = (adrecipient as ADUser);
         }
         if (aduser == null)
         {
             mailboxConnectivity.Message = "ADUser was not found.";
             return(mailboxConnectivity);
         }
         mailboxConnectivity.Message = "Getting ExchangePrincipal";
         ExchangePrincipal principal = ExchangePrincipal.FromADUser(aduser, null);
         mailboxConnectivity.Message = "Creating EwsAuditClient";
         EwsAuditClient client = new EwsAuditClient(new EwsConnectionManager(principal, OpenAsAdminOrSystemServiceBudgetTypeType.Default, ExTraceGlobals.ServiceletTracer), TimeSpan.FromSeconds(5.0), ExTraceGlobals.ServiceletTracer);
         mailboxConnectivity.Message = "Checking connectivity";
         AuditLogSearchHealthHandler.CheckMailboxConnectivity(client, false);
         mailboxConnectivity.Message = "Checking connectivity (archive)";
         AuditLogSearchHealthHandler.CheckMailboxConnectivity(client, true);
         mailboxConnectivity.Message = "Ok";
         mailboxConnectivity.Success = true;
     }
     catch (Exception ex)
     {
         mailboxConnectivity.Message  += " FAILED.";
         mailboxConnectivity.Exception = ex.ToString();
     }
     return(mailboxConnectivity);
 }
        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);
        }
Example #3
0
        private static ADRawEntry FindByExchangeGuidIncludingAlternate(Guid exchangeGuid, IRecipientSession recipientSession, IRoutingDiagnostics diagnostics)
        {
            DateTime   utcNow = DateTime.UtcNow;
            ADRawEntry result;

            try
            {
                result = recipientSession.FindByExchangeGuidIncludingAlternate(exchangeGuid, ActiveDirectoryUserProvider.AdRawEntryProperties);
            }
            finally
            {
                diagnostics.AddAccountForestLatency(DateTime.UtcNow - utcNow);
            }
            return(result);
        }
Example #4
0
        protected override ADRawEntry LoadADRawEntry()
        {
            IRecipientSession session = null;

            if (!string.IsNullOrEmpty(this.Domain) && SmtpAddress.IsValidDomain(this.Domain))
            {
                try
                {
                    session = DirectoryHelper.GetRecipientSessionFromDomain(base.RequestContext.LatencyTracker, this.Domain, false);
                    goto IL_95;
                }
                catch (CannotResolveTenantNameException)
                {
                    base.UpdateNegativeCache(new NegativeAnchorMailboxCacheEntry
                    {
                        ErrorCode    = HttpStatusCode.NotFound,
                        SubErrorCode = HttpProxySubErrorCode.DomainNotFound,
                        SourceObject = this.ToCacheKey()
                    });
                    throw;
                }
            }
            session = DirectoryHelper.GetRootOrgRecipientSession();
IL_95:
            ADRawEntry adrawEntry;

            if (base.IsArchive != null)
            {
                adrawEntry = DirectoryHelper.InvokeAccountForest(base.RequestContext.LatencyTracker, () => session.FindByExchangeGuidIncludingAlternate(this.MailboxGuid, this.PropertySet));
            }
            else
            {
                adrawEntry = DirectoryHelper.InvokeAccountForest(base.RequestContext.LatencyTracker, () => session.FindByExchangeGuidIncludingAlternate(this.MailboxGuid, MailboxGuidAnchorMailbox.ADRawEntryWithArchivePropertySet));
                if (adrawEntry != null && ((Guid)adrawEntry[ADUserSchema.ArchiveGuid]).Equals(this.MailboxGuid))
                {
                    base.IsArchive = new bool?(true);
                }
            }
            if (adrawEntry == null && !string.IsNullOrEmpty(this.FallbackSmtp) && SmtpAddress.IsValidSmtpAddress(this.FallbackSmtp))
            {
                adrawEntry = new SmtpAnchorMailbox(this.FallbackSmtp, base.RequestContext)
                {
                    IsArchive = base.IsArchive,
                    NotFoundExceptionCreator = null
                }.GetADRawEntry();
            }
            return(base.CheckForNullAndThrowIfApplicable <ADRawEntry>(adrawEntry));
        }
        // Token: 0x06000127 RID: 295 RVA: 0x00006B5C File Offset: 0x00004D5C
        protected override ADRawEntry LoadADRawEntry()
        {
            IRecipientSession session = null;

            if (!string.IsNullOrEmpty(this.Domain) && SmtpAddress.IsValidDomain(this.Domain))
            {
                try
                {
                    session = DirectoryHelper.GetRecipientSessionFromMailboxGuidAndDomain(this.MailboxGuid, this.Domain, base.RequestContext.Logger, base.RequestContext.LatencyTracker);
                    goto IL_98;
                }
                catch (CannotResolveTenantNameException)
                {
                    base.UpdateNegativeCache(new NegativeAnchorMailboxCacheEntry
                    {
                        ErrorCode    = HttpStatusCode.NotFound,
                        SubErrorCode = 3009,
                        SourceObject = this.ToCacheKey()
                    });
                    throw;
                }
            }
            session = DirectoryHelper.GetRootOrgRecipientSession();
IL_98:
            ADRawEntry adrawEntry;

            if (base.IsArchive != null)
            {
                adrawEntry = DirectoryHelper.InvokeAccountForest <ADRawEntry>(base.RequestContext.LatencyTracker, () => session.FindByExchangeGuidIncludingAlternate(this.MailboxGuid, this.PropertySet, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\AnchorMailbox\\MailboxGuidAnchorMailbox.cs", 170, "LoadADRawEntry"), base.RequestContext.Logger, session);
            }
            else
            {
                adrawEntry = DirectoryHelper.InvokeAccountForest <ADRawEntry>(base.RequestContext.LatencyTracker, () => session.FindByExchangeGuidIncludingAlternate(this.MailboxGuid, MailboxGuidAnchorMailbox.ADRawEntryWithArchivePropertySet, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\AnchorMailbox\\MailboxGuidAnchorMailbox.cs", 184, "LoadADRawEntry"), base.RequestContext.Logger, session);
                if (adrawEntry != null)
                {
                    Guid guid  = (Guid)adrawEntry[ADMailboxRecipientSchema.ArchiveGuid];
                    Guid guid2 = (Guid)adrawEntry[ADMailboxRecipientSchema.ExchangeGuid];
                    if (guid.Equals(this.MailboxGuid))
                    {
                        base.IsArchive = new bool?(true);
                    }
                    else if (!guid2.Equals(this.MailboxGuid))
                    {
                        adrawEntry = DirectoryHelper.InvokeAccountForest <ADRawEntry>(base.RequestContext.LatencyTracker, () => session.FindByExchangeGuidIncludingAlternate(this.MailboxGuid, MailboxGuidAnchorMailbox.ADRawEntryWithMailboxLocationsPropertySet, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\AnchorMailbox\\MailboxGuidAnchorMailbox.cs", 208, "LoadADRawEntry"), base.RequestContext.Logger, session);
                        this.isLocationsMailbox = true;
                    }
                }
            }
            if (adrawEntry == null && !string.IsNullOrEmpty(this.FallbackSmtp) && SmtpAddress.IsValidSmtpAddress(this.FallbackSmtp))
            {
                adrawEntry = new SmtpAnchorMailbox(this.FallbackSmtp, base.RequestContext)
                {
                    IsArchive = base.IsArchive,
                    NotFoundExceptionCreator = null
                }.GetADRawEntry();
            }
            return(base.CheckForNullAndThrowIfApplicable <ADRawEntry>(adrawEntry));
        }