protected override AutoDiscoverQuery CreateAutoDiscoverQuery(string domain, AutoDiscoverQueryItem[] queryItems, int redirectionDepth) { AutoDiscoverQuery.AutoDiscoverTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Search for TargetForestConfiguration for domain {1}", TraceContext.Get(), domain); TargetForestConfiguration targetForestConfiguration = TargetForestConfigurationCache.FindByDomain(base.ClientContext.OrganizationId, domain); if (targetForestConfiguration.Exception != null) { AutoDiscoverQuery.AutoDiscoverTracer.TraceError <object, string, LocalizedException>((long)this.GetHashCode(), "{0}: Found TargetForestConfiguration lookup for domain {1}, but it is in failed state due exception: {2}", TraceContext.Get(), domain, targetForestConfiguration.Exception); throw targetForestConfiguration.Exception; } QueryList queryListFromQueryItems = base.GetQueryListFromQueryItems(queryItems); return(new AutoDiscoverQueryInternal(base.Application, base.ClientContext, base.RequestLogger, targetForestConfiguration.AutoDiscoverUrl, new AutoDiscoverAuthenticator(targetForestConfiguration.GetCredentialCache(targetForestConfiguration.AutoDiscoverUrl), targetForestConfiguration.Credentials), queryItems, redirectionDepth, base.CreateAutoDiscoverRequest, targetForestConfiguration, queryListFromQueryItems)); }