网站设计风格分析,梅州建站方法,网站建设方案 报价,2023年战争离我们越来越近了我有一个场景#xff0c;我需要访问远程计算机以编程方式添加和删除Windows用户帐户 . 远程机器是一个“备用工作站”#xff0c;我需要远程配置#xff0c;准备好以防万一主工作站需要更换 - 所以这里没有安全绕过或恶意软件:)我知道远程机器管理员的用户/密码#xff0c;…我有一个场景我需要访问远程计算机以编程方式添加和删除Windows用户帐户 . 远程机器是一个“备用工作站”我需要远程配置准备好以防万一主工作站需要更换 - 所以这里没有安全绕过或恶意软件:)我知道远程机器管理员的用户/密码我能够使用WMI Win32_UserAccount检索现有用户帐户的完整列表 . 现在我正在尝试为每个用户获取一个UserPrincipal对象(最终将其删除)但我的所有尝试都获得了异常 .尝试1PrincipalContext context new PrincipalContext(ContextType.Domain, xxx.xxx.xxx.xxx /*remote IP Address*/);UserPrincipal user (UserPrincipal.FindByIdentity(context, userName));// Do something with user, like user.Delete();在这种情况下我总是在第一行得到一个例外System.DirectoryServices.AccountManagement.PrincipalServerDownException已被捕获Message 无法联系服务器 . Source System.DirectoryServices.AccountManagement StackTraceSystem.DirectoryServices.AccountManagement中的System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverNameServerPropertiesproperties)中的System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()中的System.DirectoryServices.AccountManagement.AccountManagement.PrincipalContext . System.DirectoryServices.AccountManagement.PrincipalContext..ctor中的ContextType contextTypeString nameString containerContextOptions optionsString userNameString password)(ContextType contextTypeString nameString containerString userNameString password)InnerExceptionSystem.DirectoryServices .Protocols.LdapException Message LDAP服务器不可用 . Source System.DirectoryServices.Protocols ErrorCode 81 StackTraceSystem.DirectoryServices.Protocols中的System.DirectoryServices.Protocols.LdapConnection.Connect()System.DirectoryServices.Protocols.LdapConnection中的SystemRequestConnection.SendRequestHelper(DirectoryRequest requestInt32messageID) . System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverNameServerPropertiesproperties)中的System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest请求)中的SendRequest(DirectoryRequest请求TimeSpan requestTimeout)InnerException尝试2PrincipalContext context new PrincipalContext(ContextType.Machine, xxx.xxx.xxx.xxx /*remote IP Address*/);UserPrincipal user (UserPrincipal.FindByIdentity(context, userName));// Do something with user, like user.Delete();在这种情况下我总是在第二行得到一个例外System.IO.FileNotFoundException被捕获Message 找不到网络路径 . Source Active Directory StackTraceSystem.DirectoryServices.Antory中的System.DirectoryServices.Interop.Unsafe服务中的System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()中的System.DirectoryServices.AccountManagement.PrincipalContext.DoMachineInit()System.DirectoryServices.AccountManagement.PrincipalContext System.DirectoryServices.AccountManagement中System.DirectoryServices.AccountManagement.Principal.FindBdentIdentityWithTypeHelper(PrincipalContext上下文Type principalTypeNullable1 identityTypeString identityValueDateTime refDate)中的System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()中的.Initialize() System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext contextString identityValue)中的.Principal.FindByIdentityWithType(PrincipalContext contextType principalTypeString identityValue)InnerException我尝试了PrincipalContext对象的不同签名(使用域名而不是IP地址用户名和密码......)但我总是在两次尝试中都获得例外 .我错过了一些指示吗在创建PrincipalContext对象之前是否需要使用模拟来获得对远程计算机的完全访问权限还有其他方法来完成我想要做的事情吗 (即访问远程计算机以添加/删除Windows帐户)