コード例 #1
0
 public static TargetForestConfiguration FindByDomain(OrganizationId organizationId, string domainName)
 {
     if (!VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled)
     {
         TargetForestConfiguration result;
         if (!TargetForestConfigurationCache.cache.TryGetValue(domainName, out result))
         {
             TargetForestConfigurationCache.ConfigurationTracer.TraceError <object, string>(0L, "{0}: TargetForestConfiguration for domain {1} could not be found in cache", TraceContext.Get(), domainName);
             throw new AddressSpaceNotFoundException(Strings.descConfigurationInformationNotFound(domainName), 51004U);
         }
         return(result);
     }
     else
     {
         if (organizationId == null)
         {
             OrganizationId forestWideOrgId = OrganizationId.ForestWideOrgId;
         }
         OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(organizationId);
         if (organizationIdCacheValue == null)
         {
             TargetForestConfigurationCache.ConfigurationTracer.TraceError <object, OrganizationId>(0L, "{0}: Unable to find organization {1} in the OrgId cache", TraceContext.Get(), organizationId);
             throw new AddressSpaceNotFoundException(Strings.descConfigurationInformationNotFound(domainName), 64316U);
         }
         AvailabilityAddressSpace availabilityAddressSpace = organizationIdCacheValue.GetAvailabilityAddressSpace(domainName);
         if (availabilityAddressSpace != null)
         {
             TargetForestConfiguration result = TargetForestConfigurationCache.ConstructTargetForestConfiguration(availabilityAddressSpace, null);
             return(result);
         }
         TargetForestConfigurationCache.ConfigurationTracer.TraceError <object, string, OrganizationId>(0L, "{0}: TargetForestConfiguration for domain {1} could not be found in cache for organization {2}", TraceContext.Get(), domainName, organizationId);
         throw new AddressSpaceNotFoundException(Strings.descConfigurationInformationNotFound(domainName), 47932U);
     }
 }
コード例 #2
0
        internal static void Refresh()
        {
            ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "ConfigurationReader is now refreshing TargetForestConfigurationCache.");
            DateTime populateDeadline = DateTime.UtcNow + ConfigurationReader.refreshTimeout;

            TargetForestConfigurationCache.Populate(populateDeadline);
            ConfigurationReader.ConfigurationTracer.TraceDebug(0L, "ConfigurationReader is done refreshing TargetForestConfigurationCache.");
        }
