我试图以编程方式将用户添加到AD lDS
实例。下面是如何增加一个用户:轻量级目录服务实例中缺少sAMAccountName
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
我得到一个错误:
The specified directory service attribute or value does not exist.System.Exception {System.DirectoryServices.DirectoryServicesCOMException}
使用ADSI Edit
我看着对象的属性和我没有看到sAMAccountName
上市那里!
我如何添加用户名AD LDS
实例?
感谢您的答复。我犯了同样的错误。 – smr5 2015-02-05 17:27:48
您是否尝试过设置userPrincipalName? – Blake 2015-02-05 17:55:23
我有,它的工作原理。从我的阅读'userPrincipalName'格式为'username @ domain.com'。这可以用作用户名吗? – smr5 2015-02-05 18:12:04