LDAP 无效 DN 语法
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();
代码生成 COMException :“无效的 DN 语法” at dir.Properties["description"].Value
如果我没有指定任何用户名和密码并将 DirectoryEntry 初始化替换为:
DirectoryEntry dir = new DirectoryEntry(path);
dir.AuthenticationType = AuthenticationTypes.ServerBind;
然后我在 CommitChanges 处收到 UnauthorizedAccessException。
非常感谢任何有关可能出现问题的想法。
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();
The code generates a COMException : "Invalid DN syntax" at dir.Properties["description"].Value
If I don't specify any the username and password and replace the DirectoryEntry initialization with:
DirectoryEntry dir = new DirectoryEntry(path);
dir.AuthenticationType = AuthenticationTypes.ServerBind;
Then I get UnauthorizedAccessException at CommitChanges.
Any ideas on what might be wrong are greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否在未指定 AuthenticationTypes 的情况下尝试过?
一样:
Have you tried it without specifying
AuthenticationTypes
?Just like:
如果您尝试在没有密码和用户名的情况下登录,您会得到 UnauthorizedAccess。
这实际上取决于 LDAP 服务器的配置方式,但这似乎不允许匿名访问。
我认为应该在没有 IP 地址的情况下定义路径,例如 LDAP://CN=users,DC=company,DC=ltm,DC=dom,但我没有在 .NET 中使用,所以我不能肯定地说。
Well you get UnauthorizedAccess if you try to login without password and username.
This actually depends on how the LDAP server is configured but this does not seem to allow anonymous access.
I think that the path should be defined without the ip address like LDAP://CN=users,DC=company,DC=ltm,DC=dom but I am not used in .NET so I can't say for sure.