如何在 ApacheDS 上解锁用户

How to unlock user on ApacheDS

我设置了启用默认密码策略的 ApacheDS。为了测试建议,我通过多次输入错误的凭据锁定了一个简单的用户(objectClass=Person 扩展了一些自定义 User-objectClass)。如我所料,用户已被锁定(错误消息:用户被永久锁定)。

现在的问题是:如何重新解锁用户?有没有比删除再添加更好的方法?

我对扩展用户 (objectClass=pwdPolicy) 进行了同样的尝试,但是当用户被锁定时没有添加 pwd* 属性。

最近,我在工作中遇到了同样的问题。但是,网上好像没有答案。最后,我通过查看这篇文档找到了答案:

Password Policy for LDAP Directories draft-behera-ldap-password-policy

  • 第 5.3.3 节:pwdAccountLockedTime

This attribute holds the time that the user's account was locked. A
locked account means that the password may no longer be used to
authenticate. A 000001010000Z value means that the account has been
locked permanently, and that only a password administrator can unlock the account.

  • 第 5.2.12 节:pwdLockoutDuration

This attribute holds the number of seconds that the password cannot
be used to authenticate due to too many failed bind attempts. If
this attribute is not present, or if the value is 0 the password
cannot be used to authenticate until reset by a password
administrator
.

通过以上两节,我们可以假设我们应该以管理员身份连接到ApacheDS服务器(默认:uid=admin,ou=system,password=secret),并删除用户的userPassword属性。这样就可以解锁永久锁定的用户了。

我练习了这个sulotion,效果很好。

我建议您设置 pwdLockoutDuration 属性值,这样用户就不会被永久锁定。

更多信息:

ApacheDS password Policy

先生的答案非常适合解锁帐户,如果您想为单个用户设置 pwdLockoutDuration(假设用户已实现对象类 pwdPolicy

还有一个全局配置文件位于:

ou=config
  *  ads-directoryServiceId=<default>
    * ou=interceptors
       * ads-interceptorId=authenticationInterceptor
          * ou=passwordPolicies

这里我们可以设置默认密码策略:

因为我的只是一个测试服务器,我已经通过将 ads-pwdlockout 设置为 FALSE 来完全禁用锁定。有关配置密码策略的更多信息,请阅读 official docs

使用ApacheDS Studio并以管理员身份登录,找到用户,右键单击并选择"Fetch->Fetch operational attributes"。现在 pwdAccountLockedTime 可见,您可以删除它以解锁用户

供参考,这是您通过 java 在服务器上启用此功能的方式:

AuthenticationInterceptor authenticationInterceptor = new AuthenticationInterceptor();      
PasswordPolicyConfiguration config = new PasswordPolicyConfiguration();
config.setPwdLockout(true);
authenticationInterceptor.setPwdPolicies(config);      

然后可以将客户端方法写入 enable/disable 特定帐户,类似于:

 public void disableUser(String dn) throws LdapException, UnsupportedEncodingException 
 {
   Modification disablePassword = new DefaultModification( 
   ModificationOperation.REPLACE_ATTRIBUTE, "pwdAccountLockedTime","000001010000Z" );
   connection.modify(dn,disablePassword);
 }   

 public void enableUser(String dn) throws LdapException, UnsupportedEncodingException 
 {    
   Modification disablePassword = new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, "pwdAccountLockedTime");
   connection.modify(dn,disablePassword);
 }