使用UserPrincipal类创建新的AD-LDS用户总是失败
问题描述:
如果我想在ADAM(Ad LDS)目录(也可能在Active Directory中,我没有测试过)创建一个UserPrincipal类的新用户,它总是失败,出现以下消息:“校长不能启用,因为现有的帐户控制标志不能读取”使用UserPrincipal类创建新的AD-LDS用户总是失败
我使用的代码如下:
using (UserPrincipal user = new UserPrincipal(ctx,userName,password,[false/true])) {
// ...
}
答
它变成了ou这是AccountManagement-Namespace中的另一个错误。创建没有任何属性的用户,稍后分配属性,保存用户并在保存后启用它。这有助于。
using (UserPrincipal user = new UserPrincipal(ctx)) {
user.Name = userName;
user.UserPrincipalName = userName;
user.SetPassword(password);
user.Save();
user.Enabled = true;
user.Save();
}
有一个connect-entry,和可悲的是,MS中写道此项,他们不是愿意来修复这个bug。