// Token: 0x0600071C RID: 1820 RVA: 0x00029C28 File Offset: 0x00027E28
        private AnchorMailbox ResolveToDefaultAnchorMailbox(string originalRpcServerName, string reason)
        {
            string text;

            if (HttpContextItemParser.TryGetLiveIdMemberName(base.HttpContext.Items, ref text))
            {
                AnchorMailbox anchorMailbox = base.ResolveAnchorMailbox();
                if (anchorMailbox != null)
                {
                    base.Logger.AppendString(3, "-" + reason);
                    if (ExTraceGlobals.BriefTracer.IsTraceEnabled(3))
                    {
                        ExTraceGlobals.BriefTracer.TraceError((long)this.GetHashCode(), "[RpcHttpProxyRequestHandler::ResolveToDefaultAnchorMailbox]: Invalid explicit RPC server name from client: {0}; Defaulting to authenticated user {1} for routing; Context {2}; State {3}", new object[]
                        {
                            originalRpcServerName,
                            text,
                            base.TraceContext,
                            base.State
                        });
                    }
                    this.rpcServerTarget = text;
                    return(anchorMailbox);
                }
            }
            throw new HttpProxyException(HttpStatusCode.NotFound, 3003, string.Format("RPC server name passed in by client could not be resolved: {0}", originalRpcServerName));
        }
Exemple #2
0
        public static AnchorMailbox CreateFromCaller(IRequestContext requestContext)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException("requestContext");
            }
            CommonAccessToken commonAccessToken = requestContext.HttpContext.Items["Item-CommonAccessToken"] as CommonAccessToken;

            if (commonAccessToken != null)
            {
                AnchorMailbox anchorMailbox = AnchorMailboxFactory.TryCreateFromCommonAccessToken(commonAccessToken, requestContext);
                if (anchorMailbox != null)
                {
                    return(anchorMailbox);
                }
            }
            if (requestContext.HttpContext.User == null || requestContext.HttpContext.User.Identity == null)
            {
                requestContext.Logger.SafeSet(HttpProxyMetadata.RoutingHint, "UnauthenticatedRequest-RandomBackEnd");
                return(new AnonymousAnchorMailbox(requestContext));
            }
            WindowsIdentity windowsIdentity = requestContext.HttpContext.User.Identity as WindowsIdentity;

            if (windowsIdentity != null && windowsIdentity.User == null)
            {
                requestContext.Logger.SafeSet(HttpProxyMetadata.RoutingHint, "AnonymousRequest-RandomBackEnd");
                return(new AnonymousAnchorMailbox(requestContext));
            }
            return(AnchorMailboxFactory.CreateFromLogonIdentity(requestContext));
        }
