我一直在尝试寻找一些关于如何使用.NET的LDAP类型连接到OpenDS的教程,但都无济于事。有没有人可以给我推荐一些文章/教程,里面有一些很好的示例,介绍了如何使用OpenDS作为目录服务,以及如何使用C#访问和使用它。
这就是我到目前为止所尝试的,但总是得到一个无效的用户名/密码错误。我被困在什么凭证需要进入,或者我试图做的事情是否有任何意义。
DirectoryEntry directoryEntry = new DirectoryEntry
{
Path = @"LDAP://SUnnikris-va-d:389/dc=example,dc=com",
Username = "uid=user.0",
Password = "TestPass!",
AuthenticationType = AuthenticationTypes.ServerBind
};
directoryEntry.RefreshCache();
DirectoryEntry newUser = directoryEntry.Children.Add("uid=nuser,ou=People,dc=example,dc=com", "person");
newUser.Properties["objectClass"].Value = new object[] { "top", "person", "organizationalPerson", "inetorgPerson" };
newUser.Properties["uid"].Value = "nuser";
newUser.Properties["givenName"].Value = "new";
newUser.Properties["sn"].Value = "user";
newUser.Properties["cn"].Value = "new user";
newUser.Properties["userPassword"].Value = "nuser";
newUser.CommitChanges();发布于 2010-09-16 01:49:10
我发现,OpenDS使用规范名称作为管理的超级用户。本质上,问题在于我使用的凭据,而不是我必须指定的uid:-
NetworkCredential myCreds = new NetworkCredential("cn=Directory Manager", "TestPass!");发布于 2010-09-15 06:12:29
我猜您的用户名是错的,您需要输入用户名的完整ldap路径,即uid=admin、ou=AdminOU、dc=example、dc=com
您也可以使用System.DirectoryServices.AccountManagement进行更简单的实现在这里查看-> http://anyrest.wordpress.com/2010/06/28/active-directory-c/
https://stackoverflow.com/questions/3711879
复制相似问题