Ejemplo n.º 1
0
        public Uri FindRemote(string domainName, NetworkCredential networkCredential)
        {
            if (this.results == null || this.results.Length == 0)
            {
                return(null);
            }
            ADServiceConnectionPoint[] orderedByPriority = ScpSearch.GetOrderedByPriority(this.results, (ADServiceConnectionPoint scp) => ScpSearch.CalculatePriorityForLocal(scp, domainName));
            List <ScpSearch.ServiceBindingInformation> serviceBindingInformation = ScpSearch.GetServiceBindingInformation(orderedByPriority);

            if (serviceBindingInformation == null)
            {
                Globals.AvailabilityLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_SCPMisconfiguredRemoteServiceBindings, null, new object[]
                {
                    Globals.ProcessId,
                    domainName
                });
                return(null);
            }
            using (List <ScpSearch.ServiceBindingInformation> .Enumerator enumerator = serviceBindingInformation.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ScpSearch.< > c__DisplayClass4 CS$ < > 8__locals2 = new ScpSearch.< > c__DisplayClass4();
                    CS$ < > 8__locals2.serviceBindingInformation = enumerator.Current;
                    ScpSearch.ConfigurationTracer.TraceDebug <string>(0L, "Creating AD remote session to {0}", CS$ < > 8__locals2.serviceBindingInformation.ServiceBinding.Host);
                    IConfigurationSession remoteSession = null;
                    Exception             ex            = ScpSearch.PerformRetryableAdOperation("remote AD session", delegate
                    {
                        remoteSession = ADSystemConfigurationSession.CreateRemoteForestSession(CS$ < > 8__locals2.serviceBindingInformation.ServiceBinding.Host, networkCredential);
                    });
Ejemplo n.º 2
0
        public static ScpSearch FindLocal()
        {
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 114, "FindLocal", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\RequestDispatch\\ScpSearch.cs");
            ScpSearch             scpSearch = ScpSearch.Find(tenantOrTopologyConfigurationSession, ScpSearch.localQueryFilter);

            if (scpSearch != null && scpSearch.Exception != null)
            {
                Globals.AvailabilityLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_SCPErrorSearchingLocalADForSCP, null, new object[]
                {
                    Globals.ProcessId,
                    scpSearch.Exception
                });
            }
            return(scpSearch);
        }
        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;
            }
        }
        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));
        }