Exemple #1
0
 private void Link()
 {
     try
     {
         ADUser     aduser     = this.FindRmsSharedIdentityUser();
         ADComputer adcomputer = this.FindComputer();
         if (!aduser.RMSComputerAccounts.Contains(adcomputer.Id))
         {
             base.WriteVerbose(Strings.RmsSharedIdentityBeingLinkedToComputer(aduser.DistinguishedName, aduser.OriginatingServer, adcomputer.DistinguishedName, adcomputer.OriginatingServer));
             aduser.RMSComputerAccounts.Add(adcomputer.Id);
             this.writeableRecipientSession.LinkResolutionServer = adcomputer.OriginatingServer;
             this.writeableRecipientSession.Save(aduser);
         }
     }
     catch (RmsSharedIdentityTooManyUsersException exception)
     {
         this.WriteError(exception, ErrorCategory.InvalidData, null, true);
     }
     catch (RmsSharedIdentityUserNotFoundException exception2)
     {
         this.WriteError(exception2, ErrorCategory.InvalidData, null, true);
     }
     catch (RmsSharedIdentityLocalComputerNotFoundException exception3)
     {
         this.WriteError(exception3, ErrorCategory.InvalidData, null, true);
     }
     catch (RmsSharedIdentityComputerNotFoundException exception4)
     {
         this.WriteError(exception4, ErrorCategory.InvalidData, null, true);
     }
     catch (ADObjectEntryAlreadyExistsException)
     {
     }
 }
Exemple #2
0
        public IADResult <ADComputer> DeleteComputer(DomainInfo info, string name)
        {
            var result = new ADResult <ADComputer>();

            if (string.IsNullOrWhiteSpace(name))
            {
                return(result.ToReturn("computer Name is NullOrWhiteSpace"));
            }

            try
            {
                using var context = new PrincipalContext(ContextType.Domain, info.DomainName, info.ContainerString, info.AdminName, info.AdminPassword);
                using ComputerPrincipal comPrin = new ComputerPrincipal(context);
                comPrin.Name = name;

                using var com = (new PrincipalSearcher(comPrin).FindOne()) as ComputerPrincipal;

                if (com != null)
                {
                    var copy = new ADComputer().NewCopy(com);

                    com.Delete();

                    return(result.ToReturn(copy));
                }
                return(result.ToReturn("Cannot find the computer in " + context.Name));
            }
            catch (Exception ex)
            {
                return(result.ToReturn(ex.Message));
            }
        }
Exemple #3
0
 private void AssignWitnessServerFqdn()
 {
     if (this.WitnessServer.isFqdn)
     {
         this.m_witnessServerFqdn = this.WitnessServer.Fqdn;
         return;
     }
     try
     {
         ITopologyConfigurationSession topologyConfigurationSession = this.CreateRootSession();
         ADComputer adcomputer = topologyConfigurationSession.FindComputerByHostName(this.WitnessServer.HostName);
         if (adcomputer == null || string.IsNullOrEmpty(adcomputer.DnsHostName))
         {
             throw new ArgumentException(Strings.ErrorUnableToFindFqdnForHost(this.WitnessServer.HostName), "FileShareWitnessServerName");
         }
         this.m_witnessServerFqdn = adcomputer.DnsHostName;
     }
     catch (ADTransientException ex)
     {
         throw new ErrorUnableToFindFqdnForHostADErrorException(this.WitnessServer.HostName, ex.Message);
     }
     catch (ADExternalException ex2)
     {
         throw new ErrorUnableToFindFqdnForHostADErrorException(this.WitnessServer.HostName, ex2.Message);
     }
     catch (ADOperationException ex3)
     {
         throw new ErrorUnableToFindFqdnForHostADErrorException(this.WitnessServer.HostName, ex3.Message);
     }
 }
