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 处生成 COMException : "Invalid DN syntax"
如果我没有指定任何用户名和密码,并将 DirectoryEntry 初始化替换为:
DirectoryEntry dir = new DirectoryEntry(path);
dir.AuthenticationType = AuthenticationTypes.ServerBind;
然后我在 CommitChanges 得到 UnauthorizedAccessException。
非常感谢任何关于可能出错的想法。