Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 服务器不愿意处理对ActiveDirectory的请求_C#_Active Directory - Fatal编程技术网

C# 服务器不愿意处理对ActiveDirectory的请求

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

我尝试在广告中创建一个用户

现在,我得到一个错误:

0000052D:SvcErr:DSID-031A1248,问题5003(将不执行),数据0

服务器不愿意处理该请求

翻译:El servidor没有律师资格

我的实际遗留代码(主片段):

注意:
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();