Ejemplo n.º 1
0
 public void Set(WebServiceUri webServiceUri, int versionBucket)
 {
     if (webServiceUri == null)
     {
         throw new ArgumentNullException("webServiceUri");
     }
     if (!LocalizedString.Empty.Equals(webServiceUri.AutodiscoverFailedExceptionString))
     {
         this.uriByVersionBuckets[versionBucket] = webServiceUri;
         return;
     }
     for (int i = versionBucket; i > -1; i--)
     {
         if (i == versionBucket)
         {
             this.uriByVersionBuckets[i] = webServiceUri;
         }
         else
         {
             WebServiceUri webServiceUri2 = this.uriByVersionBuckets[i];
             if (webServiceUri2 == null)
             {
                 this.uriByVersionBuckets[i] = webServiceUri;
             }
             else if (!LocalizedString.Empty.Equals(webServiceUri2.AutodiscoverFailedExceptionString))
             {
                 this.uriByVersionBuckets[i] = webServiceUri;
             }
         }
     }
 }
Ejemplo n.º 2
0
        protected override void SetResult(AutoDiscoverQueryItem queryItem, LocalizedString exceptionString, uint locationIdentifier)
        {
            WebServiceUri webServiceUri = new WebServiceUri(null, exceptionString, queryItem.EmailAddress);

            base.AddWebServiceUriToCache(queryItem, webServiceUri);
            queryItem.SetResult(new AutoDiscoverResult(new AutoDiscoverFailedException(exceptionString, locationIdentifier)));
        }
        internal static WebServiceUri Get(EmailAddress email, int versionBucket)
        {
            string text = email.Address.ToLower();
            VersionedWebServiceUri versionedWebServiceUri;

            lock (RemoteServiceUriCache.cacheLocker)
            {
                versionedWebServiceUri = (VersionedWebServiceUri)RemoteServiceUriCache.cache[text];
            }
            if (versionedWebServiceUri != null)
            {
                RemoteServiceUriCache.AutoDiscoverTracer.TraceDebug <object, VersionedWebServiceUri, string>(0L, "{0}: Found service URI {1} for email {2} in the cache.", TraceContext.Get(), versionedWebServiceUri, text);
                WebServiceUri webServiceUri = versionedWebServiceUri.Get(versionBucket);
                if (webServiceUri == null)
                {
                    RemoteServiceUriCache.AutoDiscoverTracer.TraceDebug <object, string, int>(0L, "{0}: Service URI for email {1} was not found in version bucket {2}.", TraceContext.Get(), text, versionBucket);
                }
                else if (webServiceUri.Expired(DateTime.UtcNow) && (LocalizedString.Empty.Equals(webServiceUri.AutodiscoverFailedExceptionString) || RemoteServiceUriCache.IsBadUri(webServiceUri)))
                {
                    RemoteServiceUriCache.AutoDiscoverTracer.TraceDebug <object, WebServiceUri>(0L, "{0}: URI {1} was found to be a bad URL, resetting and returning NULL.", TraceContext.Get(), webServiceUri);
                    lock (RemoteServiceUriCache.cacheLocker)
                    {
                        if (webServiceUri == versionedWebServiceUri.Get(versionBucket))
                        {
                            versionedWebServiceUri.Clear(versionBucket);
                        }
                    }
                    return(null);
                }
                return(webServiceUri);
            }
            RemoteServiceUriCache.AutoDiscoverTracer.TraceDebug <object, string>(0L, "{0}: Service URI for email {1} was not found in the cache.", TraceContext.Get(), text);
            return(null);
        }
Ejemplo n.º 4
0
 public SharingInformation(SmtpAddress requestorSmtpAddress, WebServiceUri targetSharingEpr, Uri targetAutodiscoverEpr)
 {
     this.RequestorSmtpAddress    = requestorSmtpAddress;
     this.TargetSharingEpr        = targetSharingEpr;
     this.TargetAutodiscoverEpr   = targetAutodiscoverEpr;
     this.IsFromIntraOrgConnector = true;
 }
