【发布时间】:2016-09-15 04:55:55
【问题描述】:
我尝试在 AD 中创建用户。
现在,我得到了错误:
0000052D:SvcErr:DSID-031A1248,问题 5003 (WILL_NOT_PERFORM),数据 0
服务器不愿意处理请求
翻译:El servidor no puede procesar la solicitud。
我的实际遗留代码(主要片段):
SearchResult ret = searcher.FindOneReturningDirectorySearchResult();
if (ret == null)
throw new ObjectNotFoundException("group", searcher.GetFilter());
using (DirectoryEntry parent = ret.GetDirectoryEntry())
{
parent.RefreshCache();
using (DirectoryEntry newUser = parent.Children.Add("CN=" + this.CommonName, CommonPropertyNames.ObjectClassNames.UserObjectClassName))
{
Utility.SetProperty(newUser, UserPropertyNames.Name, this.CommonName);
Utility.SetProperty(newUser, "userPassword", "Cambia$123");
FillUserProperties(newUser);
newUser.CommitChanges();
注意:
newUser.CommitChanges()抛出错误。
现在,如果我尝试使用 System.DirectoryServices.AccountManagement 是working。没有错误,一切正常。
string OuDnDES = "OU=Portal,OU=NSI DESARROLLO,DC=company,DC=net";
using (var pc = new System.DirectoryServices.AccountManagement.PrincipalContext(System.DirectoryServices.AccountManagement.ContextType.Domain,
"mydomain.net",OuDnDES, "mydomain\\DES_GestorDirectorio", "1234"))
{
using (var up = new System.DirectoryServices.AccountManagement.UserPrincipal(pc))
{
up.SamAccountName = "testAD001";
up.EmailAddress = "test@realexx.es";
up.SetPassword("Change$123");
up.Enabled = true;
up.ExpirePasswordNow();
up.Save();
}
}
我无法使用 System.DirectoryServices.AccountManagement,我的 NET 3.5 之前的版本。
有什么建议吗?
【问题讨论】:
标签: c# active-directory