Exemple #3
0
        protected override BackEndServer GetDownLevelClientAccessServer(AnchorMailbox anchorMailbox, BackEndServer mailboxServer)
        {
            BackEndServer deterministicBackEndServer = HttpProxyBackEndHelper.GetDeterministicBackEndServer <WebServicesService>(mailboxServer, anchorMailbox.ToCookieKey(), this.ClientAccessType);

            ExTraceGlobals.VerboseTracer.TraceDebug <int, BackEndServer, BackEndServer>((long)this.GetHashCode(), "[OWAUserPhotoProxyRequestHandler::GetDownLevelClientAccessServer] Context {0}; Overriding down level target {0} with latest version backend {1}.", base.TraceContext, mailboxServer, deterministicBackEndServer);
            return(deterministicBackEndServer);
        }
 // Token: 0x060004C4 RID: 1220 RVA: 0x0001A4E4 File Offset: 0x000186E4
 protected override void OnDatabaseNotFound(AnchorMailbox anchorMailbox)
 {
     foreach (string text in this.BackEndCookieNames)
     {
         Utility.DeleteCookie(base.ClientRequest, base.ClientResponse, text, this.GetCookiePath(), false, false);
         Utility.DeleteCookie(base.ClientRequest, base.ClientResponse, text, null, true, false);
     }
     base.OnDatabaseNotFound(anchorMailbox);
 }
        protected override BackEndServer GetDownLevelClientAccessServer(AnchorMailbox anchorMailbox, BackEndServer mailboxServer)
        {
            base.LogElapsedTime("E_GetDLCAS");
            Uri           uri = null;
            BackEndServer downLevelClientAccessServer = DownLevelServerManager.Instance.GetDownLevelClientAccessServer <HttpService>(anchorMailbox, mailboxServer, this.ClientAccessType, base.Logger, HttpProxyGlobals.ProtocolType == ProtocolType.Owa || HttpProxyGlobals.ProtocolType == ProtocolType.OwaCalendar || HttpProxyGlobals.ProtocolType == ProtocolType.Ecp, out uri);

            base.LogElapsedTime("L_GetDLCAS");
            return(downLevelClientAccessServer);
        }
 // Token: 0x060006F6 RID: 1782 RVA: 0x000290E8 File Offset: 0x000272E8
 protected override void SetUseServerCookieFlag(AnchorMailbox anchorMailbox)
 {
     if (CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).GenerateServerCookieInRPS.Enabled)
     {
         DatabaseBasedAnchorMailbox databaseBasedAnchorMailbox = anchorMailbox as DatabaseBasedAnchorMailbox;
         if (databaseBasedAnchorMailbox != null)
         {
             databaseBasedAnchorMailbox.UseServerCookie = true;
         }
     }
 }
        // Token: 0x0600049B RID: 1179 RVA: 0x0001970C File Offset: 0x0001790C
        private bool TryMatchByCid(string publishingUrl, out AnchorMailbox anchorMailbox)
        {
            anchorMailbox = null;
            CID cid;

            if (RequestPathParser.TryGetCid(publishingUrl, ref cid))
            {
                anchorMailbox = new CidAnchorMailbox(cid.ToString(), this);
            }
            return(anchorMailbox != null);
        }
        // Token: 0x0600049D RID: 1181 RVA: 0x000197C4 File Offset: 0x000179C4
        private bool TryMatchBySmtpAddress(AnonymousPublishingUrl publishingUrl, out AnchorMailbox anchorMailbox)
        {
            anchorMailbox = null;
            string text = publishingUrl.ParameterSegments[0];

            if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(text))
            {
                base.Logger.Set(3, "AnonymousPublishingUrl-SMTP");
                anchorMailbox = new SmtpAnchorMailbox(text, this);
            }
            return(anchorMailbox != null);
        }
 // Token: 0x060000B4 RID: 180 RVA: 0x00004E6C File Offset: 0x0000306C
 public AnchoredRoutingTarget(AnchorMailbox anchorMailbox, BackEndServer backendServer)
 {
     if (anchorMailbox == null)
     {
         throw new ArgumentNullException("anchorMailbox");
     }
     if (backendServer == null)
     {
         throw new ArgumentNullException("backendServer");
     }
     this.AnchorMailbox = anchorMailbox;
     this.BackEndServer = backendServer;
 }
        public void RedirectMailbox(AnchorMailbox anchorMailbox)
        {
            if (anchorMailbox == null)
            {
                throw new ArgumentNullException("anchorMailbox");
            }
            if (!(anchorMailbox is UserBasedAnchorMailbox))
            {
                throw new ArgumentException("The AnchorMailbox object needs to be user based.");
            }
            string userAddress = this.ResolveUserAddress(anchorMailbox);

            this.RedirectAddress(userAddress);
        }
 public TargetCalculationCallbackBeacon(AnchorMailbox anchorMailbox, BackEndServer mailboxServer)
 {
     if (anchorMailbox == null)
     {
         throw new ArgumentNullException("anchorMailbox");
     }
     if (mailboxServer == null)
     {
         throw new ArgumentNullException("mailboxServer");
     }
     this.AnchorMailbox = anchorMailbox;
     this.MailboxServer = mailboxServer;
     this.State         = TargetCalculationCallbackState.MailboxServerResolved;
 }
        // Token: 0x0600073B RID: 1851 RVA: 0x0002A6F4 File Offset: 0x000288F4
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri>((long)this.GetHashCode(), "[SiteMailboxCreatingProxyRequestHandler::ResolveAnchorMailbox]: Method {0}; Url {1};", base.ClientRequest.HttpMethod, base.ClientRequest.Url);
            }
            if (!Utilities.IsPartnerHostedOnly && !GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled)
            {
                base.Logger.Set(3, "SiteMailboxCreating-ServerVersion");
                return(new ServerVersionAnchorMailbox <EcpService>(new ServerVersion(Server.E15MinVersion), 0, this));
            }
            AnchorMailbox anchorMailbox = AnchorMailboxFactory.CreateFromCaller(this);

            if (anchorMailbox is AnonymousAnchorMailbox)
            {
                return(anchorMailbox);
            }
            if (anchorMailbox is DomainAnchorMailbox || anchorMailbox is OrganizationAnchorMailbox)
            {
                return(anchorMailbox);
            }
            SidAnchorMailbox sidAnchorMailbox = anchorMailbox as SidAnchorMailbox;

            if (sidAnchorMailbox != null)
            {
                if (sidAnchorMailbox.OrganizationId == null)
                {
                    throw new InvalidOperationException(string.Format("OrganizationId is null for site mailbox proxy {0}.", anchorMailbox.ToString()));
                }
                base.Logger.Set(3, "SiteMailboxCreating-Organization");
                return(new OrganizationAnchorMailbox(sidAnchorMailbox.OrganizationId, this));
            }
            else
            {
                UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox as UserBasedAnchorMailbox;
                if (userBasedAnchorMailbox == null)
                {
                    throw new InvalidOperationException(string.Format("Unknown site mailbox proxy {0}.", anchorMailbox.ToString()));
                }
                OrganizationId organizationId = (OrganizationId)userBasedAnchorMailbox.GetADRawEntry()[ADObjectSchema.OrganizationId];
                if (organizationId == null)
                {
                    throw new InvalidOperationException(string.Format("OrganizationId is null for site mailbox proxy {0}.", anchorMailbox.ToString()));
                }
                base.Logger.Set(3, "SiteMailboxCreating-Organization");
                return(new OrganizationAnchorMailbox(organizationId, this));
            }
        }
        private string ResolveUserAddress(AnchorMailbox anchorMailbox)
        {
            SidAnchorMailbox sidAnchorMailbox = anchorMailbox as SidAnchorMailbox;

            if (sidAnchorMailbox != null && !string.IsNullOrEmpty(sidAnchorMailbox.SmtpOrLiveId))
            {
                return(sidAnchorMailbox.SmtpOrLiveId);
            }
            SmtpAnchorMailbox smtpAnchorMailbox = anchorMailbox as SmtpAnchorMailbox;

            if (smtpAnchorMailbox != null)
            {
                return(smtpAnchorMailbox.Smtp);
            }
            UserBasedAnchorMailbox userBasedAnchorMailbox = (UserBasedAnchorMailbox)anchorMailbox;

            return(string.Format("anyone@{0}", userBasedAnchorMailbox.GetDomainName()));
        }