Exemple #4
0
 public static ADComputerWrapper CreateWrapper(ADComputer adComputer)
 {
     if (adComputer == null)
     {
         return(null);
     }
     return(new ADComputerWrapper(adComputer));
 }
 private ADAllowableInputObject(ADComputer adComp)
 {
     this.LoginName = adComp.SamAccountName;
     //this.IsADAccount = true;
     this.FromADObject      = true;
     this.Type              = LoginType.WindowsUser;
     this.DistinguishedName = adComp.DistinguishedName;
 }
        public static DagNetworkConfiguration GetDagNetworkConfig(DatabaseAvailabilityGroup dag)
        {
            DagNetworkConfiguration dagNetworkConfiguration = null;

            if (dag.Servers.Count == 0)
            {
                return(null);
            }
            Exception ex = null;
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 85, "GetDagNetworkConfig", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Cluster\\DagNetworkClientRpc.cs");

            topologyConfigurationSession.UseConfigNC      = false;
            topologyConfigurationSession.UseGlobalCatalog = true;
            foreach (ADObjectId adobjectId in dag.Servers)
            {
                try
                {
                    ADComputer adcomputer = topologyConfigurationSession.FindComputerByHostName(adobjectId.Name);
                    if (adcomputer != null && !string.IsNullOrEmpty(adcomputer.DnsHostName))
                    {
                        if (dag.DatacenterActivationMode != DatacenterActivationModeOption.DagOnly || !dag.StoppedMailboxServers.Contains(adcomputer.DnsHostName, StringComparer.OrdinalIgnoreCase))
                        {
                            dagNetworkConfiguration = DagNetworkRpc.GetDagNetworkConfig(adcomputer.DnsHostName);
                            if (dagNetworkConfiguration != null)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (TaskServerTransientException ex2)
                {
                    ex = ex2;
                }
                catch (TaskServerException ex3)
                {
                    ex = ex3;
                }
                catch (ADTransientException ex4)
                {
                    ex = ex4;
                }
                catch (ADExternalException ex5)
                {
                    ex = ex5;
                }
                catch (ADOperationException ex6)
                {
                    ex = ex6;
                }
            }
            if (dagNetworkConfiguration == null && ex != null)
            {
                throw ex;
            }
            return(dagNetworkConfiguration);
        }
		private static ADComputer GetComputerObject(string name, ITopologyConfigurationSession gcSession, ManageSendConnectors.ThrowTerminatingErrorDelegate throwDelegate)
		{
			TaskLogger.LogEnter();
			ADComputer adcomputer = gcSession.FindComputerByHostName(name);
			if (adcomputer == null)
			{
				throwDelegate(new SendConnectorComputerNotFoundException(name), ErrorCategory.ObjectNotFound, null);
			}
			TaskLogger.LogExit();
			return adcomputer;
		}
Exemple #8
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            List <Server>             list  = new List <Server>();
            List <SecurityIdentifier> list2 = new List <SecurityIdentifier>();
            Server server = null;

            try
            {
                server = ((ITopologyConfigurationSession)this.configurationSession).FindLocalServer();
            }
            catch (LocalServerNotFoundException ex)
            {
                base.WriteError(new CouldNotFindExchangeServerDirectoryEntryException(ex.Fqdn), ErrorCategory.InvalidData, null);
            }
            base.LogReadObject(server);
            list.Add(server);
            ADComputer adcomputer = ((ITopologyConfigurationSession)this.domainConfigurationSession).FindLocalComputer();

            if (adcomputer == null)
            {
                base.WriteError(new CouldNotFindLocalhostDirectoryEntryException(), ErrorCategory.InvalidData, null);
            }
            base.LogReadObject(adcomputer);
            list2.Add(adcomputer.Sid);
            if (list.Count > 0)
            {
                List <ActiveDirectoryAccessRule> list3 = list2.ConvertAll <ActiveDirectoryAccessRule>((SecurityIdentifier machineSid) => new ActiveDirectoryAccessRule(machineSid, ActiveDirectoryRights.GenericRead, AccessControlType.Allow, ActiveDirectorySecurityInheritance.All));
                using (IEnumerator <string> enumerator = DirectoryCommon.ServerWriteAttrs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string attr = enumerator.Current;
                        list3.AddRange(list2.ConvertAll <ActiveDirectoryAccessRule>((SecurityIdentifier machineSid) => new ActiveDirectoryAccessRule(machineSid, ActiveDirectoryRights.WriteProperty, AccessControlType.Allow, DirectoryCommon.GetSchemaPropertyGuid(this.configurationSession, attr), ActiveDirectorySecurityInheritance.None)));
                    }
                }
                foreach (Server obj in list)
                {
                    DirectoryCommon.SetAces(new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), null, obj, list3.ToArray());
                }
                SecurityIdentifier sid = this.exs.Sid;
                List <ActiveDirectoryAccessRule> list4 = new List <ActiveDirectoryAccessRule>();
                list4.Add(new ActiveDirectoryAccessRule(sid, ActiveDirectoryRights.ExtendedRight, AccessControlType.Allow, WellKnownGuid.StoreTransportAccessExtendedRightGuid, ActiveDirectorySecurityInheritance.All));
                list4.Add(new ActiveDirectoryAccessRule(sid, ActiveDirectoryRights.ExtendedRight, AccessControlType.Allow, WellKnownGuid.StoreConstrainedDelegationExtendedRightGuid, ActiveDirectorySecurityInheritance.All));
                list4.Add(new ActiveDirectoryAccessRule(sid, ActiveDirectoryRights.ExtendedRight, AccessControlType.Allow, WellKnownGuid.StoreReadAccessExtendedRightGuid, ActiveDirectorySecurityInheritance.All));
                list4.Add(new ActiveDirectoryAccessRule(sid, ActiveDirectoryRights.ExtendedRight, AccessControlType.Allow, WellKnownGuid.StoreReadWriteAccessExtendedRightGuid, ActiveDirectorySecurityInheritance.All));
                foreach (Server obj2 in list)
                {
                    DirectoryCommon.SetAces(new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), null, obj2, list4.ToArray());
                }
                TaskLogger.LogExit();
            }
        }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter(new object[]
            {
                this.serverId,
                this.Component
            });
            ADComputer adcomputer = null;
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(this.DomainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 98, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\ComponentStates\\GetServerComponentState.cs");
            string text  = (!string.IsNullOrWhiteSpace(this.serverId.Fqdn)) ? this.serverId.Fqdn : this.serverId.ToString();
            string text2 = text;
            int    num   = text.IndexOf('.');

            if (num > 0)
            {
                text2 = text.Substring(0, num);
            }
            Server server = topologyConfigurationSession.FindServerByName(text2);

            if (server == null)
            {
                topologyConfigurationSession.UseConfigNC      = false;
                topologyConfigurationSession.UseGlobalCatalog = true;
                adcomputer = topologyConfigurationSession.FindComputerByHostName(text2);
                if (adcomputer == null)
                {
                    base.WriteError(new ADServerNotFoundException(text), ErrorCategory.InvalidArgument, null);
                }
            }
            if (string.IsNullOrEmpty(this.Component))
            {
                using (IEnumerator enumerator = Enum.GetValues(typeof(ServerComponentEnum)).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        object obj = enumerator.Current;
                        ServerComponentEnum serverComponent = (ServerComponentEnum)obj;
                        if (ServerComponentStateManager.IsValidComponent(serverComponent))
                        {
                            base.WriteObject(new ServerComponentStatePresentationObject((server != null) ? server.Id : adcomputer.Id, (server != null) ? server.Fqdn : adcomputer.DnsHostName, ServerComponentStateManager.GetComponentId(serverComponent), (server != null) ? server.ComponentStates : adcomputer.ComponentStates));
                        }
                    }
                    goto IL_1B2;
                }
            }
            base.WriteObject(new ServerComponentStatePresentationObject((server != null) ? server.Id : adcomputer.Id, (server != null) ? server.Fqdn : adcomputer.DnsHostName, this.Component, (server != null) ? server.ComponentStates : adcomputer.ComponentStates));
IL_1B2:
            TaskLogger.LogExit();
        }
