首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AD LDS错误“服务器上没有这样的对象”

AD LDS错误“服务器上没有这样的对象”
EN

Stack Overflow用户
提问于 2016-05-14 10:16:09
回答 1查看 1.9K关注 0票数 1

我正在使用blow代码从本地计算机(虚拟桌面)客户端在AD LDS中创建帐户/用户。在我的本地,下面的代码运行良好,但在将代码部署到与AD LDS安装位置不同的其他服务器后,它抛出错误“服务器上没有这样的对象”,下面给出了完整的响应头。

代码语言:javascript
运行
复制
 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
EN

回答 1

Stack Overflow用户

发布于 2016-12-13 03:24:25

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

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

我相信Enabled也是如此。

代码语言:javascript
运行
复制
  UserPrincipal newUser = new UserPrincipal(principalContext);
            newUser.Name = userId;
            newUser.UserPrincipalName = userId;
            newUser.Save();

            newUser.Enabled = false;
            newUser.SetPassword(pwd.ToString());
            newUser.Save();
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37221767

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档