C# 服务器不愿意处理对ActiveDirectory的请求
我尝试在广告中创建一个用户 现在,我得到一个错误: 0000052D:SvcErr:DSID-031A1248,问题5003(将不执行),数据0 服务器不愿意处理该请求 翻译:El servidor没有律师资格 我的实际遗留代码(主片段): 注意:C# 服务器不愿意处理对ActiveDirectory的请求,c#,active-directory,C#,Active Directory,我尝试在广告中创建一个用户 现在,我得到一个错误: 0000052D:SvcErr:DSID-031A1248,问题5003(将不执行),数据0 服务器不愿意处理该请求 翻译:El servidor没有律师资格 我的实际遗留代码(主片段): 注意:newUser.CommitChanges()抛出错误 现在,如果我尝试使用System.DirectoryServices.AccountManagement可以工作。没有错误,一切正常 string OuDnDES = "OU=P
newUser.CommitChanges()
抛出错误
现在,如果我尝试使用System.DirectoryServices.AccountManagement可以工作。没有错误,一切正常
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
有什么建议吗?该错误通常意味着未设置所创建对象的某些必需属性。尝试设置sAMAccountName属性
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");
Utility.SetProperty(newUser, "sAMAccountName", "testAD001");
FillUserProperties(newUser);
newUser.CommitChanges();
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");
Utility.SetProperty(newUser, "sAMAccountName", "testAD001");
FillUserProperties(newUser);
newUser.CommitChanges();