无法使用net-ldap启用活动目录用户

时间:2016-04-18 17:07:45

标签: ruby active-directory windows-server-2012-r2 netldap

我们在尝试使用TypeError: (0 , _configureStore.configureStore) is not a function 库启用活动目录用户(windows server 2012 r2)时遇到问题。

设置

首先,我们通过此方法创建用户:

net/ldap

这会创建用户,默认情况下将def create_user(attrs) dn = "cn=#{attrs[:cn]},cn=Users,#{@base}" cn = attrs[:cn] pass = ascii_convert(attrs[:pwd]) updated_attrs = { cn: cn, objectclass: ['user'], samaccountname: cn, userprincipalname: "#{attrs[:cn]}@#{@domain}", unicodepwd: pass } @connection.add(dn: dn, attributes: updated_attrs) result = @connection.get_operation_result raise LdapError.new("Create AD user error: #{result}") if result.code != 0 end 属性设置为userAccountControl(这就是我们想要的),在活动目录中检查时显示为:

546

问题

稍后我们要启用该用户,以便我们致电:

0x222 (ACCOUNTDISABLE|PASSWD_NOTREQD|NORMAL_ACCOUNT)

但是,如果我打印def enable_user!(dn, cn) u = search_query(find_user(cn)).try(:first) if u @connection.replace_attribute(dn, :useraccountcontrol, '512') else false end end ,我会:

@connection.get_operation_result

使用此方法,我们希望<OpenStruct code=53, error_message="0000052D: SvcErr: DSID-031A12D2, problem 5003 (WILL_NOT_PERFORM), data 0\n\u0000", matched_dn="", message="Unwilling to perform">等于userAccountControl,相当于512

我尝试过的事情

注意:连接是通过SSL(LDAPS),并绑定到管理员AD帐户。

  • this answer
  • 0x200 (NORMAL_ACCOUNT)方法中使用#modify代替#replace_attribute
  • 传递十六进制值而不是整数表示。
  • 使用apache directory studio执行相同的修改。

我注意到一件有趣的事情,就是我可以将enable_user!修改为useraccountcontrol,这是:

514

所以,似乎我可以修改此属性,只要它仍然被禁用,只要我尝试更改为启用就是在我看到错误时。

1 个答案:

答案 0 :(得分:1)

错误0000052Dsystem error code。具体来说,这意味着:

  

ERROR_PASSWORD_RESTRICTION

     

1325(0x52D)

     

无法更新密码。为新密码提供的值不符合域的长度,复杂性或历史记录要求。

问题似乎是您启用的帐户已应用密码策略,从而使其无法满足密码策略。

我首先要弄清楚该帐户的密码策略是什么,然后在翻转该位以启用它之前将密码设置为符合该策略条件的密码。

但是,如果您确实希望用户能够在没有密码的情况下登录,则应将密码设置为null。但我不确定在什么情况下这是可取的。