string path = "LDAP://192.168.0.20/CN=users,DC=company,DC=ltm,DC=dom";
DirectoryEntry dir = new DirectoryEntry(path, admin, pass, AuthenticationTypes.ServerBind);
object value = dir.Properties["description"].Value;
dir.Properties["description"].Value = "test";
dir.CommitChanges();代码在dir.Properties"description".Value处生成一个语法:"Invalid DN COMException“
如果我没有指定任何用户名和密码,并将DirectoryEntry初始化替换为:
DirectoryEntry dir = new DirectoryEntry(path);
dir.AuthenticationType = AuthenticationTypes.ServerBind;然后我在CommitChanges找到了UnauthorizedAccessException。
任何关于哪里可能出错的想法都是非常感谢的。
发布于 2010-01-22 18:01:04
您是否尝试过不指定AuthenticationTypes的情况
就像这样:
DirectoryEntry dir = new DirectoryEntry(path, admin, pass);发布于 2010-01-22 17:50:18
如果你尝试在没有密码和用户名的情况下登录,你会得到UnauthorizedAccess。
这实际上取决于LDAP服务器的配置方式,但这似乎不允许匿名访问。
我认为应该不使用ip地址来定义路径,比如LDAP://CN=users,DC=company,DC=ltm,DC=dom,但是我不在.NET中使用,所以我不能确定。
https://stackoverflow.com/questions/2116189
复制相似问题