Ejemplo n.º 5
0
        protected override void SetResult(AutoDiscoverQueryItem queryItem, WebServiceUri webServiceUri)
        {
            WebServiceUri webServiceUri2 = new WebServiceUri(webServiceUri, this.targetForestConfiguration.Credentials, queryItem.EmailAddress);

            base.AddWebServiceUriToCache(queryItem, webServiceUri2);
            queryItem.SetResult(this.GetResult(queryItem.RecipientData, webServiceUri2));
        }
Ejemplo n.º 6
0
        public static VersionedWebServiceUri Create(WebServiceUri webServiceUri, int versionBucket)
        {
            VersionedWebServiceUri versionedWebServiceUri = new VersionedWebServiceUri();

            versionedWebServiceUri.Set(webServiceUri, versionBucket);
            return(versionedWebServiceUri);
        }
Ejemplo n.º 7
0
 public AutoDiscoverRequestResult(Uri url, string redirectAddress, Uri autoDiscoverRedirectUri, WebServiceUri webServiceUri, string frontEndServerName, string backEnderServerName)
 {
     this.Url                     = url;
     this.RedirectAddress         = redirectAddress;
     this.AutoDiscoverRedirectUri = autoDiscoverRedirectUri;
     this.WebServiceUri           = webServiceUri;
     this.FrontEndServerName      = frontEndServerName;
     this.BackEndServerName       = backEnderServerName;
 }
Ejemplo n.º 8
0
        protected void AddWebServiceUriToCache(AutoDiscoverQueryItem queryItem, WebServiceUri webServiceUri)
        {
            int autodiscoverVersionBucket = this.Application.GetAutodiscoverVersionBucket(this.autodiscoverType);

            RemoteServiceUriCache.Add(queryItem.EmailAddress, webServiceUri, autodiscoverVersionBucket);
            if (queryItem.InitialEmailAddress != queryItem.EmailAddress)
            {
                RemoteServiceUriCache.Add(queryItem.InitialEmailAddress, webServiceUri, autodiscoverVersionBucket);
            }
        }
Ejemplo n.º 9
0
        public override IService CreateService(WebServiceUri webServiceUri, TargetServerVersion targetVersion, RequestType requestType)
        {
            Service service = new Service(webServiceUri);

            if (targetVersion >= TargetServerVersion.E14R3OrLater || targetVersion == TargetServerVersion.Unknown)
            {
                this.SetTimeZoneDefinitionHeader(service);
            }
            return(service);
        }
Ejemplo n.º 10
0
 internal WebServiceUri(WebServiceUri uri, NetworkCredential credentials, EmailAddress emailAddress)
 {
     this.credentials   = credentials;
     this.whenCached    = uri.WhenCached;
     this.uri           = uri.Uri;
     this.protocol      = uri.Protocol;
     this.source        = this.Source;
     this.emailAddress  = emailAddress;
     this.serverVersion = uri.ServerVersion;
     this.AutodiscoverFailedExceptionString = uri.AutodiscoverFailedExceptionString;
 }
Ejemplo n.º 11
0
 internal WebServiceUri(WebServiceUri uri, DateTime whenCached)
 {
     this.whenCached    = whenCached;
     this.credentials   = uri.credentials;
     this.uri           = uri.Uri;
     this.protocol      = uri.Protocol;
     this.source        = uri.Source;
     this.emailAddress  = uri.EmailAddress;
     this.serverVersion = uri.ServerVersion;
     this.AutodiscoverFailedExceptionString = uri.AutodiscoverFailedExceptionString;
 }
Ejemplo n.º 12
0
        protected override void SetResult(AutoDiscoverQueryItem queryItem, WebServiceUri webServiceUri)
        {
            WebServiceUri webServiceUri2 = new WebServiceUri(webServiceUri, null, queryItem.EmailAddress);

            base.AddWebServiceUriToCache(queryItem, webServiceUri2);
            AutoDiscoverResult result;

            if (!base.Application.IsVersionSupportedForExternalUser(webServiceUri.ServerVersion))
            {
                AutoDiscoverQuery.AutoDiscoverTracer.TraceError <object, int, Type>((long)this.GetHashCode(), "{0}: Remote server version {1} is considered a legacy server by {2} application for external user.", TraceContext.Get(), webServiceUri.ServerVersion, base.Application.GetType());
                result = new AutoDiscoverResult(base.Application.CreateExceptionForUnsupportedVersion(queryItem.RecipientData, webServiceUri.ServerVersion));
            }
            else
            {
                result = new AutoDiscoverResult(webServiceUri2, base.Authenticator.ProxyAuthenticator);
            }
            queryItem.SetResult(result);
        }