Exemple #14
0
        public BackEndServer GetDownLevelClientAccessServer <ServiceType>(AnchorMailbox anchorMailbox, BackEndServer mailboxServer, ClientAccessType clientAccessType, RequestDetailsLogger logger, bool calculateRedirectUrl, out Uri redirectUrl) where ServiceType : HttpService
        {
            if (anchorMailbox == null)
            {
                throw new ArgumentNullException("anchorMailbox");
            }
            if (mailboxServer == null)
            {
                throw new ArgumentNullException("mailboxServer");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (!DownLevelServerManager.IsApplicable)
            {
                throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.EndpointNotFound, string.Format("{0} does not support down level server proxy.", HttpProxyGlobals.ProtocolType));
            }
            redirectUrl = null;
            if (mailboxServer.Version < Server.E14MinVersion)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <int, int, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServer]: Found mailbox server version {0}, which was pre-E14 minimum version {1}, so returning mailbox server FQDN {2}", mailboxServer.Version, Server.E14MinVersion, mailboxServer.Fqdn);
                return(mailboxServer);
            }
            ServiceTopology currentLegacyServiceTopology = ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 393);
            Site            site   = currentLegacyServiceTopology.GetSite(mailboxServer.Fqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 394);
            ServiceType     result = this.GetClientAccessServiceInSite <ServiceType>(currentLegacyServiceTopology, anchorMailbox, site, clientAccessType, (ServiceType service) => service.ServerVersionNumber >= Server.E14MinVersion && service.ServerVersionNumber < Server.E15MinVersion, logger);

            if (calculateRedirectUrl && !Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossSiteRedirect.Enabled && result != null && !string.IsNullOrEmpty(result.ServerFullyQualifiedDomainName))
            {
                Site member = HttpProxyGlobals.LocalSite.Member;
                if (!member.DistinguishedName.Equals(result.Site.DistinguishedName))
                {
                    HttpService httpService = currentLegacyServiceTopology.FindAny <ServiceType>(ClientAccessType.External, (ServiceType externalService) => externalService != null && externalService.ServerFullyQualifiedDomainName.Equals(result.ServerFullyQualifiedDomainName, StringComparison.OrdinalIgnoreCase), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServer", 419);
                    if (httpService != null)
                    {
                        redirectUrl = httpService.Url;
                    }
                }
            }
            return(new BackEndServer(result.ServerFullyQualifiedDomainName, result.ServerVersionNumber));
        }
 protected override AnchorMailbox ResolveAnchorMailbox()
 {
     if (AutodiscoverProxyRequestHandler.LoadBalancedPartnerRouting.Value && base.ClientRequest.Url.AbsolutePath.ToLower().Contains("/wssecurity/x509cert"))
     {
         string text  = base.ClientRequest.Headers[Constants.AnchorMailboxHeaderName];
         string text2 = null;
         if (string.IsNullOrEmpty(text))
         {
             AnchorMailbox anchorMailbox = base.TryGetAnchorMailboxFromWsSecurityRequest();
             if (anchorMailbox != null)
             {
                 SmtpAnchorMailbox smtpAnchorMailbox = anchorMailbox as SmtpAnchorMailbox;
                 if (smtpAnchorMailbox != null)
                 {
                     text2 = smtpAnchorMailbox.Smtp;
                 }
                 else
                 {
                     DomainAnchorMailbox domainAnchorMailbox = anchorMailbox as DomainAnchorMailbox;
                     if (domainAnchorMailbox != null)
                     {
                         text2 = domainAnchorMailbox.Domain;
                     }
                 }
             }
         }
         else
         {
             text2 = text;
         }
         if (!string.IsNullOrEmpty(text2))
         {
             bool flag = text2.EndsWith(AutodiscoverProxyRequestHandler.BlackBerryTenantName.Value, StringComparison.OrdinalIgnoreCase);
             if (flag)
             {
                 base.Logger.SafeSet(HttpProxyMetadata.RoutingHint, "PartnerX509Request");
                 return(new TargetForestAnchorMailbox(this, AutodiscoverProxyRequestHandler.BlackBerryTenantName.Value, false));
             }
         }
     }
     return(base.ResolveAnchorMailbox());
 }
        protected override BackEndServer GetDownLevelClientAccessServer(AnchorMailbox anchorMailbox, BackEndServer mailboxServer)
        {
            if (mailboxServer.Version < Server.E14MinVersion)
            {
                return(this.GetE12TargetServer(mailboxServer));
            }
            Uri           uri = null;
            BackEndServer downLevelClientAccessServer = DownLevelServerManager.Instance.GetDownLevelClientAccessServer <ServiceType>(anchorMailbox, mailboxServer, this.ClientAccessType, base.Logger, HttpProxyGlobals.ProtocolType == ProtocolType.Owa || HttpProxyGlobals.ProtocolType == ProtocolType.OwaCalendar || HttpProxyGlobals.ProtocolType == ProtocolType.Ecp, out uri);

            if (uri != null)
            {
                Uri uri2 = this.UpdateExternalRedirectUrl(uri);
                if (Uri.Compare(uri2, base.ClientRequest.Url, UriComponents.Host, UriFormat.Unescaped, StringComparison.Ordinal) != 0)
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[BEServerCookieProxyRequestHandler::GetDownLevelClientAccessServer]: Stop processing and redirect to {0}.", uri2.ToString());
                    throw new HttpException(302, uri2.ToString());
                }
            }
            return(downLevelClientAccessServer);
        }
        // Token: 0x0600049C RID: 1180 RVA: 0x0001973C File Offset: 0x0001793C
        private bool TryMatchByGuidAtDomain(AnonymousPublishingUrl publishingUrl, out AnchorMailbox anchorMailbox)
        {
            anchorMailbox = null;
            string text   = publishingUrl.ParameterSegments[0];
            Guid   empty  = Guid.Empty;
            string empty2 = string.Empty;

            if (RequestHeaderParser.TryGetMailboxGuid(text, ref empty, ref empty2))
            {
                string text2 = string.Format("AnonymousPublishingUrl-MailboxGuid{0}", string.IsNullOrEmpty(empty2) ? string.Empty : "WithDomainAndSmtpFallback");
                base.Logger.Set(3, text2);
                MailboxGuidAnchorMailbox mailboxGuidAnchorMailbox = new MailboxGuidAnchorMailbox(empty, empty2, this);
                if (!string.IsNullOrEmpty(empty2))
                {
                    mailboxGuidAnchorMailbox.FallbackSmtp = text;
                }
                anchorMailbox = mailboxGuidAnchorMailbox;
            }
            return(anchorMailbox != null);
        }
        // Token: 0x060001B2 RID: 434 RVA: 0x00008840 File Offset: 0x00006A40
        public override AnchorMailbox CreateAuthModuleSpecificAnchorMailbox(IRequestContext requestContext)
        {
            AnchorMailbox result = null;
            string        text;

            if (RequestCookieParser.TryGetDefaultAnchorMailboxCookie(requestContext.HttpContext.Request.Cookies, ref text))
            {
                if (SmtpAddress.IsValidSmtpAddress(text))
                {
                    string organizationContext;
                    HttpContextItemParser.TryGetLiveIdOrganizationContext(requestContext.HttpContext.Items, ref organizationContext);
                    requestContext.Logger.SafeSet(3, "DefaultAnchorMailboxCookie");
                    result = new LiveIdMemberNameAnchorMailbox(text, organizationContext, requestContext);
                }
            }
            else
            {
                requestContext.Logger.SafeSet(3, "UnauthenticatedAnonymous");
                result = new AnonymousAnchorMailbox(requestContext);
            }
            return(result);
        }
