我正在尝试以编程方式将用户添加到AD lDS
实例。这是我添加用户的方法:
string ldap = "LDAP://xxxx";
var root = new DirectoryEntry(ldap);
var cn = "CN=" + "Joe" + "Blow";
var u = root.Children.Add(cn, "user");
//u.Properties["sAMAccountName"].Value = "jblow";
u.Properties["employeeID"].Value = "654321";
u.Properties["sn"].Value = "Blow";
u.Properties["givenName"].Value = "Joe";
u.Properties["comment"].Value = "a note for you";
u.Properties["homePhone"].Value = "55555555";
u.CommitChanges();
如果我执行此代码,它将成功添加用户Joe Blow
。但是,如果我尝试添加用户名,则会sAMAccountName
收到错误消息:
指定的目录服务属性或值不存在。System.Exception {System.DirectoryServices.DirectoryServicesCOMException}
使用ADSI Edit
我查看了对象的属性,但我没有看到sAMAccountName
那里列出!
如何将用户名添加到AD LDS
实例?