示例#1
0
        protected override void WriteResult(IConfigurable dataObject)
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObject.Identity,
                dataObject
            });
            ClientAccessServer clientAccessServer = new ClientAccessServer((Server)dataObject);

            if (this.IncludeAlternateServiceAccountCredentialPassword.ToBool())
            {
                SetClientAccessServer.EnsureRunningOnTargetServer(this, (Server)dataObject);
                clientAccessServer.AlternateServiceAccountConfiguration = AlternateServiceAccountConfiguration.LoadWithPasswordsFromRegistry();
            }
            else if (this.IncludeAlternateServiceAccountCredentialStatus.ToBool())
            {
                clientAccessServer.AlternateServiceAccountConfiguration = AlternateServiceAccountConfiguration.LoadFromRegistry(clientAccessServer.Fqdn);
            }
            IConfigurable[] array = this.ConfigurationSession.Find <ADRpcHttpVirtualDirectory>((ADObjectId)clientAccessServer.Identity, QueryScope.SubTree, null, null, 1);
            clientAccessServer.OutlookAnywhereEnabled = new bool?(array.Length > 0);
            QueryFilter filter = ExchangeScpObjects.AutodiscoverUrlKeyword.Filter;

            array = this.ConfigurationSession.Find <ADServiceConnectionPoint>((ADObjectId)clientAccessServer.Identity, QueryScope.SubTree, filter, null, 2);
            if (array.Length == 1)
            {
                ADServiceConnectionPoint adserviceConnectionPoint = array[0] as ADServiceConnectionPoint;
                if (adserviceConnectionPoint.ServiceBindingInformation.Count > 0)
                {
                    clientAccessServer.AutoDiscoverServiceInternalUri = new Uri(adserviceConnectionPoint.ServiceBindingInformation[0]);
                }
                clientAccessServer.AutoDiscoverServiceGuid      = new Guid?(GetClientAccessServer.ScpUrlGuid);
                clientAccessServer.AutoDiscoverServiceCN        = Fqdn.Parse(adserviceConnectionPoint.ServiceDnsName);
                clientAccessServer.AutoDiscoverServiceClassName = adserviceConnectionPoint.ServiceClassName;
                if (adserviceConnectionPoint.Keywords != null && adserviceConnectionPoint.Keywords.Count > 1)
                {
                    MultiValuedProperty <string> multiValuedProperty = null;
                    foreach (string text in adserviceConnectionPoint.Keywords)
                    {
                        if (text.StartsWith("site=", StringComparison.OrdinalIgnoreCase))
                        {
                            if (multiValuedProperty == null)
                            {
                                multiValuedProperty = new MultiValuedProperty <string>();
                            }
                            multiValuedProperty.Add(text.Substring(5));
                        }
                    }
                    if (multiValuedProperty != null && multiValuedProperty.Count > 0)
                    {
                        clientAccessServer.AutoDiscoverSiteScope = multiValuedProperty;
                    }
                }
            }
            base.WriteResult(clientAccessServer);
            TaskLogger.LogExit();
        }
        private static string GetUrlFromScp(ITopologyConfigurationSession configSession, string domainName, Task.TaskVerboseLoggingDelegate verboseDelegate)
        {
            QueryFilter filter = ExchangeScpObjects.AutodiscoverUrlKeyword.Filter;

            IConfigurable[] array = configSession.Find <ADServiceConnectionPoint>(filter, null, true, null);
            string          empty = string.Empty;

            if (array != null && array.Length > 0)
            {
                string item = "Domain=" + domainName;
                ADServiceConnectionPoint adserviceConnectionPoint = null;
                foreach (IConfigurable configurable in array)
                {
                    ADServiceConnectionPoint adserviceConnectionPoint2 = configurable as ADServiceConnectionPoint;
                    if (adserviceConnectionPoint2.Keywords.Contains("67661d7F-8FC4-4fa7-BFAC-E1D7794C1F68") && AutoDiscoverHelper.IsE14OrLater(configSession, adserviceConnectionPoint2))
                    {
                        verboseDelegate(Strings.TowsFoundScpByDomain(adserviceConnectionPoint2.Identity.ToString(), domainName, adserviceConnectionPoint2.ServiceBindingInformation[0]));
                        if (adserviceConnectionPoint2.Keywords.Contains(item))
                        {
                            return(adserviceConnectionPoint2.ServiceBindingInformation[0]);
                        }
                    }
                    else if (adserviceConnectionPoint2.Keywords.Count == 1 && adserviceConnectionPoint == null)
                    {
                        adserviceConnectionPoint = adserviceConnectionPoint2;
                    }
                }
                string siteName = NativeHelpers.GetSiteName(false);
                string item2    = "Site=" + siteName;
                ADServiceConnectionPoint adserviceConnectionPoint3 = null;
                foreach (IConfigurable configurable2 in array)
                {
                    ADServiceConnectionPoint adserviceConnectionPoint4 = configurable2 as ADServiceConnectionPoint;
                    if (adserviceConnectionPoint4.Keywords.Contains("77378F46-2C66-4aa9-A6A6-3E7A48B19596") && adserviceConnectionPoint4.Keywords.Contains(item2) && AutoDiscoverHelper.IsE14OrLater(configSession, adserviceConnectionPoint4))
                    {
                        verboseDelegate(Strings.TowsFoundScpBySite(adserviceConnectionPoint4.Identity.ToString(), siteName, adserviceConnectionPoint4.ServiceBindingInformation[0]));
                        return(adserviceConnectionPoint4.ServiceBindingInformation[0]);
                    }
                    if (adserviceConnectionPoint3 == null)
                    {
                        adserviceConnectionPoint3 = adserviceConnectionPoint4;
                    }
                }
                if (adserviceConnectionPoint3 != null)
                {
                    return(adserviceConnectionPoint3.ServiceBindingInformation[0]);
                }
                if (adserviceConnectionPoint != null)
                {
                    return(adserviceConnectionPoint.ServiceBindingInformation[0]);
                }
            }
            return(null);
        }