Exemple #19
0
        // Token: 0x060000E5 RID: 229 RVA: 0x000055DC File Offset: 0x000037DC
        public static AnchorMailbox CreateFromCaller(IRequestContext requestContext)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException("requestContext");
            }
            CommonAccessToken commonAccessToken = requestContext.HttpContext.Items["Item-CommonAccessToken"] as CommonAccessToken;

            if (commonAccessToken != null)
            {
                AnchorMailbox anchorMailbox = AnchorMailboxFactory.TryCreateFromCommonAccessToken(commonAccessToken, requestContext);
                if (anchorMailbox != null)
                {
                    return(anchorMailbox);
                }
            }
            if (requestContext.HttpContext.User == null || requestContext.HttpContext.User.Identity == null)
            {
                requestContext.Logger.SafeSet(3, "UnauthenticatedRequest-RandomBackEnd");
                return(new AnonymousAnchorMailbox(requestContext));
            }
            if (HttpProxySettings.IdentityIndependentAuthBehaviorEnabled.Value && requestContext.AuthBehavior.AuthState != AuthState.FrontEndFullAuth)
            {
                AnchorMailbox anchorMailbox2 = requestContext.AuthBehavior.CreateAuthModuleSpecificAnchorMailbox(requestContext);
                if (anchorMailbox2 != null)
                {
                    return(anchorMailbox2);
                }
            }
            WindowsIdentity windowsIdentity = requestContext.HttpContext.User.Identity as WindowsIdentity;

            if (windowsIdentity != null && windowsIdentity.User == null)
            {
                requestContext.Logger.SafeSet(3, "AnonymousRequest-RandomBackEnd");
                return(new AnonymousAnchorMailbox(requestContext));
            }
            return(AnchorMailboxFactory.CreateFromLogonIdentity(requestContext));
        }