Exemple #10
0
        // Token: 0x06000D0E RID: 3342 RVA: 0x00039908 File Offset: 0x00037B08
        private static void CheckOSVersionUsingAD(string server, Version localOSVersion, ITopologyConfigurationSession session)
        {
            if (session == null)
            {
                throw new ArgumentException("session should not be null.", "session");
            }
            ADComputer adcomputer = session.FindComputerByHostName(server);

            if (adcomputer != null)
            {
                string operatingSystemVersion = adcomputer.OperatingSystemVersion;
                if (string.IsNullOrEmpty(operatingSystemVersion))
                {
                    ExTraceGlobals.ClusterTracer.TraceDebug <string>(0L, "CheckOSVersionUsingAD(): Could not read OperatingSystemVersion from AD for server '{0}'.", server);
                    return;
                }
                ExTraceGlobals.ClusterTracer.TraceDebug <string, string>(0L, "CheckOSVersionUsingAD(): Server '{0}' has OperatingSystemVersion '{1}' from AD.", server, operatingSystemVersion);
                string[] array = operatingSystemVersion.Split(new char[]
                {
                    '.',
                    ' ',
                    '(',
                    ')'
                }, StringSplitOptions.RemoveEmptyEntries);
                if (array == null || array.Length != 3)
                {
                    ExTraceGlobals.ClusterTracer.TraceDebug <string>(0L, "CheckOSVersionUsingAD(): Found unexpected OS version format from AD for server '{0}'.", server);
                    return;
                }
                Version version = new Version(Convert.ToInt32(array[0]), Convert.ToInt32(array[1]), Convert.ToInt32(array[2]));
                if (version.Major != localOSVersion.Major)
                {
                    if (version.Major == 6 && localOSVersion.Major == 5)
                    {
                        throw new RemoteClusterWin2k3ToWin2k8NotSupportedException();
                    }
                    if (version.Major == 5 && localOSVersion.Major == 6)
                    {
                        throw new RemoteClusterWin2k8ToWin2k3NotSupportedException();
                    }
                }
            }
            else
            {
                ExTraceGlobals.ClusterTracer.TraceDebug <string>(0L, "CheckOSVersionUsingAD(): Could not find ADComputer object for server '{0}'.", server);
            }
        }
        private static Server GetInboundProxyCaller(string securityContextHeader, WindowsIdentity identity)
        {
            if (string.IsNullOrEmpty(securityContextHeader))
            {
                ExTraceGlobals.ProxyTracer.TraceInformation(0, 0L, "Request does not carry a security context header.");
                return(null);
            }
            if (identity == null)
            {
                ExTraceGlobals.ProxyTracer.TraceInformation(0, 0L, "Request does not carry a WindowsIdentity.");
                throw new CmdletAccessDeniedException(Strings.ProxyRequiresWindowsAuthentication);
            }
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 1177, "GetInboundProxyCaller", "f:\\15.00.1497\\sources\\dev\\admin\\src\\ecp\\RBAC\\RbacSettings.cs");

            topologyConfigurationSession.UseConfigNC      = false;
            topologyConfigurationSession.UseGlobalCatalog = true;
            ADComputer adcomputer = topologyConfigurationSession.FindComputerBySid(identity.User);

            if (adcomputer == null)
            {
                ExTraceGlobals.ProxyTracer.TraceInformation <SecurityIdentifier>(0, 0L, "Identity in the request is not from an AD computer. {0}", identity.User);
                throw new CmdletAccessDeniedException(Strings.ProxyRequiresCallerToBeCAS);
            }
            topologyConfigurationSession.UseConfigNC = true;
            Server server = topologyConfigurationSession.FindServerByName(adcomputer.Name);

            if (server == null)
            {
                ExTraceGlobals.ProxyTracer.TraceInformation <string>(0, 0L, "Identity in the request is a computer but not an Exchange server. {0}", adcomputer.Name);
                throw new CmdletAccessDeniedException(Strings.ProxyRequiresCallerToBeCAS);
            }
            if (!server.IsClientAccessServer && !server.IsFfoWebServiceRole && !server.IsCafeServer && !server.IsOSPRole)
            {
                ExTraceGlobals.ProxyTracer.TraceInformation <string>(0, 0L, "Exchange Server {0} is not a Client Access Server.", server.Name);
                throw new CmdletAccessDeniedException(Strings.ProxyRequiresCallerToBeCAS);
            }
            if (!server.IsE14OrLater)
            {
                ExTraceGlobals.ProxyTracer.TraceInformation <string, string>(0, 0L, "Exchange Server {0} is not a E14 or later. {1}", server.Name, server.SerialNumber);
                throw new CmdletAccessDeniedException(Strings.ProxyRequiresCallerToBeCAS);
            }
            ExTraceGlobals.ProxyTracer.TraceInformation <string>(0, 0L, "Detected an inbound proxy call from server {0}.", server.Name);
            return(server);
        }
