【问题标题】:How to add new password Attribute with Apache LDAP API如何使用 Apache LDAP API 添加新密码属性
【发布时间】:2014-03-07 15:01:09
【问题描述】:

我正在使用 Apache LDAP API 设置新属性:Oracle Internet Directory 中的 userPassword。我想用 SHA 加密方法设置这个密码。我目前有以下代码:

Attribute userPasswordAttribute = new DefaultAttribute("userPassword", "password"));
ModifyRequest modifyRequest = new ModifyRequestImpl();
modifyRequest.setName(dn);
modifyRequest.add(userPasswordAttribute);
ModifyResponse response = connection.modify(modifyRequest);

但是,这会添加 SSHA 加密密码以及我不想要的其他一些属性 (authpassword;oid)。我已经看到 LDAP API 中有一个名为 EncryptionMethod 的类,但是如何在我的代码中使用它?

【问题讨论】:

    标签: java ldap oid


    【解决方案1】:

    试试这个

    String newPassword = "password";
    modifyRequest.replace("userPassword", PasswordUtil.createStoragePassword(
                                newPassword.getBytes(), LdapSecurityConstants.HASH_METHOD_SHA));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-02
      • 1970-01-01
      • 2020-02-29
      • 2017-09-25
      • 2018-06-18
      • 2019-11-23
      • 1970-01-01
      相关资源
      最近更新 更多