Exemple #20
0
        private AnchorMailbox ResolveToDefaultAnchorMailbox(string originalRpcServerName, string reason)
        {
            string text = base.HttpContext.Items[Constants.WLIDMemberName] as string;

            if (!string.IsNullOrEmpty(text))
            {
                AnchorMailbox anchorMailbox = base.ResolveAnchorMailbox();
                if (anchorMailbox != null)
                {
                    base.Logger.AppendString(HttpProxyMetadata.RoutingHint, "-" + reason);
                    ExTraceGlobals.BriefTracer.TraceError((long)this.GetHashCode(), "[RpcHttpProxyRequestHandler::ResolveToDefaultAnchorMailbox]: Invalid explicit RPC server name from client: {0}; Defaulting to authenticated user {1} for routing; Context {2}; State {3}", new object[]
                    {
                        originalRpcServerName,
                        text,
                        base.TraceContext,
                        base.State
                    });
                    this.rpcServerTarget = text;
                    return(anchorMailbox);
                }
            }
            throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.MailboxGuidWithDomainNotFound, string.Format("RPC server name passed in by client could not be resolved: {0}", originalRpcServerName));
        }
        // Token: 0x060004BD RID: 1213 RVA: 0x0001A12C File Offset: 0x0001832C
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            AnchorMailbox anchorMailbox = null;

            if (!base.HasPreemptivelyCheckedForRoutingHint)
            {
                anchorMailbox = base.CreateAnchorMailboxFromRoutingHint();
            }
            if (anchorMailbox != null)
            {
                return(anchorMailbox);
            }
            anchorMailbox = this.TryGetAnchorMailboxFromWsSecurityRequest();
            if (anchorMailbox != null)
            {
                return(anchorMailbox);
            }
            anchorMailbox = this.TryGetAnchorMailboxFromDomainBasedRequest();
            if (anchorMailbox != null)
            {
                return(anchorMailbox);
            }
            return(AnchorMailboxFactory.CreateFromCaller(this));
        }
        // Token: 0x06000573 RID: 1395 RVA: 0x0001E664 File Offset: 0x0001C864
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            string text = base.ClientRequest.Headers[Constants.TargetDatabaseHeaderName];

            if (!string.IsNullOrEmpty(text))
            {
                Guid databaseGuid;
                if (Guid.TryParse(text, out databaseGuid))
                {
                    base.Logger.Set(3, "TargetDatabase-GUID");
                    return(new DatabaseGuidAnchorMailbox(databaseGuid, this));
                }
                base.Logger.Set(3, "TargetDatabase-Name");
                return(new DatabaseNameAnchorMailbox(text, this));
            }
            else
            {
                AnchorMailbox anchorMailbox = base.CreateAnchorMailboxFromRoutingHint();
                if (anchorMailbox != null)
                {
                    return(anchorMailbox);
                }
                if (Utilities.IsPartnerHostedOnly || GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled)
                {
                    base.Logger.Set(3, "ClientVersionHeader");
                    return(base.GetServerVersionAnchorMailbox(base.ClientRequest.Headers[Constants.ClientVersionHeaderName]));
                }
                string text2 = base.ClientRequest.Headers["X-GenericAnchorHint"];
                if (!string.IsNullOrEmpty(text2))
                {
                    return(new PstProviderAnchorMailbox(text2, this));
                }
                base.Logger.Set(3, "ForestWideOrganization");
                return(new OrganizationAnchorMailbox(OrganizationId.ForestWideOrgId, this));
            }
        }
Exemple #23
0
 protected override BackEndServer GetDownLevelClientAccessServer(AnchorMailbox anchorMailbox, BackEndServer backEndServer)
 {
     return(backEndServer);
 }
Exemple #24
0
        private ServiceType GetClientAccessServiceInSite <ServiceType>(ServiceTopology topology, AnchorMailbox anchorMailbox, Site targetSite, ClientAccessType clientAccessType, Predicate <ServiceType> otherFilter, RequestDetailsLogger logger) where ServiceType : HttpService
        {
            Dictionary <string, List <DownLevelServerStatusEntry> > downLevelServerMap = this.GetDownLevelServerMap();
            List <DownLevelServerStatusEntry> serverList = null;

            if (!downLevelServerMap.TryGetValue(targetSite.DistinguishedName, out serverList))
            {
                string text = string.Format("Unable to find site {0} in the down level server map.", targetSite.DistinguishedName);
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceInSite]: {0}", text);
                ThreadPool.QueueUserWorkItem(delegate(object o)
                {
                    this.RefreshServerMap(true);
                });
                throw new NoAvailableDownLevelBackEndException(text);
            }
            return(this.GetClientAccessServiceFromList <ServiceType>(serverList, topology, anchorMailbox, targetSite, clientAccessType, otherFilter, logger, DownLevelServerManager.DownlevelExchangeServerVersion.Exchange2010));
        }
Exemple #25
0
        // Token: 0x060000EB RID: 235 RVA: 0x00005DD4 File Offset: 0x00003FD4
        private static AnchorMailbox CreateFromLogonIdentity(IRequestContext requestContext)
        {
            HttpContext httpContext = requestContext.HttpContext;
            IPrincipal  user        = httpContext.User;
            IIdentity   identity    = httpContext.User.Identity;
            string      text;

            HttpContextItemParser.TryGetLiveIdMemberName(httpContext.Items, ref text);
            OAuthIdentity oauthIdentity = identity as OAuthIdentity;

            if (oauthIdentity != null)
            {
                string externalDirectoryObjectId;
                if (RequestHeaderParser.TryGetExternalDirectoryObjectId(httpContext.Request.Headers, ref externalDirectoryObjectId))
                {
                    requestContext.Logger.SafeSet(3, "OAuthIdentity-ExternalDirectoryObjectId");
                    return(new ExternalDirectoryObjectIdAnchorMailbox(externalDirectoryObjectId, oauthIdentity.OrganizationId, requestContext));
                }
                if (oauthIdentity.ActAsUser != null)
                {
                    requestContext.Logger.SafeSet(3, "OAuthIdentity-ActAsUser");
                    return(new OAuthActAsUserAnchorMailbox(oauthIdentity.ActAsUser, requestContext));
                }
                requestContext.Logger.SafeSet(3, "OAuthIdentity-AppOrganization");
                return(new OrganizationAnchorMailbox(oauthIdentity.OrganizationId, requestContext));
            }
            else
            {
                GenericSidIdentity genericSidIdentity = identity as GenericSidIdentity;
                if (genericSidIdentity != null)
                {
                    requestContext.Logger.SafeSet(3, "GenericSidIdentity");
                    return(new SidAnchorMailbox(genericSidIdentity.Sid, requestContext)
                    {
                        PartitionId = genericSidIdentity.PartitionId,
                        SmtpOrLiveId = text
                    });
                }
                DelegatedPrincipal delegatedPrincipal = user as DelegatedPrincipal;
                if (delegatedPrincipal != null && delegatedPrincipal.DelegatedOrganization != null && string.IsNullOrEmpty(text))
                {
                    requestContext.Logger.SafeSet(3, "DelegatedPrincipal-DelegatedOrganization");
                    return(new DomainAnchorMailbox(delegatedPrincipal.DelegatedOrganization, requestContext));
                }
                WindowsIdentity windowsIdentity = identity as WindowsIdentity;
                if (windowsIdentity != null)
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        requestContext.Logger.SafeSet(3, "WindowsIdentity");
                    }
                    else
                    {
                        requestContext.Logger.SafeSet(3, "WindowsIdentity-LiveIdMemberName");
                    }
                    return(new SidAnchorMailbox(windowsIdentity.User, requestContext)
                    {
                        SmtpOrLiveId = text
                    });
                }
                SecurityIdentifier securityIdentifier = null;
                if (IIdentityExtensions.TryGetSecurityIdentifier(identity, ref securityIdentifier) && !securityIdentifier.Equals(AuthCommon.MemberNameNullSid))
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        requestContext.Logger.SafeSet(3, "SID");
                    }
                    else
                    {
                        requestContext.Logger.SafeSet(3, "SID-LiveIdMemberName");
                    }
                    return(new SidAnchorMailbox(securityIdentifier, requestContext)
                    {
                        SmtpOrLiveId = text
                    });
                }
                if (!HttpProxySettings.IdentityIndependentAuthBehaviorEnabled.Value && requestContext.AuthBehavior.AuthState != AuthState.FrontEndFullAuth)
                {
                    AnchorMailbox anchorMailbox = requestContext.AuthBehavior.CreateAuthModuleSpecificAnchorMailbox(requestContext);
                    if (anchorMailbox != null)
                    {
                        return(anchorMailbox);
                    }
                }
                if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(text))
                {
                    requestContext.Logger.SafeSet(3, "Smtp-LiveIdMemberName");
                    return(new SmtpAnchorMailbox(text, requestContext));
                }
                throw new InvalidOperationException(string.Format("Unknown idenity {0} with type {1}.", IIdentityExtensions.GetSafeName(identity, true), identity.ToString()));
            }
        }
