【问题标题】:AD LDS error "There is no such object on the server"AD LDS 错误“服务器上没有这样的对象”
【发布时间】:2016-05-14 02:16:09
【问题描述】:

我正在使用打击代码从我的本地计算机(虚拟桌面)客户端在 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

【问题讨论】:

    标签: c# asp.net-mvc adlds


    【解决方案1】:

    我知道这个问题很老,所以您可能已经找到了解决方案。但对于通过 Google 来到这里的其他人:

    如果您告诉我们哪一行引发了错误,这会有所帮助,但我猜它是 SetPassword。设置该密码要求该帐户已经存在。因此,将您的 SetPassword 移到您的 Save() 之后。

    我相信Enabled 也是如此。

      UserPrincipal newUser = new UserPrincipal(principalContext);
                newUser.Name = userId;
                newUser.UserPrincipalName = userId;
                newUser.Save();
    
                newUser.Enabled = false;
                newUser.SetPassword(pwd.ToString());
                newUser.Save();
    

    【讨论】:

      猜你喜欢
      • 2011-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-13
      • 1970-01-01
      • 2020-05-07
      • 1970-01-01
      • 2021-08-20
      相关资源
      最近更新 更多