示例#3
0
        protected override TokenTarget CreateOnCacheMiss(string key, ref bool shouldAdd)
        {
            TargetUriViaSCP.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TargetUriViaSCP: cache miss for: {0}", key);
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                ExchangeScpObjects.DomainToApplicationUriKeyword.Filter,
                new TextFilter(ADServiceConnectionPointSchema.Keywords, "Domain=" + key, MatchOptions.FullString, MatchFlags.IgnoreCase)
            });
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 76, "CreateOnCacheMiss", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\Authentication\\TargetUriViaSCP.cs");

            ADServiceConnectionPoint[] array = topologyConfigurationSession.Find <ADServiceConnectionPoint>(topologyConfigurationSession.GetAutoDiscoverGlobalContainerId(), QueryScope.SubTree, filter, null, 0);
            if (array == null || array.Length == 0)
            {
                TargetUriViaSCP.Tracer.TraceError <string>((long)this.GetHashCode(), "TargetUriViaSCP: found no SCP object for domain: {0}", key);
                return(null);
            }
            if (array.Length > 1)
            {
                TargetUriViaSCP.Tracer.TraceError <string>((long)this.GetHashCode(), "TargetUriViaSCP: found more than one SCP object for: {0}", key);
                return(null);
            }
            ADServiceConnectionPoint adserviceConnectionPoint = array[0];

            if (adserviceConnectionPoint.ServiceBindingInformation == null || adserviceConnectionPoint.ServiceBindingInformation.Count == 0)
            {
                TargetUriViaSCP.Tracer.TraceError <ADObjectId>((long)this.GetHashCode(), "TargetUriViaSCP: found no value in ServiceBindingInformation in: {0}", adserviceConnectionPoint.Id);
                return(null);
            }
            if (adserviceConnectionPoint.ServiceBindingInformation.Count > 1)
            {
                TargetUriViaSCP.Tracer.TraceError <ADObjectId>((long)this.GetHashCode(), "TargetUriViaSCP: found more than one value in ServiceBindingInformation in: {0}", adserviceConnectionPoint.Id);
                return(null);
            }
            string text = adserviceConnectionPoint.ServiceBindingInformation[0];

            if (!Uri.IsWellFormedUriString(text, UriKind.Absolute))
            {
                TargetUriViaSCP.Tracer.TraceError <string>((long)this.GetHashCode(), "TargetUriViaSCP: value in ServiceBindingInformation is not well-formed URI: {0}", text);
                return(null);
            }
            TargetUriViaSCP.Tracer.TraceError <string, string>((long)this.GetHashCode(), "TargetUriViaSCP: ApplicationUri for domain {0} is {1}", key, text);
            return(new TokenTarget(new Uri(text, UriKind.Absolute)));
        }
        private static bool IsE14OrLater(ITopologyConfigurationSession configSession, ADServiceConnectionPoint scp)
        {
            Server server = configSession.FindServerByName(scp.ServiceDnsName);

            return(server != null && server.IsE14OrLater);
        }