Exemple #26
0
        // Token: 0x060000E7 RID: 231 RVA: 0x00005928 File Offset: 0x00003B28
        public static bool TryCreateFromMailboxGuid(IRequestContext requestContext, string anchorMailboxAddress, out AnchorMailbox anchorMailbox)
        {
            anchorMailbox = null;
            Guid   mailboxGuid;
            string domain;

            if (RequestHeaderParser.TryGetMailboxGuid(anchorMailboxAddress, ref mailboxGuid, ref domain))
            {
                requestContext.Logger.SafeSet(3, "URL-MailboxGuidWithDomain");
                anchorMailbox = new MailboxGuidAnchorMailbox(mailboxGuid, domain, requestContext);
                return(true);
            }
            return(false);
        }
Exemple #27
0
 // Token: 0x0600050C RID: 1292 RVA: 0x0001BDA0 File Offset: 0x00019FA0
 protected override AnchorMailbox ResolveAnchorMailbox()
 {
     if (base.State != ProxyRequestHandler.ProxyState.CalculateBackEndSecondRound)
     {
         if (!base.AuthBehavior.IsFullyAuthenticated())
         {
             base.HasPreemptivelyCheckedForRoutingHint = true;
             string liveIdMemberName;
             if (RequestHeaderParser.TryGetAnchorMailboxUpn(base.ClientRequest.Headers, ref liveIdMemberName))
             {
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: From Header Routing UPN Hint, context {1}.", base.TraceContext);
                 }
                 base.Logger.SafeSet(3, "OwaEcpUpn");
                 return(new LiveIdMemberNameAnchorMailbox(liveIdMemberName, null, this));
             }
             AnchorMailbox anchorMailbox = base.CreateAnchorMailboxFromRoutingHint();
             if (anchorMailbox != null)
             {
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: From Header Routing Hint, context {1}.", base.TraceContext);
                 }
                 return(anchorMailbox);
             }
         }
         string text = this.TryGetExplicitLogonNode(0);
         bool   flag;
         if (!string.IsNullOrEmpty(text))
         {
             if (SmtpAddress.IsValidSmtpAddress(text))
             {
                 base.IsExplicitSignOn      = true;
                 base.ExplicitSignOnAddress = text;
                 base.Logger.Set(3, "ExplicitSignOn-SMTP");
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: ExplicitSignOn-SMTP. Address {0}, context {1}.", text, base.TraceContext);
                 }
                 return(new SmtpAnchorMailbox(text, this));
             }
             if ((Utilities.IsPartnerHostedOnly || CafeConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).SyndicatedAdmin.Enabled) && text.StartsWith("@"))
             {
                 this.isSyndicatedAdmin = true;
                 text = text.Substring(1);
                 if (SmtpAddress.IsValidDomain(text))
                 {
                     string text2 = this.TryGetExplicitLogonNode(1);
                     if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                     {
                         ExTraceGlobals.VerboseTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: SyndAdmin, domain {0}, SMTP {1}, context {2}.", text, text2, base.TraceContext);
                     }
                     if (!string.IsNullOrEmpty(text2) && SmtpAddress.IsValidSmtpAddress(text2))
                     {
                         base.IsExplicitSignOn      = true;
                         base.ExplicitSignOnAddress = text2;
                         base.Logger.Set(3, "SyndAdmin-SMTP");
                         return(new SmtpAnchorMailbox(text2, this));
                     }
                     base.Logger.Set(3, "SyndAdmin-Domain");
                     return(new DomainAnchorMailbox(text, this));
                 }
             }
         }
         else if (!Utilities.IsPartnerHostedOnly && !GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled)
         {
             string text3 = this.TryGetBackendParameter("TargetServer", out flag);
             if (!string.IsNullOrEmpty(text3))
             {
                 base.Logger.Set(3, "TargetServer" + (flag ? "-UrlQuery" : "-Cookie"));
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: On-Premise, TargetServer parameter {0}, from {1}, context {2}.", text3, flag ? "url query" : "cookie", base.TraceContext);
                 }
                 return(new ServerInfoAnchorMailbox(text3, this));
             }
         }
         string text4 = this.TryGetBackendParameter("ExchClientVer", out flag);
         if (!string.IsNullOrEmpty(text4))
         {
             string text5 = Utilities.NormalizeExchClientVer(text4);
             base.Logger.Set(3, "ExchClientVer" + (flag ? "-UrlQuery" : "-Cookie"));
             if (!Utilities.IsPartnerHostedOnly && !GlobalConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MultiTenancy.Enabled)
             {
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: On-Premise, Version parameter {0}, from {1}, context {2}.", text4, flag ? "url query" : "cookie", base.TraceContext);
                 }
                 return(base.GetServerVersionAnchorMailbox(text5));
             }
             string text6 = (string)base.HttpContext.Items["AuthenticatedUserOrganization"];
             if (!string.IsNullOrEmpty(text6))
             {
                 if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                 {
                     ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: On-Cloud, Version parameter {0}, from {1}, domain {2}, context {3}.", new object[]
                     {
                         text5,
                         flag ? "url query" : "cookie",
                         text6,
                         base.TraceContext
                     });
                 }
                 return(VersionedDomainAnchorMailbox.GetAnchorMailbox(text6, text5, this));
             }
             if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
             {
                 ExTraceGlobals.VerboseTracer.TraceDebug <int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: AuthenticatedUserOrganization is null. Context {0}.", base.TraceContext);
             }
         }
     }
     if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
     {
         ExTraceGlobals.VerboseTracer.TraceDebug <string, int>((long)this.GetHashCode(), "[EcpProxyRequestHandler::ResolveAnchorMailbox]: {0}, context {1}, call base method to do regular anchor mailbox calculation.", (base.State == ProxyRequestHandler.ProxyState.CalculateBackEndSecondRound) ? "Second round" : "Nothing special", base.TraceContext);
     }
     return(base.ResolveAnchorMailbox());
 }