Exemple #12
0
        private static MultiValuedProperty <string> ReadLocalServerComponentStatesFromAD()
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 480, "ReadLocalServerComponentStatesFromAD", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ServerComponentStateManager.cs");
            string machineName = Environment.MachineName;
            Server server      = topologyConfigurationSession.FindServerByName(machineName);

            if (server != null)
            {
                return(server.ComponentStates);
            }
            topologyConfigurationSession.UseConfigNC      = false;
            topologyConfigurationSession.UseGlobalCatalog = true;
            ADComputer adcomputer = topologyConfigurationSession.FindComputerByHostName(machineName);

            if (adcomputer == null)
            {
                throw new LocalServerNotFoundException(machineName);
            }
            return(adcomputer.ComponentStates);
        }
 private void FixExchangeTrustedSubsystemGroupMembership(ADGroup ets, ADGroup ewp, ADGroup exs, ADGroup ema, bool etsExisted, bool ewpExisted)
 {
     if (!ewpExisted && etsExisted)
     {
         ets.Members.Remove(exs.Id);
         ADPagedReader <Server> adpagedReader = ((ITopologyConfigurationSession)this.configurationSession).FindAllServersWithVersionNumber(Server.E14MinVersion);
         bool useGlobalCatalog = this.domainConfigurationSession.UseGlobalCatalog;
         this.domainConfigurationSession.UseGlobalCatalog = true;
         foreach (Server server in adpagedReader)
         {
             ADComputer adcomputer = ((ITopologyConfigurationSession)this.domainConfigurationSession).FindComputerByHostName(server.Fqdn);
             if (adcomputer == null)
             {
                 this.WriteWarning(Strings.ErrorCannotFindComputerObjectByServerFqdnNeedManualAdd(server.Fqdn));
             }
             else if (ets.Members.Contains(adcomputer.Id))
             {
                 base.WriteVerbose(Strings.InfoAlreadyIsMemberOfGroup(adcomputer.DistinguishedName, ets.DistinguishedName));
             }
             else
             {
                 ets.Members.Add(adcomputer.Id);
             }
         }
         this.domainConfigurationSession.UseGlobalCatalog = useGlobalCatalog;
         SetupTaskBase.Save(ets, this.rootDomainRecipientSession);
     }
     if (this.adSplitPermissionMode)
     {
         InitializeExchangeUniversalGroups.RemoveMember(ets, this.rootDomainRecipientSession, ewp, new WriteVerboseDelegate(base.WriteVerbose));
     }
     else
     {
         InitializeExchangeUniversalGroups.AddMember(ets, this.rootDomainRecipientSession, ewp, new WriteVerboseDelegate(base.WriteVerbose));
     }
     if (ema.Members.Contains(ets.Id))
     {
         ema.Members.Remove(ets.Id);
         SetupTaskBase.Save(ema, this.rootDomainRecipientSession);
     }
 }
Exemple #14
0
 private void Unlink()
 {
     try
     {
         ADUser     aduser     = this.FindRmsSharedIdentityUser();
         ADComputer adcomputer = this.FindComputer();
         if (aduser.RMSComputerAccounts.Contains(adcomputer.Id))
         {
             base.WriteVerbose(Strings.RmsSharedIdentityBeingUnlinkedFromComputer(aduser.DistinguishedName, aduser.OriginatingServer, adcomputer.DistinguishedName, adcomputer.OriginatingServer));
             aduser.RMSComputerAccounts.Remove(adcomputer.Id);
             this.writeableRecipientSession.LinkResolutionServer = adcomputer.OriginatingServer;
             this.writeableRecipientSession.Save(aduser);
         }
     }
     catch (RmsSharedIdentityTooManyUsersException ex)
     {
         this.WriteWarning(ex.LocalizedString);
         this.WriteWarning(Strings.RmsSharedIdentityFailedToRemoveLink);
     }
     catch (RmsSharedIdentityUserNotFoundException ex2)
     {
         this.WriteWarning(ex2.LocalizedString);
         this.WriteWarning(Strings.RmsSharedIdentityFailedToRemoveLink);
     }
     catch (RmsSharedIdentityLocalComputerNotFoundException)
     {
         this.WriteWarning(Strings.RmsSharedIdentityLocalComputerNotFound);
         this.WriteWarning(Strings.RmsSharedIdentityFailedToRemoveLink);
     }
     catch (RmsSharedIdentityComputerNotFoundException)
     {
         this.WriteWarning(Strings.RmsSharedIdentityComputerNotFound(this.ServerName));
         this.WriteWarning(Strings.RmsSharedIdentityFailedToRemoveLink);
     }
     catch (DataValidationException ex3)
     {
         this.WriteWarning(Strings.RmsSharedIdentityInconsistentState(ex3.LocalizedString));
         this.WriteWarning(Strings.RmsSharedIdentityFailedToRemoveLink);
     }
 }
Exemple #15
0
        protected string GetNetBIOSName(string name)
        {
            string text = null;
            int    num  = name.IndexOf('.');

            if (num != -1)
            {
                try
                {
                    ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 1551, "GetNetBIOSName", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\ComponentInfoBasedTask.cs");
                    topologyConfigurationSession.UseConfigNC      = false;
                    topologyConfigurationSession.UseGlobalCatalog = true;
                    ADComputer adcomputer = topologyConfigurationSession.FindComputerByHostName(name);
                    if (adcomputer != null)
                    {
                        text = adcomputer.Name;
                    }
                }
                catch (DataSourceOperationException)
                {
                }
                catch (DataSourceTransientException)
                {
                }
                catch (DataValidationException)
                {
                }
                if (text == null)
                {
                    text = name.Substring(0, num);
                }
            }
            else
            {
                text = name;
            }
            return(text);
        }
Exemple #16
0
 private ADComputer FindComputer()
 {
     if (string.IsNullOrEmpty(this.ServerName))
     {
         ITopologyConfigurationSession topologyConfigurationSession = this.CreateReadOnlyLocalConfigurationSession();
         ADComputer adcomputer = topologyConfigurationSession.FindLocalComputer();
         if (adcomputer == null)
         {
             throw new RmsSharedIdentityLocalComputerNotFoundException();
         }
         return(adcomputer);
     }
     else
     {
         ITopologyConfigurationSession topologyConfigurationSession2 = this.CreateGlobalCatalogConfigurationSession();
         ADComputer adcomputer2 = topologyConfigurationSession2.FindComputerByHostName(this.ServerName);
         if (adcomputer2 == null)
         {
             throw new RmsSharedIdentityComputerNotFoundException(this.ServerName);
         }
         return(adcomputer2);
     }
 }