Ejemplo n.º 13
0
        private AutoDiscoverResult GetResult(RecipientData recipientData, WebServiceUri webServiceUri)
        {
            if (!base.Application.IsVersionSupported(webServiceUri.ServerVersion))
            {
                AutoDiscoverQuery.AutoDiscoverTracer.TraceError <object, int, Type>((long)this.GetHashCode(), "{0}: Remote server version {1} is considered a legacy server by {2} application.", TraceContext.Get(), webServiceUri.ServerVersion, base.Application.GetType());
                return(new AutoDiscoverResult(base.Application.CreateExceptionForUnsupportedVersion(recipientData, webServiceUri.ServerVersion)));
            }
            AutoDiscoverQuery.AutoDiscoverTracer.TraceDebug <object, Uri, EmailAddress>((long)this.GetHashCode(), "{0}: Found availability service {1} that can fill request for mailbox {2}", TraceContext.Get(), webServiceUri.Uri, (recipientData != null) ? recipientData.EmailAddress : null);
            SerializedSecurityContext serializedSecurityContext = null;
            InternalClientContext     internalClientContext     = base.ClientContext as InternalClientContext;

            if (this.targetForestConfiguration.IsPerUserAuthorizationSupported && internalClientContext != null)
            {
                serializedSecurityContext = internalClientContext.SerializedSecurityContext;
            }
            ProxyAuthenticator proxyAuthenticatorForAutoDiscover = this.targetForestConfiguration.GetProxyAuthenticatorForAutoDiscover(webServiceUri.Uri, serializedSecurityContext, base.ClientContext.MessageId);

            return(new AutoDiscoverResult(webServiceUri, proxyAuthenticatorForAutoDiscover));
        }
Ejemplo n.º 14
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder(1000);

            for (int i = 0; i < this.uriByVersionBuckets.Length; i++)
            {
                WebServiceUri webServiceUri = this.uriByVersionBuckets[i];
                if (webServiceUri != null)
                {
                    stringBuilder.Append(string.Concat(new object[]
                    {
                        i,
                        ":",
                        webServiceUri.ToString(),
                        ";"
                    }));
                }
            }
            return(stringBuilder.ToString());
        }
