0
我正在使用打擊代碼在本地計算機(虛擬桌面)客戶端的AD LDS中創建帳戶/用戶。 在我本地的下面的代碼中工作正常但是在將代碼部署到與安裝AD LDS不同的其他服務器之後,它會引發錯誤「服務器上沒有這樣的對象」完整的響應標題如下。AD LDS錯誤「服務器上沒有這樣的對象」
Var host = "Hostname";// soemthing like SV1DCVDEVDB789 where AD LDS is instaed
var port = 389;//Port Number
var machineName = string.Format("{0}:{1}", host, port);
var container = "CN=PSExtUser,CN=PSADLDSPartition1,DC=PS,DC=COM";
var principalContext = new PrincipalContext(ContextType.ApplicationDirectory, machineName, container);
//Check id user already exist
UserPrincipal usr = UserPrincipal.FindByIdentity(principalContext, userId);
//if usr is null create new user as below code
UserPrincipal newUser = new UserPrincipal(principalContext);
newUser.Name = userId;
newUser.UserPrincipalName = userId;
newUser.SetPassword(pwd.ToString());
newUser.Enabled = false;
newUser.Save();
////REsponse obtained
[DirectoryServicesCOMException (0x80072030): There is no such object on the server.
]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +597561
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_AdsObject() +42
System.DirectoryServices.DirectoryEntry.get_Options() +42
System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit() +351
[PrincipalOperationException: There is no such object on the server.
]
System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit() +495548
System.DirectoryServices.AccountManagement.PrincipalContext.DoApplicationDirectoryInit() +61
System.DirectoryServices.AccountManagement.PrincipalContext.Initialize() +184
System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx() +42