Exemple #17
0
        public async Task <ADComputer> GetADComputerAsync(LdapCredential ldapCredential, string name)
        {
            ADComputer ADComputer = null;

            if (ldapCredential is null)
            {
                throw new Exception("Failed to get LDAP Credentials");
            }

            using (LdapConnection ldapConnection = await CreateBindAsync(ldapCredential.UserName, ldapCredential.Password))
            {
                string defaultNamingContext = _ldapOptions.Value.SearchBase;

                var ldapSearchResult = (await ldapConnection.SearchByCnAsync(defaultNamingContext, name, Native.LdapSearchScope.LDAP_SCOPE_SUB)).FirstOrDefault();

                if (ldapSearchResult != null)
                {
                    ADComputer = new ADComputer(ldapSearchResult.DirectoryAttributes["cn"].GetValues <string>().First());

                    if (ldapSearchResult.DirectoryAttributes.Any(x => x.Name == "ms-Mcs-AdmPwd"))
                    {
                        ADComputer.LAPSPassword           = ldapSearchResult.DirectoryAttributes["ms-Mcs-AdmPwd"].GetValues <string>().First().ToString();
                        ADComputer.LAPSPasswordExpireDate = DateTime.FromFileTime(Convert.ToInt64(ldapSearchResult.DirectoryAttributes["ms-Mcs-AdmPwdExpirationTime"].GetValues <string>().First().ToString()));
                    }
                    else
                    {
                        throw new Exception("No permission to retrieve LAPS Password");
                    }
                }
                else
                {
                    throw new Exception($"AD Computer {name} could not be found");
                }
            }

            return(ADComputer);
        }
		public static void RemoveServersFromGroup(IList<ADObjectId> serverIds, ADGroup group, IRecipientSession recipSession, ITopologyConfigurationSession gcSession, ManageSendConnectors.ThrowTerminatingErrorDelegate throwDelegate)
		{
			TaskLogger.LogEnter();
			if (serverIds.Count == 0)
			{
				TaskLogger.LogExit();
				return;
			}
			foreach (ADObjectId adobjectId in serverIds)
			{
				ADComputer computerObject = ManageSendConnectors.GetComputerObject(adobjectId.Name, gcSession, throwDelegate);
				if (group.Members.Contains(computerObject.Id))
				{
					TaskLogger.Trace("Removing server '{0}' from group '{1}'", new object[]
					{
						adobjectId.Name,
						group.Name
					});
					group.Members.Remove(computerObject.Id);
				}
			}
			recipSession.Save(group);
			TaskLogger.LogExit();
		}
Exemple #19
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            bool flag  = false;
            bool flag2 = false;
            InformationStoreSkuLimits informationStoreSkuLimits = null;
            IConfigurationSession     configurationSession      = (IConfigurationSession)base.DataSession;
            ExchangeServer            exchangeServer            = new ExchangeServer(this.DataObject);

            if (this.isErrorReportingChanged && this.oldErrorReporting != null && !this.oldErrorReporting.Value && (this.DataObject.ErrorReportingEnabled == null || this.DataObject.ErrorReportingEnabled.Value) && !base.ShouldContinue(Strings.ErrorReportingEnabledLegalMessage))
            {
                return;
            }
            if (this.ShouldGeneratePid())
            {
                this.DataObject.ProductID = this.ProductKey.GenerateProductID();
                this.DataObject.Edition   = this.ProductKey.Sku.ServerEdition;
                ADObjectId       childId          = this.DataObject.Id.GetChildId("InformationStore");
                InformationStore informationStore = configurationSession.Read <InformationStore>(childId);
                if (informationStore != null)
                {
                    informationStoreSkuLimits        = new InformationStoreSkuLimits(informationStore);
                    informationStore.MinAdminVersion = new int?(ExchangeObjectVersion.Exchange2007.ExchangeBuild.ToExchange2003FormatInt32());
                    informationStore.SetExchangeVersion(ExchangeObjectVersion.Exchange2007);
                    this.ProductKey.Sku.InformationStoreSkuLimits.UpdateInformationStore(informationStore);
                    configurationSession.Save(informationStore);
                    flag = true;
                }
            }
            if ((this.isDCChanged || this.isGCChanged || this.isCDCChanged || this.isExcludedDCChanged || this.isErrorReportingChanged) && !this.DataObject.IsProvisionedServer)
            {
                Exception ex = null;
                GetExchangeServer.SetConfigurationToRegistry(exchangeServer.Fqdn, exchangeServer.StaticDomainControllers, exchangeServer.StaticGlobalCatalogs, exchangeServer.StaticConfigDomainController ?? string.Empty, exchangeServer.StaticExcludedDomainControllers, exchangeServer.ErrorReportingEnabled, out ex);
                if (ex != null)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorFaildToWriteRegistry(exchangeServer.Fqdn, ex.Message)), ErrorCategory.WriteError, this.Identity);
                }
                flag2 = true;
            }
            bool flag3 = false;

            try
            {
                if (this.DataObject.IsModified(ServerSchema.MonitoringGroup))
                {
                    bool useConfigNC      = configurationSession.UseConfigNC;
                    bool useGlobalCatalog = configurationSession.UseGlobalCatalog;
                    try
                    {
                        configurationSession.UseConfigNC      = false;
                        configurationSession.UseGlobalCatalog = true;
                        ADComputer adcomputer = ((ITopologyConfigurationSession)configurationSession).FindComputerByHostName(this.DataObject.Name);
                        if (adcomputer == null)
                        {
                            base.WriteError(new DirectoryObjectNotFoundException(this.DataObject.Id.ToString()), ErrorCategory.WriteError, this.Identity);
                        }
                        adcomputer.MonitoringGroup = this.DataObject.MonitoringGroup;
                        configurationSession.Save(adcomputer);
                    }
                    finally
                    {
                        configurationSession.UseConfigNC      = useConfigNC;
                        configurationSession.UseGlobalCatalog = useGlobalCatalog;
                    }
                }
                base.InternalProcessRecord();
                flag3 = true;
                if (flag)
                {
                    this.WriteWarning(Strings.ProductKeyRestartWarning);
                }
            }
            finally
            {
                if (!flag3)
                {
                    if (flag2)
                    {
                        Exception ex2 = null;
                        GetExchangeServer.SetConfigurationToRegistry(exchangeServer.Fqdn, this.oldDomainControllers, this.oldGlobalCatalogs, this.oldConfigDomainController ?? string.Empty, this.oldExcludedDomainControllers, new bool?(this.oldErrorReporting != null && this.oldErrorReporting.Value), out ex2);
                        if (ex2 != null)
                        {
                            this.WriteError(new InvalidOperationException(Strings.ErrorFaildToWriteRegistry(this.DataObject.Name, ex2.Message)), ErrorCategory.WriteError, this.Identity, false);
                        }
                    }
                    if (flag)
                    {
                        ADObjectId       childId2          = this.DataObject.Id.GetChildId("InformationStore");
                        InformationStore informationStore2 = configurationSession.Read <InformationStore>(childId2);
                        informationStoreSkuLimits.UpdateInformationStore(informationStore2);
                        configurationSession.Save(informationStore2);
                    }
                }
            }
            TaskLogger.LogExit();
        }
