【问题标题】:Server is unwilling to process the request for ActiveDirectory服务器不愿意处理对 ActiveDirectory 的请求
【发布时间】: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.AccountManagementworking。没有错误,一切正常。

         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


    【解决方案1】:

    该错误通常意味着未设置正在创建的对象的某些强制属性。尝试设置 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();
    

    【讨论】:

      猜你喜欢
      • 2019-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-02
      • 1970-01-01
      • 1970-01-01
      • 2010-10-25
      • 1970-01-01
      相关资源
      最近更新 更多