示例#5
0
 // Token: 0x06000868 RID: 2152 RVA: 0x0001E538 File Offset: 0x0001C738
 public ADServiceConnectionPointIdParameter(ADServiceConnectionPoint connectionPoint) : base(connectionPoint.Id)
 {
 }
示例#6
0
        protected sealed override void InternalProcessRecord()
        {
            TaskLogger.LogEnter(new object[]
            {
                this.DataObject
            });
            if (this.DataObject.MajorVersion != LocalServer.GetServer().MajorVersion)
            {
                base.WriteError(new CannotModifyCrossVersionObjectException(this.DataObject.Id.DistinguishedName), ErrorCategory.InvalidOperation, null);
                return;
            }
            ClientAccessServer clientAccessServer = new ClientAccessServer(this.DataObject);

            if (base.Fields.IsModified("ClientAccessArray"))
            {
                ClientAccessArray clientAccessArrayFromIdParameter = this.GetClientAccessArrayFromIdParameter();
                if (clientAccessArrayFromIdParameter == null)
                {
                    clientAccessServer.ClientAccessArray = null;
                }
                else
                {
                    if (clientAccessArrayFromIdParameter.IsPriorTo15ExchangeObjectVersion)
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorCannotSetToOldClientAccessArray(clientAccessArrayFromIdParameter.ExchangeVersion.ToString(), ClientAccessArray.MinimumSupportedExchangeObjectVersion.ToString())), ErrorCategory.InvalidOperation, this.Identity);
                        return;
                    }
                    clientAccessServer.ClientAccessArray = (ADObjectId)clientAccessArrayFromIdParameter.Identity;
                }
            }
            bool flag = false;
            ADServiceConnectionPoint adserviceConnectionPoint = null;
            ADObjectId childId = clientAccessServer.Id.GetChildId("Protocols").GetChildId("Autodiscover").GetChildId(clientAccessServer.Name);

            if (base.Fields.IsModified("AutoDiscoverServiceInternalUri") && this.AutoDiscoverServiceInternalUri == null && base.Fields.IsModified("AutoDiscoverSiteScope") && this.AutoDiscoverSiteScope == null)
            {
                adserviceConnectionPoint = new ADServiceConnectionPoint();
                adserviceConnectionPoint.SetId(childId);
                base.DataSession.Delete(adserviceConnectionPoint);
                ADObjectId  parent      = adserviceConnectionPoint.Id.Parent;
                ADContainer adcontainer = new ADContainer();
                adcontainer.SetId(parent);
                base.DataSession.Delete(adcontainer);
                flag = true;
            }
            else
            {
                adserviceConnectionPoint = ((IConfigurationSession)base.DataSession).Read <ADServiceConnectionPoint>(childId);
                if (adserviceConnectionPoint == null)
                {
                    adserviceConnectionPoint = new ADServiceConnectionPoint();
                    adserviceConnectionPoint.SetId(childId);
                    if (!base.Fields.IsModified("AutoDiscoverServiceInternalUri"))
                    {
                        string text = ComputerInformation.DnsFullyQualifiedDomainName;
                        if (string.IsNullOrEmpty(text))
                        {
                            text = ComputerInformation.DnsPhysicalHostName;
                        }
                        adserviceConnectionPoint.ServiceBindingInformation.Add("https://" + text + "/Autodiscover/Autodiscover.xml");
                    }
                    if (!base.Fields.IsModified("AutoDiscoverSiteScope"))
                    {
                        adserviceConnectionPoint.Keywords.Add("77378F46-2C66-4aa9-A6A6-3E7A48B19596");
                        string siteName = NativeHelpers.GetSiteName(false);
                        if (!string.IsNullOrEmpty(siteName))
                        {
                            adserviceConnectionPoint.Keywords.Add("Site=" + siteName);
                        }
                    }
                    adserviceConnectionPoint.ServiceDnsName   = ComputerInformation.DnsPhysicalHostName;
                    adserviceConnectionPoint.ServiceClassName = "ms-Exchange-AutoDiscover-Service";
                    flag = true;
                }
                if (base.Fields.IsModified("AutoDiscoverServiceInternalUri"))
                {
                    adserviceConnectionPoint.ServiceBindingInformation.Clear();
                    if (this.AutoDiscoverServiceInternalUri != null)
                    {
                        adserviceConnectionPoint.ServiceBindingInformation.Add(this.AutoDiscoverServiceInternalUri.ToString());
                    }
                    flag = true;
                }
                if (base.Fields.IsModified("AutoDiscoverSiteScope"))
                {
                    adserviceConnectionPoint.Keywords.Clear();
                    adserviceConnectionPoint.Keywords.Add("77378F46-2C66-4aa9-A6A6-3E7A48B19596");
                    if (this.AutoDiscoverSiteScope != null)
                    {
                        foreach (string str in this.AutoDiscoverSiteScope)
                        {
                            adserviceConnectionPoint.Keywords.Add("Site=" + str);
                        }
                    }
                    flag = true;
                }
                if (flag)
                {
                    ADObjectId parent2 = adserviceConnectionPoint.Id.Parent;
                    if (((IConfigurationSession)base.DataSession).Read <ADContainer>(parent2) == null)
                    {
                        ADContainer adcontainer2 = new ADContainer();
                        adcontainer2.SetId(parent2);
                        base.DataSession.Save(adcontainer2);
                    }
                    base.DataSession.Save(adserviceConnectionPoint);
                }
            }
            bool flag2 = false;

            if (this.CleanUpInvalidAlternateServiceAccountCredentials.ToBool() && this.alternateServiceAccountCredentialsToRemove.Count > 0)
            {
                foreach (AlternateServiceAccountCredential credential in this.alternateServiceAccountCredentialsToRemove)
                {
                    this.alternateServiceAccountConfiguration.RemoveCredential(credential);
                }
                flag2 = true;
            }
            if (this.RemoveAlternateServiceAccountCredentials.ToBool())
            {
                flag2 = this.alternateServiceAccountConfiguration.RemoveAllCredentials();
                flag2 = true;
            }
            if (this.AlternateServiceAccountCredential != null)
            {
                for (int i = this.AlternateServiceAccountCredential.Length - 1; i >= 0; i--)
                {
                    this.alternateServiceAccountConfiguration.AddCredential(this.AlternateServiceAccountCredential[i]);
                    flag2 = true;
                }
            }
            if (this.DataObject.ObjectState != ObjectState.Unchanged)
            {
                base.InternalProcessRecord();
            }
            else if (!flag && !flag2)
            {
                this.WriteWarning(Strings.WarningForceMessage);
            }
            TaskLogger.LogExit();
        }