Exemple #20
0
 private LoginIdentity(ADComputer adComp)
 {
     _backing = adComp.SID.Value;
     this.IsSecurityIdentitifer = true;
     this.IsADObject            = true;
 }
 internal static bool IsRemoteComponentOnline(ADComputer server, ServerComponentEnum serverComponent)
 {
     return(ServerComponentStates.IsRemoteComponentOnlineInternal(server.DnsHostName, server.ComponentStates, serverComponent));
 }
 internal static bool IsRemoteComponentOnlineAccordingToAD(ADComputer server, ServerComponentEnum serverComponent)
 {
     return(ServerComponentStates.IsRemoteComponentOnlineAccordingToADInternal(server.ComponentStates, serverComponent));
 }
 internal static bool IsServerOnline(ADComputer server)
 {
     return(ServerComponentStates.IsRemoteComponentOnlineAccordingToADInternal(server.ComponentStates, ServerComponentEnum.ServerWideOffline));
 }
        public IADComputer FindComputerByHostName(string hostName)
        {
            ADComputer adComputer = this.m_session.FindComputerByHostName(hostName);

            return(ADObjectWrapperFactory.CreateWrapper(adComputer));
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     try
     {
         try
         {
             MailboxDatabase mailboxDatabase  = this.ConfigurationSession.Read <MailboxDatabase>((ADObjectId)this.DataObject.Identity);
             Server          server           = null;
             ADComputer      adcomputer       = null;
             bool            useConfigNC      = this.ConfigurationSession.UseConfigNC;
             bool            useGlobalCatalog = this.ConfigurationSession.UseGlobalCatalog;
             if (mailboxDatabase != null)
             {
                 server = mailboxDatabase.GetServer();
                 try
                 {
                     this.ConfigurationSession.UseConfigNC      = false;
                     this.ConfigurationSession.UseGlobalCatalog = true;
                     adcomputer = ((ITopologyConfigurationSession)this.ConfigurationSession).FindComputerByHostName(server.Name);
                 }
                 finally
                 {
                     this.ConfigurationSession.UseConfigNC      = useConfigNC;
                     this.ConfigurationSession.UseGlobalCatalog = useGlobalCatalog;
                 }
                 if (adcomputer == null)
                 {
                     base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorDBOwningServerNotFound(mailboxDatabase.Identity.ToString())), ErrorCategory.ObjectNotFound, server.Identity);
                 }
                 ADObjectId adobjectId = adcomputer.Id.DomainId;
                 adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects");
                 adobjectId = adobjectId.GetChildId("SystemMailbox" + mailboxDatabase.Guid.ToString("B"));
                 string identity = adobjectId.ToDNString();
                 GeneralMailboxIdParameter generalMailboxIdParameter = GeneralMailboxIdParameter.Parse(identity);
                 base.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(generalMailboxIdParameter, this.RecipientSession, typeof(ADRecipient), null));
                 IEnumerable <ADSystemMailbox> objects = generalMailboxIdParameter.GetObjects <ADSystemMailbox>(adobjectId, this.RecipientSession);
                 using (IEnumerator <ADSystemMailbox> enumerator = objects.GetEnumerator())
                 {
                     if (enumerator.MoveNext())
                     {
                         ADSystemMailbox adsystemMailbox = enumerator.Current;
                     }
                     else
                     {
                         NewMailboxDatabase.SaveSystemMailbox(mailboxDatabase, mailboxDatabase.GetServer(), base.RootOrgContainerId, (ITopologyConfigurationSession)this.ConfigurationSession, this.RecipientSession, null, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                     }
                 }
             }
             base.WriteVerbose(Strings.VerboseMountDatabase(this.Identity.ToString()));
             this.RequestMount(MountFlags.None);
             if (!this.DataObject.DatabaseCreated)
             {
                 this.DataObject.DatabaseCreated = true;
                 base.InternalProcessRecord();
             }
         }
         catch (AmServerException ex)
         {
             Exception ex2;
             if (ex.TryGetInnerExceptionOfType(out ex2))
             {
                 TaskLogger.Trace("Database already mounted (database={0}, exception={1})", new object[]
                 {
                     this.DataObject.Name,
                     ex2.Message
                 });
             }
             else if (ex.TryGetInnerExceptionOfType(out ex2) || ex.TryGetInnerExceptionOfType(out ex2))
             {
                 this.AttemptForcedMountIfNecessary(this.Force, Strings.ContinueMountWhenDBFilesNotExist, Strings.VerboseMountDatabaseForcely(this.Identity.ToString()), Strings.ErrorFailedToMountReplicatedDbWithMissingEdbFile(this.Identity.ToString()), ex, MountFlags.ForceDatabaseCreation);
             }
             else if (ex.TryGetInnerExceptionOfType(out ex2))
             {
                 this.PromptForMountIfNecessary(this.AcceptDataLoss, Strings.ContinueMountWithDataLoss, Strings.VerboseMountDatabaseDataLoss(this.Identity.ToString()), MountFlags.AcceptDataLoss);
             }
             else
             {
                 TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
                 {
                     ex.Message
                 });
                 base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex.Message), ex), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
         }
     }
     catch (AmServerException ex3)
     {
         TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
         {
             ex3.Message
         });
         base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex3.Message), ex3), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     catch (AmServerTransientException ex4)
     {
         TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
         {
             ex4.Message
         });
         base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex4.Message), ex4), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Exemple #26