Exemple #28
0
        // Token: 0x060004DC RID: 1244 RVA: 0x0001ADF8 File Offset: 0x00018FF8
        protected override bool HandleBackEndCalculationException(Exception exception, AnchorMailbox anchorMailbox, string label)
        {
            HttpProxyException ex = exception as HttpProxyException;

            if (ex != null && ex.ErrorCode == 3009)
            {
                HttpException exception2 = new HttpException(302, E4eProxyRequestHandler.GetErrorUrl(E4eProxyRequestHandler.E4eErrorType.OrgNotExisting));
                return(base.HandleBackEndCalculationException(exception2, anchorMailbox, label));
            }
            return(base.HandleBackEndCalculationException(exception, anchorMailbox, label));
        }
Exemple #29
0
        private ServiceType GetClientAccessServiceFromList <ServiceType>(List <DownLevelServerStatusEntry> serverList, ServiceTopology topology, AnchorMailbox anchorMailbox, Site targetSite, ClientAccessType clientAccessType, Predicate <ServiceType> otherFilter, RequestDetailsLogger logger, DownLevelServerManager.DownlevelExchangeServerVersion targetDownlevelExchangeServerVersion) where ServiceType : HttpService
        {
            string text     = anchorMailbox.ToCookieKey();
            int    hashCode = HttpProxyBackEndHelper.GetHashCode(text);

            serverList = this.GetFilteredServerListByVersion(serverList, targetDownlevelExchangeServerVersion);
            int[] shuffledList = DownLevelServerManager.GetShuffledList(serverList.Count, hashCode);
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, int, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: HashKey: {0}, HashCode: {1}, Anchor mailbox {2}.", text, hashCode, anchorMailbox.ToString());
            }
            for (int i = 0; i < shuffledList.Length; i++)
            {
                int num = shuffledList[i];
                DownLevelServerStatusEntry currentServer = serverList[num];
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string, int, bool>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} is selected by current index {1}. IsHealthy = {2}", currentServer.BackEndServer.Fqdn, num, currentServer.IsHealthy);
                }
                if (currentServer.IsHealthy)
                {
                    ServiceType serviceType = topology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && service.ServerFullyQualifiedDomainName.Equals(currentServer.BackEndServer.Fqdn, StringComparison.OrdinalIgnoreCase) && !service.IsOutOfService && otherFilter(service), "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetClientAccessServiceFromList", 767);
                    if (serviceType != null)
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug <Uri, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Found service {0} matching back end server {1}.", serviceType.Url, currentServer.BackEndServer.Fqdn);
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(logger, "DownLevelTargetRandomHashing", string.Format("{0}/{1}", i, serverList.Count));

                        return(serviceType);
                    }
                    ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} cannot be found by ServiceDiscovery.", currentServer.BackEndServer.Fqdn);
                }
                else
                {
                    ExTraceGlobals.VerboseTracer.TraceWarning <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} is marked as unhealthy.", currentServer.BackEndServer.Fqdn);
                }
            }
            RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(logger, "DownLevelTargetRandomHashingFailure", string.Format("{0}", serverList.Count));

            this.TriggerServerMapRefreshIfNeeded(topology, serverList);
            string text2 = string.Format("Unable to find proper back end service for {0} in site {1}.", anchorMailbox, targetSite.DistinguishedName);

            ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: {0}", text2);
            throw new NoAvailableDownLevelBackEndException(text2);
        }
