Пример #1
0
        // Token: 0x060003B8 RID: 952 RVA: 0x00017530 File Offset: 0x00015730
        private bool TryGetMailboxAccessPartnerInfo(CallContext callContext, ADRecipient callerAdRecipient, out PartnerInfo partnerInfo, out string targetTenant)
        {
            partnerInfo  = null;
            targetTenant = null;
            if (!Common.IsMultiTenancyEnabled)
            {
                return(false);
            }
            if (callContext.Users.Count != 1)
            {
                return(false);
            }
            User        user        = callContext.Users[0];
            SmtpAddress smtpAddress = new SmtpAddress(user.Mailbox);

            if (!smtpAddress.IsValidAddress)
            {
                return(false);
            }
            string         name           = callerAdRecipient.Name;
            SmtpDomain     smtpDomain     = new SmtpDomain(smtpAddress.Domain);
            OrganizationId organizationId = DomainToOrganizationIdCache.Singleton.Get(smtpDomain);

            if (organizationId != null && !ADAccountPartitionLocator.IsKnownPartition(organizationId.PartitionId))
            {
                organizationId = null;
            }
            OrganizationId organizationId2 = callerAdRecipient.OrganizationId;

            if (organizationId != null && organizationId.Equals(organizationId2))
            {
                ExTraceGlobals.FrameworkTracer.TraceDebug <string, OrganizationId>((long)this.GetHashCode(), "The caller {0} tries to query its' own org {1}", name, organizationId2);
                return(false);
            }
            partnerInfo = MailboxAccessPartnerInfoCache.Singleton.Get(new MailboxAccessPartnerInfoCacheKey(callerAdRecipient.Id, organizationId2));
            if (partnerInfo == PartnerInfo.Invalid)
            {
                ExTraceGlobals.FrameworkTracer.TraceDebug <string>((long)this.GetHashCode(), "The caller {0} could not be acted as mailbox access partner.", name);
                return(false);
            }
            if (!partnerInfo.HasPartnerRelationship(organizationId))
            {
                ExTraceGlobals.FrameworkTracer.TraceDebug <string, OrganizationId>((long)this.GetHashCode(), "The caller {0} has no partner relationship with organization {1}", name, organizationId);
                return(false);
            }
            targetTenant = smtpDomain.Domain;
            return(true);
        }