Beispiel #1
0
 public void InitializeServiceInstanceADStructure()
 {
     if (this.configSession.Read <SyncServiceInstance>(this.serviceInstanceObjectId) == null)
     {
         SyncServiceInstance syncServiceInstance = new SyncServiceInstance();
         syncServiceInstance.SetId(this.serviceInstanceObjectId);
         this.configSession.Save(syncServiceInstance);
     }
     if (this.configSession.Read <ADContainer>(this.divergenceContainerObjectId) == null)
     {
         ADContainer adcontainer = new ADContainer();
         adcontainer.SetId(this.divergenceContainerObjectId);
         this.configSession.Save(adcontainer);
     }
 }
Beispiel #2
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();
        }