Exemple #30
0
        protected override AnchorMailbox ResolveAnchorMailbox()
        {
            AnchorMailbox          anchorMailbox          = null;
            AnchorMailbox          anchorMailbox2         = base.ResolveAnchorMailbox();
            UserBasedAnchorMailbox userBasedAnchorMailbox = anchorMailbox2 as UserBasedAnchorMailbox;

            if (userBasedAnchorMailbox == null)
            {
                return(anchorMailbox2);
            }
            userBasedAnchorMailbox.UseServerCookie = true;
            string targetOrgMailbox = base.HttpContext.Request.Headers["TargetOrgMailbox"];
            Guid   guid             = Guid.Empty;

            if (!string.IsNullOrEmpty(targetOrgMailbox))
            {
                IRecipientSession session    = DirectoryHelper.GetRecipientSessionFromSmtpOrLiveId(base.LatencyTracker, targetOrgMailbox, false);
                ADRawEntry        adrawEntry = DirectoryHelper.InvokeAccountForest(base.LatencyTracker, () => OrganizationMailbox.GetOrganizationMailboxByUPNAndCapability(session, targetOrgMailbox, OrganizationCapability.OABGen));
                if (adrawEntry != null)
                {
                    anchorMailbox = new UserADRawEntryAnchorMailbox(adrawEntry, this);
                }
            }
            else
            {
                AnchoredRoutingTarget anchoredRoutingTarget = this.TryFastTargetCalculationByAnchorMailbox(anchorMailbox2);
                if (anchoredRoutingTarget != null)
                {
                    return(anchoredRoutingTarget.AnchorMailbox);
                }
                ADRawEntry adrawEntry2 = userBasedAnchorMailbox.GetADRawEntry();
                if (adrawEntry2 == null)
                {
                    return(anchorMailbox2);
                }
                guid = OABRequestUrl.GetOabGuidFromRequest(base.HttpContext.Request);
                if (guid == Guid.Empty)
                {
                    return(anchorMailbox2);
                }
                OrganizationId organizationId     = (OrganizationId)adrawEntry2[ADObjectSchema.OrganizationId];
                string         userAcceptedDomain = null;
                if (organizationId != OrganizationId.ForestWideOrgId)
                {
                    userAcceptedDomain = ((SmtpAddress)adrawEntry2[ADRecipientSchema.PrimarySmtpAddress]).Domain;
                }
                OABCache.OABCacheEntry oabfromCacheOrAD = OABCache.Instance.GetOABFromCacheOrAD(guid, userAcceptedDomain);
                if (oabfromCacheOrAD.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012))
                {
                    anchorMailbox = this.GetE14CASServer(oabfromCacheOrAD);
                }
                else
                {
                    ADRawEntry adrawEntry3 = null;
                    if (OABVariantConfigurationSettings.IsLinkedOABGenMailboxesEnabled && !oabfromCacheOrAD.ShadowMailboxDistributionEnabled && oabfromCacheOrAD.GeneratingMailbox != null)
                    {
                        IRecipientSession recipientSessionFromOrganizationId = DirectoryHelper.GetRecipientSessionFromOrganizationId(base.LatencyTracker, organizationId);
                        adrawEntry3 = recipientSessionFromOrganizationId.Read(oabfromCacheOrAD.GeneratingMailbox);
                    }
                    if (adrawEntry3 == null)
                    {
                        if (OABVariantConfigurationSettings.IsSkipServiceTopologyDiscoveryEnabled)
                        {
                            adrawEntry3 = HttpProxyBackEndHelper.GetOrganizationMailbox(organizationId, OrganizationCapability.OABGen, null);
                        }
                        else
                        {
                            adrawEntry3 = HttpProxyBackEndHelper.GetOrganizationMailboxInClosestSite(organizationId, OrganizationCapability.OABGen);
                        }
                    }
                    if (adrawEntry3 != null)
                    {
                        anchorMailbox = new UserADRawEntryAnchorMailbox(adrawEntry3, this)
                        {
                            UseServerCookie = true
                        };
                    }
                }
            }
            if (anchorMailbox == null)
            {
                ExTraceGlobals.VerboseTracer.TraceError(0L, "[OabProxyRequestHandler::ResolveAnchorMailbox] Unable to locate appropriate server for OAB");
                string message;
                if (string.IsNullOrEmpty(targetOrgMailbox))
                {
                    message = string.Format("Unable to locate appropriate server for OAB {0}.", guid);
                }
                else
                {
                    message = string.Format("Unable to locate organization mailbox {0}", targetOrgMailbox);
                }
                throw new HttpProxyException(HttpStatusCode.InternalServerError, HttpProxySubErrorCode.OrganizationMailboxNotFound, message);
            }
            ExTraceGlobals.VerboseTracer.TraceDebug <AnchorMailbox>(0L, "[OabProxyRequestHandler::ResolveAnchorMailbox] Proxying OAB request using anchor {0}.", anchorMailbox);
            string value = string.Format("{0}-{1}", base.Logger.Get(HttpProxyMetadata.RoutingHint), "OABOrgMailbox");

            base.Logger.Set(HttpProxyMetadata.RoutingHint, value);
            anchorMailbox.OriginalAnchorMailbox = anchorMailbox2;
            return(anchorMailbox);
        }