开发者

LDAP Invalid DN Syntax

开发者 https://www.devze.com 2022-12-17 14:00 出处:网络
string path = \"LDAP://192.168.0.20/CN=users,DC=company,DC=ltm,DC=dom\"; DirectoryEntry dir = new DirectoryEntry(path, admin, pass, AuthenticationTypes.ServerBind);
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.


Have you tried it without specifying AuthenticationTypes?

Just like:

DirectoryEntry dir = new DirectoryEntry(path, admin, pass);


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消