コード例 #3
0
        private static TargetForestConfiguration ConstructTargetForestConfiguration(AvailabilityAddressSpace addressSpace, ScpSearch localScpSearch)
        {
            TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string>(0L, "Processing AvailabilityAddressSpace name: {0}", addressSpace.ForestName);
            NetworkCredential     networkCredential     = null;
            AutodiscoverUrlSource autodiscoverUrlSource = AutodiscoverUrlSource.Unknown;
            Uri uri = null;

            if (addressSpace.AccessMethod != AvailabilityAccessMethod.OrgWideFB && addressSpace.AccessMethod != AvailabilityAccessMethod.PerUserFB)
            {
                if (addressSpace.AccessMethod != AvailabilityAccessMethod.OrgWideFBBasic)
                {
                    goto IL_1B2;
                }
            }
            try
            {
                networkCredential = TargetForestConfigurationCache.GetCredentials(addressSpace);
            }
            catch (InvalidCrossForestCredentialsException exception)
            {
                return(new TargetForestConfiguration(addressSpace.Id.ToString(), addressSpace.ForestName, exception));
            }
            if (addressSpace.TargetAutodiscoverEpr != null)
            {
                uri = addressSpace.TargetAutodiscoverEpr;
                TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <Uri>(0L, "Retrieved Autodiscover URL {0} from address space.", uri);
                goto IL_1B2;
            }
            TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string>(0L, "Searching for SCP objects for domain {0}", addressSpace.ForestName);
            uri = localScpSearch.FindRemote(addressSpace.ForestName, networkCredential);
            if (uri != null)
            {
                TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string, Uri>(0L, "Found autodiscover URL from SCP objects for domain {0}. Url is: {1}", addressSpace.ForestName, uri);
                autodiscoverUrlSource = AutodiscoverUrlSource.SCP;
                goto IL_1B2;
            }
            TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string>(0L, "Found no suitable autodiscover URL from SCP objects for domain {0}. Trying well-known endpoints.", addressSpace.ForestName);
            uri = TargetForestConfigurationCache.DiscoverFromWellKnown(addressSpace.ForestName, networkCredential);
            if (uri != null)
            {
                TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string, Uri>(0L, "Found autodiscover URL from well-known endpoints for domain {0}. Url is: {1}", addressSpace.ForestName, uri);
                autodiscoverUrlSource = AutodiscoverUrlSource.WellKnown;
                goto IL_1B2;
            }
            TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string>(0L, "Found no suitable autodiscover URL from well-known endpoints for domain {0}. Trying SRV records from DNS.", addressSpace.ForestName);
            uri = AutoDiscoverDnsReader.Query(addressSpace.ForestName);
            if (uri != null)
            {
                TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string, Uri>(0L, "Found autodiscover URL from SRV records from DNS for domain {0}. Url is: {1}", addressSpace.ForestName, uri);
                autodiscoverUrlSource = AutodiscoverUrlSource.SRV;
                goto IL_1B2;
            }
            TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string>(0L, "Found no suitable autodiscover URL from well-known endpoint lookup for domain {0}.", addressSpace.ForestName);
            return(new TargetForestConfiguration(addressSpace.Id.ToString(), addressSpace.ForestName, new AutoDiscoverFailedException(Strings.descAvailabilityAddressSpaceFailed(addressSpace.Id.ToString()))));

IL_1B2:
            return(new TargetForestConfiguration(addressSpace.Id.ToString(), addressSpace.ForestName, addressSpace.AccessMethod, networkCredential, uri, autodiscoverUrlSource));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        internal static void Populate(DateTime populateDeadline)
        {
            if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled)
            {
                return;
            }
            Dictionary <string, TargetForestConfiguration> dictionary = new Dictionary <string, TargetForestConfiguration>(StringComparer.InvariantCultureIgnoreCase);

            AvailabilityAddressSpace[] array = TargetForestConfigurationCache.SearchAddressSpaceForEnterprise();
            if (array != null && array.Length > 0)
            {
                ScpSearch localScpSearch = ScpSearch.FindLocal();
                foreach (AvailabilityAddressSpace availabilityAddressSpace in array)
                {
                    TargetForestConfiguration targetForestConfiguration;
                    if (dictionary.TryGetValue(availabilityAddressSpace.ForestName, out targetForestConfiguration))
                    {
                        TargetForestConfigurationCache.ConfigurationTracer.TraceError <string, string, ADObjectId>(0L, "There are two or more AvailabilityAddressSpace objects in AD with same ForestName {0}. Existing is {1}. Ignoring object {2}", availabilityAddressSpace.ForestName, targetForestConfiguration.Id, availabilityAddressSpace.Id);
                        Globals.AvailabilityLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_DuplicateAvailabilityAddressSpace, null, new object[]
                        {
                            Globals.ProcessId,
                            availabilityAddressSpace.ForestName,
                            targetForestConfiguration.Id,
                            availabilityAddressSpace.Id
                        });
                    }
                    else if (availabilityAddressSpace.AccessMethod == AvailabilityAccessMethod.InternalProxy)
                    {
                        TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <string>(0L, "Ignoring AvailabilityAddressSpace with ForestName {0} because it is an internal proxy.", availabilityAddressSpace.ForestName);
                    }
                    else
                    {
                        dictionary.Add(availabilityAddressSpace.ForestName, TargetForestConfigurationCache.ConstructTargetForestConfiguration(availabilityAddressSpace, localScpSearch));
                    }
                    if (DateTime.UtcNow > populateDeadline)
                    {
                        TargetForestConfigurationCache.ConfigurationTracer.TraceError(0L, "Unable to continue populating the target forest cache. Deadline has been exceeded.");
                        break;
                    }
                }
            }
            if (dictionary.Count > 0)
            {
                TargetForestConfigurationCache.ConfigurationTracer.TraceDebug <int>(0L, "Updating to new TargetForestConfiguration cache with {0} entries", dictionary.Count);
                TargetForestConfigurationCache.cache = dictionary;
            }
        }
コード例 #6
0
        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));
        }