Ejemplo n.º 15
0
        internal static bool IsBadUri(WebServiceUri uri)
        {
            bool result = false;

            if (uri.Uri != null)
            {
                string text = uri.Uri.ToString();
                if (text != null)
                {
                    text = text.ToLower();
                    lock (RemoteServiceUriCache.badUrlListLocker)
                    {
                        if (RemoteServiceUriCache.badUrlList.Contains(text))
                        {
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 16
0
        internal static void Add(EmailAddress email, WebServiceUri uri, int versionBucket)
        {
            RemoteServiceUriCache.AutoDiscoverTracer.TraceDebug <object, WebServiceUri, EmailAddress>(0L, "{0}: Adding/Updating AS URI {1} for email {2} in cache.", TraceContext.Get(), uri, email);
            string        key           = email.Address.ToLower();
            WebServiceUri webServiceUri = new WebServiceUri(uri, DateTime.UtcNow);

            lock (RemoteServiceUriCache.cacheLocker)
            {
                VersionedWebServiceUri versionedWebServiceUri = (VersionedWebServiceUri)RemoteServiceUriCache.cache[key];
                if (versionedWebServiceUri == null)
                {
                    if (500000 == RemoteServiceUriCache.cache.Count)
                    {
                        RemoteServiceUriCache.cache.RemoveAt(0);
                    }
                    versionedWebServiceUri           = VersionedWebServiceUri.Create(webServiceUri, versionBucket);
                    RemoteServiceUriCache.cache[key] = versionedWebServiceUri;
                }
                else
                {
                    versionedWebServiceUri.Set(webServiceUri, versionBucket);
                }
            }
        }
Ejemplo n.º 17
0
        internal ProxyWebRequest(Application application, ClientContext clientContext, RequestType requestType, RequestLogger requestLogger, QueryList queryList, TargetServerVersion targetVersion, ProxyAuthenticator proxyAuthenticator, WebServiceUri webServiceUri, UriSource source) : base(application, clientContext, requestLogger, "ProxyWebRequest")
        {
            this.proxyAuthenticator = proxyAuthenticator;
            this.url         = webServiceUri.Uri.OriginalString;
            this.protocol    = webServiceUri.Protocol;
            this.source      = source;
            this.queryList   = queryList;
            this.requestType = requestType;
            this.service     = application.CreateService(webServiceUri, targetVersion, requestType);
            if (proxyAuthenticator.AuthenticatorType == AuthenticatorType.WSSecurity || proxyAuthenticator.AuthenticatorType == AuthenticatorType.OAuth)
            {
                if (webServiceUri.ServerVersion >= Globals.E15Version && clientContext.RequestSchemaVersion >= ExchangeVersionType.Exchange2012)
                {
                    this.service.RequestServerVersionValue = new RequestServerVersion
                    {
                        Version = ExchangeVersionType.Exchange2012
                    };
                }
                else
                {
                    this.service.RequestServerVersionValue = new RequestServerVersion
                    {
                        Version = ExchangeVersionType.Exchange2009
                    };
                }
            }
            else if (targetVersion >= TargetServerVersion.E15 && clientContext.RequestSchemaVersion == ExchangeVersionType.Exchange2012)
            {
                this.service.RequestServerVersionValue = new RequestServerVersion
                {
                    Version = ExchangeVersionType.Exchange2012
                };
            }
            this.service.CookieContainer  = new CookieContainer();
            this.service.requestTypeValue = new RequestTypeHeader();
            if (requestType == RequestType.CrossSite || requestType == RequestType.IntraSite)
            {
                if (Configuration.BypassProxyForCrossSiteRequests)
                {
                    this.service.Proxy = new WebProxy();
                }
                this.service.requestTypeValue.RequestType = ProxyRequestType.CrossSite;
                if (requestType == RequestType.CrossSite)
                {
                    this.failedCounter = PerformanceCounters.CrossSiteCalendarFailuresPerSecond;
                    this.averageProcessingTimeCounter     = PerformanceCounters.AverageCrossSiteFreeBusyRequestProcessingTime;
                    this.averageProcessingTimeCounterBase = PerformanceCounters.AverageCrossSiteFreeBusyRequestProcessingTimeBase;
                    this.requestStatisticsType            = RequestStatisticsType.CrossSiteProxy;
                }
                else
                {
                    this.failedCounter = PerformanceCounters.IntraSiteProxyFreeBusyFailuresPerSecond;
                    this.averageProcessingTimeCounter     = PerformanceCounters.AverageIntraSiteProxyFreeBusyRequestProcessingTime;
                    this.averageProcessingTimeCounterBase = PerformanceCounters.AverageIntraSiteProxyFreeBusyRequestProcessingTimeBase;
                    this.requestStatisticsType            = RequestStatisticsType.IntraSiteProxy;
                }
            }
            else
            {
                bool flag = false;
                if (Configuration.BypassProxyForCrossForestRequests)
                {
                    this.service.Proxy = new WebProxy();
                    flag = true;
                }
                this.service.requestTypeValue.RequestType = ProxyRequestType.CrossForest;
                if (requestType == RequestType.FederatedCrossForest)
                {
                    if (proxyAuthenticator.AuthenticatorType == AuthenticatorType.OAuth)
                    {
                        this.failedCounter = PerformanceCounters.FederatedByOAuthFreeBusyFailuresPerSecond;
                        this.averageProcessingTimeCounter     = PerformanceCounters.AverageFederatedByOAuthFreeBusyRequestProcessingTime;
                        this.averageProcessingTimeCounterBase = PerformanceCounters.AverageFederatedByOAuthFreeBusyRequestProcessingTimeBase;
                        this.requestStatisticsType            = RequestStatisticsType.OAuthProxy;
                        this.service.requestTypeValue         = null;
                    }
                    else
                    {
                        this.failedCounter = PerformanceCounters.FederatedFreeBusyFailuresPerSecond;
                        this.averageProcessingTimeCounter     = PerformanceCounters.AverageFederatedFreeBusyRequestProcessingTime;
                        this.averageProcessingTimeCounterBase = PerformanceCounters.AverageFederatedFreeBusyRequestProcessingTimeBase;
                        this.requestStatisticsType            = RequestStatisticsType.FederatedProxy;
                    }
                    if (!flag)
                    {
                        Server localServer = LocalServerCache.LocalServer;
                        if (localServer != null && localServer.InternetWebProxy != null)
                        {
                            ProxyWebRequest.ProxyWebRequestTracer.TraceDebug <object, Uri>((long)this.GetHashCode(), "{0}: Using custom InternetWebProxy {1}", TraceContext.Get(), localServer.InternetWebProxy);
                            this.service.Proxy = new WebProxy(localServer.InternetWebProxy);
                        }
                    }
                }
                else
                {
                    this.failedCounter = PerformanceCounters.CrossForestCalendarFailuresPerSecond;
                    this.averageProcessingTimeCounter     = PerformanceCounters.AverageCrossForestFreeBusyRequestProcessingTime;
                    this.averageProcessingTimeCounterBase = PerformanceCounters.AverageCrossForestFreeBusyRequestProcessingTimeBase;
                    this.requestStatisticsType            = RequestStatisticsType.CrossForestProxy;
                }
            }
            if (!Configuration.DisableGzipForProxyRequests)
            {
                this.service.EnableDecompression = true;
            }
            string address = this.queryList[0].Email.Address;

            ProxyWebRequest.ProxyWebRequestTracer.TraceDebug <object, string, WebServiceUri>((long)this.GetHashCode(), "{0}: Adding Anchor Mailbox Header {1} to the request to {2}.", TraceContext.Get(), address, webServiceUri);
            this.service.HttpHeaders.Add("X-AnchorMailbox", address);
            if (!string.IsNullOrEmpty(base.ClientContext.RequestId))
            {
                this.service.HttpHeaders.Add("client-request-id", base.ClientContext.RequestId);
            }
        }
Ejemplo n.º 18
0
        protected override void EndInvoke(IAsyncResult asyncResult)
        {
            WebResponse webResponse = null;

            try
            {
                AutoDiscoverRequest.FaultInjectionTracer.TraceTest(2263231805U);
                webResponse = this.request.EndGetResponse(asyncResult);
                if (webResponse != null)
                {
                    this.headers = webResponse.Headers;
                    HttpWebResponse httpWebResponse = webResponse as HttpWebResponse;
                    if (httpWebResponse != null && httpWebResponse.StatusCode == HttpStatusCode.Found)
                    {
                        string text = this.headers["Location"];
                        if (string.IsNullOrEmpty(text))
                        {
                            this.HandleException(Strings.descAutoDiscoverBadRedirectLocation(this.emailAddress.ToString(), "null"), 50492U);
                        }
                        else
                        {
                            AutoDiscoverRequest.AutoDiscoverTracer.TraceDebug <object, string, Uri>((long)this.GetHashCode(), "{0}: Got a redirect from AutoDiscover to {1}, original location was {1}.", TraceContext.Get(), text, this.targetUri);
                            Uri uri;
                            try
                            {
                                uri = new Uri(text);
                            }
                            catch (UriFormatException exception)
                            {
                                this.HandleException(Strings.descAutoDiscoverBadRedirectLocation(this.emailAddress.ToString(), text), exception);
                                return;
                            }
                            UriBuilder uriBuilder = new UriBuilder(uri);
                            uriBuilder.Scheme = (Configuration.UseSSLForAutoDiscoverRequests ? "https" : "http");
                            this.Result       = new AutoDiscoverRequestResult(this.targetUri, null, uriBuilder.Uri, null, this.headers[WellKnownHeader.XFEServer], this.headers[WellKnownHeader.XBEServer]);
                        }
                    }
                    else
                    {
                        this.responseText = this.GetResponseText(webResponse);
                        if (this.responseText == null || this.responseText.Length == 0)
                        {
                            this.HandleException(Strings.descNullAutoDiscoverResponse, new XmlException());
                        }
                        else
                        {
                            string text2 = this.FindError();
                            if (text2 != null)
                            {
                                this.HandleException(Strings.descAutoDiscoverFailedWithException(this.emailAddress.ToString(), text2), 47420U);
                            }
                            else
                            {
                                string text3 = this.FindRedirectAddress();
                                if (text3 != null)
                                {
                                    string frontEndServerName  = null;
                                    string backEnderServerName = null;
                                    if (this.headers != null)
                                    {
                                        frontEndServerName  = this.headers[WellKnownHeader.XFEServer];
                                        backEnderServerName = this.headers[WellKnownHeader.XBEServer];
                                    }
                                    this.Result = new AutoDiscoverRequestResult(this.targetUri, text3, null, null, frontEndServerName, backEnderServerName);
                                }
                                else
                                {
                                    WebServiceUri webServiceUri = this.FindWebServiceUrlForProtocol("EXPR");
                                    if (webServiceUri != null)
                                    {
                                        this.Result = new AutoDiscoverRequestResult(this.targetUri, null, null, webServiceUri, null, null);
                                    }
                                    else
                                    {
                                        webServiceUri = this.FindWebServiceUrlForProtocol("EXCH");
                                        if (webServiceUri != null)
                                        {
                                            this.Result = new AutoDiscoverRequestResult(this.targetUri, null, null, webServiceUri, null, null);
                                        }
                                        else
                                        {
                                            this.HandleException(Strings.descProtocolNotFoundInAutoDiscoverResponse("EXCH", this.targetUri.ToString()), null);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (WebException exception2)
            {
                this.HandleException(exception2);
            }
            catch (ArgumentNullException exception3)
            {
                this.HandleException(exception3);
            }
            catch (ArgumentException exception4)
            {
                this.HandleException(exception4);
            }
            catch (InvalidOperationException exception5)
            {
                this.HandleException(exception5);
            }
            catch (NotSupportedException exception6)
            {
                this.HandleException(exception6);
            }
            catch (XmlException exception7)
            {
                this.HandleException(exception7);
            }
            catch (XPathException exception8)
            {
                this.HandleException(exception8);
            }
            catch (UriFormatException exception9)
            {
                this.HandleException(exception9);
            }
            finally
            {
                if (webResponse != null)
                {
                    webResponse.Close();
                }
                this.timer.Stop();
                base.RequestLogger.Add(RequestStatistics.Create(RequestStatisticsType.AutoDiscoverRequest, this.timer.ElapsedMilliseconds, this.targetUri.ToString()));
            }
        }
 private AsyncRequest CreateRequest(QueryList queryList, ProxyAuthenticator proxyAuthenticator, WebServiceUri webServiceUri, UriSource source)
 {
     return(new ProxyWebRequest(base.Application, base.ClientContext, RequestType.FederatedCrossForest, base.RequestLogger, queryList, TargetServerVersion.Unknown, proxyAuthenticator, webServiceUri, source));
 }
Ejemplo n.º 20
0
        public SharingInformation Read(EmailAddress emailAddress, Application application)
        {
            if (this.requester == null)
            {
                SharingReader.RequestRoutingTracer.TraceError <object, string>((long)this.GetHashCode(), "{0}: Unable to get the requestor from the client context - address {1}", TraceContext.Get(), emailAddress.Address);
                return(new SharingInformation(new InvalidClientSecurityContextException()));
            }
            if (this.supportsPersonalSharing)
            {
                SharingSubscriptionData userSubscription = this.SubscriptionLoader.GetUserSubscription(emailAddress);
                if (!this.SubscriptionLoader.IsValid)
                {
                    SharingReader.RequestRoutingTracer.TraceError <object, EmailAddress, Exception>((long)this.GetHashCode(), "{0}: SubscriptionLoader cannot open mailbox {1}. Exception: {2}", TraceContext.Get(), emailAddress, this.SubscriptionLoader.HandledException);
                }
                if (userSubscription != null)
                {
                    SharingReader.RequestRoutingTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Found a personal relationship for {1}", TraceContext.Get(), emailAddress.Address);
                    if (SmtpAddress.IsValidSmtpAddress(userSubscription.SubscriberIdentity) && SmtpAddress.IsValidSmtpAddress(userSubscription.SharingKey))
                    {
                        Uri sharingUrl = userSubscription.SharingUrl;
                        return(new SharingInformation(new SmtpAddress(userSubscription.SubscriberIdentity), new SmtpAddress(userSubscription.SharingKey), new TokenTarget(userSubscription.SharerIdentityFederationUri), new WebServiceUri(sharingUrl.OriginalString, sharingUrl.Scheme, UriSource.Directory, Globals.E14SP2Version), null));
                    }
                    SharingReader.RequestRoutingTracer.TraceError <object, EmailAddress>((long)this.GetHashCode(), "{0}: The subscriber information in the mailbox is invalid for address {1}. Personal subscription can't be used.", TraceContext.Get(), emailAddress);
                }
            }
            string                   domain = emailAddress.Domain;
            OrganizationId           key    = (this.requester.OrganizationId == null) ? OrganizationId.ForestWideOrgId : this.requester.OrganizationId;
            OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(key);

            SharingReader.RequestRoutingTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Looking for an Intra-Organization connector with domain {1}.", TraceContext.Get(), domain);
            IntraOrganizationConnector intraOrganizationConnector = organizationIdCacheValue.GetIntraOrganizationConnector(domain);
            WebServiceUri targetSharingEpr;

            if (intraOrganizationConnector != null && intraOrganizationConnector.Enabled)
            {
                Uri discoveryEndpoint         = intraOrganizationConnector.DiscoveryEndpoint;
                int autodiscoverVersionBucket = application.GetAutodiscoverVersionBucket(AutodiscoverType.External);
                targetSharingEpr = RemoteServiceUriCache.Get(emailAddress, autodiscoverVersionBucket);
                return(new SharingInformation(this.requester.PrimarySmtpAddress, targetSharingEpr, discoveryEndpoint));
            }
            SharingReader.RequestRoutingTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Looking for an Organization Relationship with domain {1}.", TraceContext.Get(), domain);
            OrganizationRelationship organizationRelationship = organizationIdCacheValue.GetOrganizationRelationship(domain);

            if (organizationRelationship == null)
            {
                SharingReader.RequestRoutingTracer.TraceError <object, string, EmailAddress>((long)this.GetHashCode(), "{0}: Unable to find a organization Relationship with domain {1} for emailAddress {2}.", TraceContext.Get(), emailAddress.Domain, emailAddress);
                return(null);
            }
            if (!organizationRelationship.Enabled)
            {
                SharingReader.RequestRoutingTracer.TraceError <object, OrganizationRelationship, string>((long)this.GetHashCode(), "{0}: Organization Relationship {1} is not enabled for access to domain {2}. Ignoring this relationship.", TraceContext.Get(), organizationRelationship, emailAddress.Domain);
                return(null);
            }
            if (!application.EnabledInRelationship(organizationRelationship))
            {
                SharingReader.RequestRoutingTracer.TraceError((long)this.GetHashCode(), "{0}: Organization Relationship {1} is not enabled for application {2} to domain {3}. Ignoring this relationship.", new object[]
                {
                    TraceContext.Get(),
                    organizationRelationship,
                    application.GetType(),
                    emailAddress.Domain
                });
                return(null);
            }
            if (!organizationRelationship.IsValidForRequestDispatcher())
            {
                SharingReader.RequestRoutingTracer.TraceError((long)this.GetHashCode(), "{0}: Organization Relationship is invalid for dispatching requests, TargetApplicationUri:{1}, TargetSharingEpr:{2}, AutoDiscoverEpr:{3}.", new object[]
                {
                    TraceContext.Get(),
                    organizationRelationship.TargetApplicationUri,
                    organizationRelationship.TargetSharingEpr,
                    organizationRelationship.TargetAutodiscoverEpr
                });
                return(new SharingInformation(new InvalidOrganizationRelationshipForRequestDispatcherException(organizationRelationship.ToString())));
            }
            if (DateTime.UtcNow > this.readDeadline)
            {
                return(new SharingInformation(new TimeoutExpiredException("OrganizationRelationship lookup")));
            }
            Uri targetSharingEpr2 = organizationRelationship.TargetSharingEpr;

            if (targetSharingEpr2 == null)
            {
                int autodiscoverVersionBucket2 = application.GetAutodiscoverVersionBucket(AutodiscoverType.External);
                targetSharingEpr = RemoteServiceUriCache.Get(emailAddress, autodiscoverVersionBucket2);
            }
            else
            {
                targetSharingEpr = new WebServiceUri(targetSharingEpr2.OriginalString, targetSharingEpr2.Scheme, UriSource.Directory, Globals.E14SP2Version);
            }
            return(new SharingInformation(this.requester.PrimarySmtpAddress, SmtpAddress.Empty, organizationRelationship.GetTokenTarget(), targetSharingEpr, organizationRelationship.TargetAutodiscoverEpr));
        }
Ejemplo n.º 21
0
 protected abstract void SetResult(AutoDiscoverQueryItem queryItem, WebServiceUri webServiceUri);
Ejemplo n.º 22
0
 public SharingInformation(SmtpAddress requestorSmtpAddress, SmtpAddress sharingKey, TokenTarget tokenTarget, WebServiceUri targetSharingEpr, Uri targetAutodiscoverEpr)
 {
     this.RequestorSmtpAddress    = requestorSmtpAddress;
     this.SharingKey              = sharingKey;
     this.TokenTarget             = tokenTarget;
     this.TargetSharingEpr        = targetSharingEpr;
     this.TargetAutodiscoverEpr   = targetAutodiscoverEpr;
     this.IsFromIntraOrgConnector = false;
 }
Ejemplo n.º 23
0
 public abstract IService CreateService(WebServiceUri webServiceUri, TargetServerVersion targetVersion, RequestType requestType);
 public ExternalProxyWebRequest(Application application, ClientContext clientContext, RequestLogger requestLogger, QueryList queryList, ExternalAuthenticationRequest externalAuthenticationRequest, WebServiceUri webServiceUri, SmtpAddress sharingKey) : base(application, clientContext, RequestType.FederatedCrossForest, requestLogger, queryList)
 {
     this.externalAuthenticationRequest = externalAuthenticationRequest;
     this.webServiceUri = webServiceUri;
     this.sharingKey    = sharingKey;
 }
Ejemplo n.º 25
0
 private AsyncRequestWithQueryList CreateRequest(QueryList queryList, ProxyAuthenticator proxyAuthenticator, WebServiceUri webServiceUri, UriSource source)
 {
     return(new GetFolderAndProxyRequest(base.Application, (InternalClientContext)base.ClientContext, RequestType.CrossForest, base.RequestLogger, queryList, TargetServerVersion.Unknown, proxyAuthenticator, webServiceUri));
 }
Ejemplo n.º 26
0
 public override IService CreateService(WebServiceUri webServiceUri, TargetServerVersion targetVersion, RequestType requestType)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 27
0
 public ExternalByOAuthProxyWebRequest(Application application, ClientContext clientContext, RequestLogger requestLogger, QueryList queryList, WebServiceUri webServiceUri) : base(application, clientContext, RequestType.FederatedCrossForest, requestLogger, queryList)
 {
     this.webServiceUri = webServiceUri;
 }
Ejemplo n.º 28
0
 public AutoDiscoverResult(WebServiceUri webServiceUri, ProxyAuthenticator proxyAuthenticator)
 {
     this.ProxyAuthenticator = proxyAuthenticator;
     this.WebServiceUri      = webServiceUri;
 }
Ejemplo n.º 29
0
 public GetFolderAndProxyRequest(Application application, InternalClientContext clientContext, RequestType requestType, RequestLogger requestLogger, QueryList queryList, TargetServerVersion targetVersion, ProxyAuthenticator proxyAuthenticator, WebServiceUri webServiceUri) : base(application, clientContext, requestType, requestLogger, queryList)
 {
     this.targetVersion      = targetVersion;
     this.proxyAuthenticator = proxyAuthenticator;
     this.webServiceUri      = webServiceUri;
 }