private static Uri DiscoverFromWellKnown(string domainName, NetworkCredential networkCredential) { RequestLogger requestLogger = new RequestLogger(); EmailAddress emailAddress = new EmailAddress(null, "01B62C6D-4324-448f-9884-5FEC6D18A7E2@" + domainName); DateTime deadline = DateTime.UtcNow + Configuration.WebRequestTimeoutInSeconds; UriBuilder uriBuilder = new UriBuilder(); uriBuilder.Path = "/autodiscover/autodiscover.xml"; uriBuilder.Scheme = Uri.UriSchemeHttps; TargetForestConfigurationCache.PingAutoDiscover[] array = new TargetForestConfigurationCache.PingAutoDiscover[TargetForestConfigurationCache.UriHostFormatStrings.Length]; for (int i = 0; i < TargetForestConfigurationCache.UriHostFormatStrings.Length; i++) { uriBuilder.Host = string.Format(TargetForestConfigurationCache.UriHostFormatStrings[i], domainName); array[i] = new TargetForestConfigurationCache.PingAutoDiscover(uriBuilder.Uri, emailAddress, networkCredential, deadline, requestLogger); } AsyncTaskParallel asyncTaskParallel = new AsyncTaskParallel(array); foreach (TargetForestConfigurationCache.PingAutoDiscover pingAutoDiscover in array) { pingAutoDiscover.Parent = asyncTaskParallel; } asyncTaskParallel.Invoke(deadline); foreach (TargetForestConfigurationCache.PingAutoDiscover pingAutoDiscover2 in array) { if (pingAutoDiscover2.Valid) { return(pingAutoDiscover2.Url); } } return(null); }
public void Log(RequestLogger requestLogger) { if (requestLogger == null) { throw new ArgumentNullException("requestLogger"); } if (this.info == RequestStatistics.Info.TimeTaken) { requestLogger.AppendToLog <long>(this.Tag.Name, this.TimeTaken); return; } if (this.info == RequestStatistics.Info.RequestCount) { requestLogger.AppendToLog <int>(this.Tag.Name, this.RequestCount); return; } if ((this.info & RequestStatistics.Info.TimeTaken) != (RequestStatistics.Info) 0) { requestLogger.AppendToLog <long>(this.Tag.Name + ".T", this.TimeTaken); } if ((this.info & RequestStatistics.Info.RequestCount) != (RequestStatistics.Info) 0) { requestLogger.AppendToLog <int>(this.Tag.Name + ".R", this.RequestCount); } if ((this.info & RequestStatistics.Info.Destination) != (RequestStatistics.Info) 0) { requestLogger.AppendToLog <string>(this.Tag.Name + ".D", this.Destination); } }
public void LogStatistics(RequestLogger requestLogger) { if (this.intraSiteQueryCount > 0) { requestLogger.AppendToLog <int>("local", this.intraSiteQueryCount); } if (this.intraSiteProxyQueryCount > 0) { requestLogger.AppendToLog <int>("intrasiteproxy", this.intraSiteProxyQueryCount); } if (this.crossSiteQueryCount > 0) { requestLogger.AppendToLog <int>("x-site", this.crossSiteQueryCount); } if (this.crossForestQueryCount > 0) { requestLogger.AppendToLog <int>("x-forest", this.crossForestQueryCount); } if (this.federatedCrossForestQueryCount > 0) { requestLogger.AppendToLog <int>("federatedxforest", this.federatedCrossForestQueryCount); } if (this.publicFolderQueryCount > 0) { requestLogger.AppendToLog <int>("PF", this.publicFolderQueryCount); } }
public ExternalAuthenticationRequest(RequestLogger requestLogger, ExternalAuthentication externalAuthentication, ADUser user, SmtpAddress emailAddress, TokenTarget target, Offer offer) { this.requestLogger = requestLogger; this.user = user; this.emailAddress = emailAddress; this.target = target; this.offer = offer; this.securityTokenService = externalAuthentication.GetSecurityTokenService(user.OrganizationId); }
public void LogThreadsUsage(RequestLogger requestLogger) { int value; int value2; ThreadPool.GetAvailableThreads(out value, out value2); requestLogger.AppendToLog <int>("Threads.Worker.Available", value); requestLogger.AppendToLog <int>("Threads.Worker.InUse", this.Worker.Count); requestLogger.AppendToLog <int>("Threads.IO.Available", value2); requestLogger.AppendToLog <int>("Threads.IO.InUse", this.IOCompletion.Count); }
public LocalRequest(Application application, ClientContext clientContext, RequestLogger requestLogger, QueryList queryList, DateTime deadline) : base(application, LocalRequest.CloneIfInternalContext(clientContext), RequestType.Local, requestLogger, queryList) { this.localQuery = application.CreateLocalQuery(base.ClientContext, deadline); int num = LimitedThreadPool.MaximumThreads / 2; if (num <= 0) { num = 1; } LocalRequest.RequestRoutingTracer.TraceDebug <object, int>((long)this.GetHashCode(), "{0}: Initializing LimitedThreadPool with {1} threads to process mailboxes", TraceContext.Get(), num); this.threadPool = new LimitedThreadPool(num, new WaitCallback(this.Execute)); }
internal static void Start(RequestLogger requestLogger) { if (ConfigurationReader.timer == null) { lock (ConfigurationReader.locker) { if (ConfigurationReader.timer == null) { ConfigurationReader.Initialize(requestLogger); using (ActivityContext.SuppressThreadScope()) { ConfigurationReader.timer = new Timer(new TimerCallback(ConfigurationReader.RefreshTimer), null, ConfigurationReader.dueTime, ConfigurationReader.refreshInterval); } ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "Timer object for refreshing configuration has been created successfully."); } } } }
public static OAuthCredentials Create(InternalClientContext clientContext, RequestLogger requestLogger) { ArgumentValidator.ThrowIfNull("clientContext", clientContext); OrganizationId organizationId = clientContext.OrganizationId; ADUser aduser = clientContext.ADUser; string text = FaultInjection.TraceTest <string>((FaultInjection.LIDs) 2743479613U); if (!string.IsNullOrEmpty(text)) { SmtpAddress smtpAddress = SmtpAddress.Parse(text); IRecipientSession recipientSession = DirectorySessionFactory.Default.CreateTenantRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromTenantAcceptedDomain(smtpAddress.Domain), 68, "Create", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\RequestDispatch\\OAuthCredentialsFactory.cs"); aduser = (recipientSession.FindByProxyAddress(ProxyAddress.Parse(text)) as ADUser); organizationId = aduser.OrganizationId; } OAuthCredentials oauthCredentialsForAppActAsToken = OAuthCredentials.GetOAuthCredentialsForAppActAsToken(organizationId, aduser, null); OAuthCredentialsFactory.SetCredentialsProperties(oauthCredentialsForAppActAsToken, clientContext, requestLogger); return(oauthCredentialsForAppActAsToken); }
private static void Initialize(RequestLogger requestLogger) { requestLogger.CaptureRequestStage("CRInit"); ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "ConfigurationReader is now initializing NetworkServiceImpersonator."); NetworkServiceImpersonator.Initialize(); requestLogger.CaptureRequestStage("CRNSInit"); ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "ConfigurationReader is done initializing NetworkServiceImpersonator."); ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "ConfigurationReader is now initializing Dns for AS discovery."); AutoDiscoverDnsReader.Initialize(); requestLogger.CaptureRequestStage("CRAD"); ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "ConfigurationReader is done initializing Dns for AS discovery."); DateTime populateDeadline = DateTime.UtcNow + ConfigurationReader.initializeTimeInterval; ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "ConfigurationReader is now refreshing TargetForestConfigurationCache."); TargetForestConfigurationCache.Populate(populateDeadline); ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "ConfigurationReader is done refreshing TargetForestConfigurationCache."); requestLogger.CaptureRequestStage("CRTC"); ConfigurationReader.ASFaultInjectionTracer.RegisterExceptionInjectionCallback(new ExceptionInjectionCallback(FaultInjection.Callback)); ConfigurationReader.RequestDispatchFaultInjectionTracer.RegisterExceptionInjectionCallback(new ExceptionInjectionCallback(FaultInjection.Callback)); }
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; }
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); } }
public GetFolderRequest(Application application, InternalClientContext clientContext, RequestType requestType, RequestLogger requestLogger, BaseQuery query, Uri url) : base(application, clientContext, requestLogger, "GetFolderRequest") { if (query.RecipientData == null || query.RecipientData.AssociatedFolderId == null) { throw new InvalidOperationException("Unable to get associated folder id"); } this.query = query; this.url = url.OriginalString; this.binding = new ExchangeServiceBinding(Globals.CertificateValidationComponentId, new RemoteCertificateValidationCallback(CertificateErrorHandler.CertValidationCallback)); this.binding.Url = url.OriginalString; this.binding.RequestServerVersionValue = new RequestServerVersion(); this.binding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1; Server localServer = LocalServerCache.LocalServer; if (localServer != null && localServer.InternetWebProxy != null) { GetFolderRequest.GetFolderRequestTracer.TraceDebug <GetFolderRequest, Uri>((long)this.GetHashCode(), "{0}: Using custom InternetWebProxy {1}", this, localServer.InternetWebProxy); this.binding.Proxy = new WebProxy(localServer.InternetWebProxy); } }
public static AutoDiscoverRequestOperation CreateForCrossForest(Application application, ClientContext clientContext, RequestLogger requestLogger, Uri targetUri, AutoDiscoverAuthenticator authenticator, EmailAddress[] emailAddresses, UriSource uriSource, AutodiscoverType autodiscoverType) { return(new AutoDiscoverRequestByDomain(application, clientContext, requestLogger, new AutoDiscoverAuthenticator(ProxyAuthenticator.CreateForSoap(clientContext.MessageId)), targetUri, emailAddresses, autodiscoverType)); }
public static AutoDiscoverRequestOperation CreateForExternal(Application application, ClientContext clientContext, RequestLogger requestLogger, Uri targetUri, AutoDiscoverAuthenticator authenticator, EmailAddress[] emailAddresses, UriSource uriSource, AutodiscoverType autodiscoverType) { return(new AutoDiscoverRequestByDomain(application, clientContext, requestLogger, authenticator, targetUri, emailAddresses, autodiscoverType)); }
public SoapAutoDiscoverRequest(Application application, ClientContext clientContext, RequestLogger requestLogger, string label, AutoDiscoverAuthenticator authenticator, Uri targetUri, EmailAddress[] emailAddresses, AutodiscoverType autodiscoverType) : base(application, clientContext, requestLogger, label) { this.authenticator = authenticator; this.TargetUri = SoapAutoDiscoverRequest.FixTargetUri(targetUri); this.EmailAddresses = emailAddresses; this.AutodiscoverType = autodiscoverType; }
protected AsyncRequestWithQueryList(Application application, ClientContext clientContext, RequestType requestType, RequestLogger requestLogger, QueryList queryList) : base(application, clientContext, requestLogger) { this.QueryList = queryList; this.RequestType = requestType; }
internal AutoDiscoverRequest(Application application, ClientContext clientContext, RequestLogger requestLogger, Uri targetUri, EmailAddress emailAddress, ICredentials credentialsForDiscovery, UriSource uriSource) : base(application, clientContext, requestLogger, "AutoDiscoverRequest") { this.uriSource = uriSource; this.emailAddress = emailAddress; this.credentialsForDiscovery = credentialsForDiscovery; this.targetUri = targetUri; CertificateValidationManager.RegisterCallback(Globals.CertificateValidationComponentId, new RemoteCertificateValidationCallback(CertificateErrorHandler.CertValidationCallback)); }
protected AutoDiscoverQuery(Application application, ClientContext clientContext, RequestLogger requestLogger, Uri autoDiscoverUrl, AutoDiscoverAuthenticator authenticator, AutoDiscoverQueryItem[] queryItems, int redirectionDepth, CreateAutoDiscoverRequestDelegate createAutoDiscoverRequest, AutodiscoverType autodiscoverType, QueryList queryList) { this.application = application; this.clientContext = clientContext; this.requestLogger = requestLogger; this.autoDiscoverUrl = autoDiscoverUrl; this.authenticator = authenticator; this.queryItems = queryItems; this.redirectionDepth = redirectionDepth; this.createAutoDiscoverRequest = createAutoDiscoverRequest; this.autodiscoverType = autodiscoverType; this.queryList = queryList; this.emailAddresses = new EmailAddress[queryItems.Length]; for (int i = 0; i < queryItems.Length; i++) { this.emailAddresses[i] = queryItems[i].EmailAddress; } StringBuilder stringBuilder = new StringBuilder(200); foreach (AutoDiscoverQueryItem autoDiscoverQueryItem in this.queryItems) { if (stringBuilder.Length > 0) { stringBuilder.Append(","); } stringBuilder.Append(autoDiscoverQueryItem.EmailAddress.ToString()); } this.emailAddressesString = stringBuilder.ToString(); AutoDiscoverQuery.AutoDiscoverTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Created AutoDiscoverQuery for {1}", TraceContext.Get(), this.emailAddressesString); }
public ExternalProxyWebRequestWithAutoDiscover(Application application, InternalClientContext clientContext, RequestLogger requestLogger, QueryList queryList, ExternalAuthenticationRequest autoDiscoverExternalAuthenticationRequest, ExternalAuthenticationRequest webProxyExternalAuthenticationRequest, Uri autoDiscoverUrl, SmtpAddress sharingKey, CreateAutoDiscoverRequestDelegate createAutoDiscoverRequest) : base(application, clientContext, RequestType.FederatedCrossForest, requestLogger, queryList) { this.autoDiscoverExternalAuthenticationRequest = autoDiscoverExternalAuthenticationRequest; this.webProxyExternalAuthenticationRequest = webProxyExternalAuthenticationRequest; this.autoDiscoverUrl = autoDiscoverUrl; this.sharingKey = sharingKey; this.createAutoDiscoverRequest = createAutoDiscoverRequest; }
public RequestDispatcher(RequestLogger requestLogger) { this.requestLogger = requestLogger; }
public GetFolderAndProxyRequestWithAutoDiscover(Application application, InternalClientContext clientContext, RequestLogger requestLogger, QueryList queryList, TargetForestConfiguration targetForestConfiguration) : base(application, clientContext, RequestType.CrossForest, requestLogger, queryList) { this.targetForestConfiguration = targetForestConfiguration; }
public ProxyWebRequestWithAutoDiscover(Application application, ClientContext clientContext, RequestLogger requestLogger, QueryList queryList, TargetForestConfiguration targetForestConfiguration, CreateAutoDiscoverRequestDelegate createAutoDiscoverRequest) : base(application, clientContext, RequestType.CrossForest, requestLogger, queryList) { this.targetForestConfiguration = targetForestConfiguration; this.createAutoDiscoverRequest = createAutoDiscoverRequest; }
protected AsyncRequest(Application application, ClientContext clientContext, RequestLogger requestLogger) { this.Application = application; this.ClientContext = clientContext; this.RequestLogger = requestLogger; }
internal UserSoapAutoDiscoverRequest(Application application, ClientContext clientContext, RequestType requestType, RequestLogger requestLogger, AutoDiscoverAuthenticator authenticator, Uri targetUri, EmailAddress[] emailAddresses, AutodiscoverType autodiscoverType) : base(application, clientContext, requestLogger, "UserSoapAutoDiscoverRequest", authenticator, targetUri, emailAddresses, autodiscoverType) { }
private AutoDiscoverRequestByDomain(Application application, ClientContext clientContext, RequestLogger requestLogger, AutoDiscoverAuthenticator authenticator, Uri targetUri, EmailAddress[] emailAddresses, AutodiscoverType autodiscoverType) : base(application, clientContext, requestLogger, targetUri, authenticator, emailAddresses, autodiscoverType) { }
public override AsyncRequestWithQueryList CreateExternalByOAuthAsyncRequestWithAutoDiscover(InternalClientContext clientContext, RequestLogger requestLogger, QueryList queryList, Uri autoDiscoverUrl) { return(new ExternalByOAuthProxyWebRequestWithAutoDiscover(this, clientContext, requestLogger, queryList, autoDiscoverUrl, new CreateAutoDiscoverRequestDelegate(AutoDiscoverRequestByUser.Create))); }
public AsyncWebRequest(Application application, ClientContext clientContext, RequestLogger requestLogger, string traceLabel) : base(application, clientContext, requestLogger) { this.traceLabel = traceLabel; }
public PingAutoDiscover(Uri url, EmailAddress emailAddress, NetworkCredential networkCredential, DateTime deadline, RequestLogger requestLogger) { this.url = url; this.emailAddress = emailAddress; this.networkCredential = networkCredential; this.deadline = deadline; this.requestLogger = requestLogger; }
internal AutoDiscoverRequestOperation(Application application, ClientContext clientContext, RequestLogger requestLogger, Uri targetUri, AutoDiscoverAuthenticator authenticator, EmailAddress[] emailAddresses, AutodiscoverType autodiscoverType) : base(application, clientContext, requestLogger) { this.TargetUri = targetUri; this.Authenticator = authenticator; this.EmailAddresses = emailAddresses; this.AutodiscoverType = autodiscoverType; }
private AutoDiscoverRequestXmlByUser(Application application, ClientContext clientContext, RequestLogger requestLogger, Uri targetUri, AutoDiscoverAuthenticator authenticator, EmailAddress[] emailAddresses, UriSource uriSource, AutodiscoverType autodiscoverType) : base(application, clientContext, requestLogger, targetUri, authenticator, emailAddresses, autodiscoverType) { this.uriSource = uriSource; }