0
        private void RecalculateAccessRules()
        {
            if (this.m_accessRules == null)
            {
                this.m_accessRules = new List <FileSystemAccessRule>();
            }
            string text = NativeHelpers.GetDomainName();
            int    num  = text.IndexOf('.');

            if (num > -1)
            {
                text = text.Substring(0, num);
            }
            ComparisonFilter filter = new ComparisonFilter(ComparisonOperator.Equal, DatabaseAvailabilityGroupSchema.Name, this.m_dagName);

            DatabaseAvailabilityGroup[] array = this.m_adSession.Find <DatabaseAvailabilityGroup>(null, QueryScope.SubTree, filter, null, 1);
            if (array == null || array.Length == 0)
            {
                this.m_accessRules.Clear();
                TaskLogger.Trace("Account {0}$ for witness share \\\\{1}\\{2} does not exist yet, assuming we are working with empty dag, fsw will be created with current user {3} permissions and removed.", new object[]
                {
                    this.m_dagName,
                    this.WitnessServer,
                    this.ShareName,
                    WindowsIdentity.GetCurrent().User
                });
                FileSystemAccessRule item = new FileSystemAccessRule(WindowsIdentity.GetCurrent().User.Translate(typeof(NTAccount)) as NTAccount, FileSystemRights.FullControl, AccessControlType.Allow);
                this.m_accessRules.Add(item);
                return;
            }
            MultiValuedProperty <IPAddress> databaseAvailabilityGroupIpAddresses = array[0].DatabaseAvailabilityGroupIpAddresses;
            bool flag = databaseAvailabilityGroupIpAddresses == null || databaseAvailabilityGroupIpAddresses.Count != 1 || !IPAddress.None.Equals(databaseAvailabilityGroupIpAddresses[0]);

            if (flag)
            {
                bool flag2 = true;
                if (this.m_accessRules.Count == 1)
                {
                    if (this.m_accessRules[0].IdentityReference.Value.Contains(this.m_dagName))
                    {
                        flag2 = false;
                    }
                    else
                    {
                        this.m_accessRules.Clear();
                    }
                }
                if (flag2)
                {
                    ITopologyConfigurationSession topologyConfigurationSession = this.CreateRootSession();
                    DateTime   t = DateTime.UtcNow.AddMinutes(6.0);
                    ADComputer adcomputer;
                    for (adcomputer = topologyConfigurationSession.FindComputerByHostName(this.m_dagName); adcomputer == null; adcomputer = topologyConfigurationSession.FindComputerByHostName(this.m_dagName))
                    {
                        if (DateTime.UtcNow > t)
                        {
                            throw new DagUnableToFindCnoException(this.m_dagName);
                        }
                        Thread.Sleep(TimeSpan.FromSeconds(20.0));
                    }
                    IdentityReference    identity = adcomputer.Sid.Translate(typeof(NTAccount));
                    FileSystemAccessRule item2    = new FileSystemAccessRule(identity, FileSystemRights.FullControl, AccessControlType.Allow);
                    this.m_accessRules.Add(item2);
                    return;
                }
            }
            else
            {
                bool       flag3     = false;
                IAmCluster amCluster = null;
                DatabaseAvailabilityGroup databaseAvailabilityGroup = array[0];
                List <AmServerName>       list = new List <AmServerName>();
                try
                {
                    if (!this.m_clusterReference.TryGetTarget(out amCluster) || (amCluster is AmCluster && ((AmCluster)amCluster).IsDisposed))
                    {
                        amCluster = null;
                        foreach (ADObjectId adobjectId in databaseAvailabilityGroup.Servers)
                        {
                            AmServerName amServerName = new AmServerName(adobjectId);
                            if (!databaseAvailabilityGroup.StoppedMailboxServers.Contains(amServerName.Fqdn) && (databaseAvailabilityGroup.ServersInMaintenance == null || !databaseAvailabilityGroup.ServersInMaintenance.Contains(adobjectId)))
                            {
                                amCluster = ClusterFactory.Instance.OpenByName(amServerName);
                                if (amCluster != null)
                                {
                                    flag3 = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (amCluster != null)
                    {
                        using (IEnumerator <IAmClusterNode> enumerator2 = amCluster.EnumerateNodes().GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                IAmClusterNode amClusterNode = enumerator2.Current;
                                list.Add(amClusterNode.Name);
                            }
                            goto IL_352;
                        }
                    }
                    foreach (ADObjectId serverId in databaseAvailabilityGroup.Servers)
                    {
                        list.Add(new AmServerName(serverId));
                    }
                    IL_352 :;
                }
                finally
                {
                    if (flag3 && amCluster != null)
                    {
                        amCluster.Dispose();
                    }
                }
                this.m_accessRules.Clear();
                ITopologyConfigurationSession topologyConfigurationSession2 = this.CreateRootSession();
                foreach (AmServerName amServerName2 in list)
                {
                    ADComputer           adcomputer2 = topologyConfigurationSession2.FindComputerByHostName(amServerName2.NetbiosName);
                    IdentityReference    identity2   = adcomputer2.Sid.Translate(typeof(NTAccount));
                    FileSystemAccessRule item3       = new FileSystemAccessRule(identity2, FileSystemRights.FullControl, AccessControlType.Allow);
                    this.m_accessRules.Add(item3);
                }
            }
        }
Exemple #27
0
        internal override IADOPathNode IdentitySearchConverter(object identity)
        {
            IADOPathNode aDOPathNode;

            if (identity != null)
            {
                string str = identity as string;
                if (str == null)
                {
                    SecurityIdentifier securityIdentifier = identity as SecurityIdentifier;
                    if (securityIdentifier == null)
                    {
                        if (!(identity is Guid))
                        {
                            ADDomainController aDDomainController = identity as ADDomainController;
                            if (aDDomainController == null)
                            {
                                ADObject aDObject = identity as ADObject;
                                if (aDObject == null)
                                {
                                    throw new ArgumentException(string.Format(StringResources.SearchConverterUnrecognizedObjectType, identity.GetType()));
                                }
                                else
                                {
                                    ADComputer aDComputer = new ADComputer(aDObject);
                                    ADDomainControllerFactory <T> .ADComputerPseudoFactory aDComputerPseudoFactory = new ADDomainControllerFactory <T> .ADComputerPseudoFactory();

                                    aDComputerPseudoFactory.SetCmdletSessionInfo(base.CmdletSessionInfo);
                                    return(aDComputerPseudoFactory.BuildIdentityFilter(aDComputer));
                                }
                            }
                            else
                            {
                                IADOPathNode        aDOPathNode1 = base.IdentitySearchConverter(identity);
                                List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>();
                                if (aDDomainController["ComputerDN"] != null && aDDomainController["ComputerDN"].Value != null)
                                {
                                    aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "distinguishedName", Utils.EscapeDNForFilter(aDDomainController["ComputerDN"].Value as string)));
                                }
                                aDOPathNodes.Add(aDOPathNode1);
                                if (aDOPathNodes.Count != 1)
                                {
                                    return(ADOPathUtil.CreateOrClause(aDOPathNodes.ToArray()));
                                }
                                else
                                {
                                    return(aDOPathNodes[0]);
                                }
                            }
                        }
                        else
                        {
                            Guid guid = (Guid)identity;
                            return(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectGuid", guid.ToByteArray()));
                        }
                    }
                    else
                    {
                        byte[] numArray = new byte[securityIdentifier.BinaryLength];
                        securityIdentifier.GetBinaryForm(numArray, 0);
                        return(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectSid", numArray));
                    }
                }
                else
                {
                    Guid?     nullable = null;
                    IPAddress pAddress = null;
                    if (!Utils.TryParseGuid(str, out nullable))
                    {
                        if (!IPAddress.TryParse(str, out pAddress))
                        {
                            List <IADOPathNode> aDOPathNodes1 = this.BuildIdentityFilterListFromString(str);
                            if (aDOPathNodes1.Count <= 1)
                            {
                                return(aDOPathNodes1[0]);
                            }
                            else
                            {
                                return(ADOPathUtil.CreateOrClause(aDOPathNodes1.ToArray()));
                            }
                        }
                        else
                        {
                            try
                            {
                                IPHostEntry hostEntry = Dns.GetHostEntry(pAddress);
                                aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "dNSHostName", hostEntry.HostName);
                            }
                            catch (SocketException socketException1)
                            {
                                SocketException socketException = socketException1;
                                object[]        objArray        = new object[1];
                                objArray[0] = pAddress;
                                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.CannotResolveIPAddressToHostName, objArray), socketException);
                            }
                            return(aDOPathNode);
                        }
                    }
                    else
                    {
                        Guid value = nullable.Value;
                        return(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectGuid", value.ToByteArray()));
                    }
                }
            }
            else
            {
                throw new ArgumentNullException("identity");
            }
        }
Exemple #28
0
 private ADComputerWrapper(ADComputer adComputer) : base(adComputer)
 {
     this.DnsHostName = adComputer.DnsHostName;
 }
Exemple #29
0
        protected override void InternalProcessRecord()
        {
            base.InternalProcessRecord();
            ADComputer adcomputer = null;
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(this.DomainController, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 213, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\ComponentStates\\SetServerComponentState.cs");
            string fqdn = this.serverId.Fqdn;
            string text = fqdn;
            int    num  = fqdn.IndexOf('.');

            if (num > 0)
            {
                text = fqdn.Substring(0, num);
            }
            Server server = topologyConfigurationSession.FindServerByName(text);

            if (server == null)
            {
                topologyConfigurationSession.UseConfigNC      = false;
                topologyConfigurationSession.UseGlobalCatalog = true;
                adcomputer = topologyConfigurationSession.FindComputerByHostName(text);
                if (adcomputer == null)
                {
                    base.WriteError(new ADServerNotFoundException(fqdn), ErrorCategory.InvalidArgument, null);
                }
            }
            if (!this.LocalOnly)
            {
                if (server != null)
                {
                    server.ComponentStates = ServerComponentStates.UpdateRemoteState(server.ComponentStates, this.Requester, this.Component, this.State);
                    topologyConfigurationSession.Save(server);
                }
                else
                {
                    adcomputer.ComponentStates = ServerComponentStates.UpdateRemoteState(adcomputer.ComponentStates, this.Requester, this.Component, this.State);
                    topologyConfigurationSession.Save(adcomputer);
                }
            }
            if (!this.RemoteOnly)
            {
                string    serverFqdn    = (server != null) ? server.Fqdn : adcomputer.DnsHostName;
                TimeSpan  invokeTimeout = TimeSpan.FromSeconds((double)this.TimeoutInSeconds);
                Exception ex            = null;
                try
                {
                    InvokeWithTimeout.Invoke(delegate()
                    {
                        ServerComponentStates.UpdateLocalState(serverFqdn, this.Requester, this.Component, this.State);
                    }, null, invokeTimeout, true, null);
                }
                catch (IOException ex2)
                {
                    ex = ex2;
                }
                catch (UnauthorizedAccessException ex3)
                {
                    ex = ex3;
                }
                catch (SecurityException ex4)
                {
                    ex = ex4;
                }
                if (ex != null && this.LocalOnly)
                {
                    base.WriteError(new ArgumentException(Strings.SetServerComponentStateServerUnreachable(serverFqdn, ex.Message)), ErrorCategory.ResourceUnavailable, null);
                }
            }
        }
 public static ADComputerWrapper CreateWrapper(ADComputer adComputer)
 {
     return(ADComputerWrapper.CreateWrapper(adComputer));
 }