【发布时间】:2019-01-11 10:57:05
【问题描述】:
我正在尝试更改 Active Directory 上的用户密码,我使用的方法是:
ldapContext = getContext(resourceName);
String quotedPassword = '"' + password.decryptToString() + '"';
ModificationItem[] modifications = new ModificationItem[1];
modifications[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(PASSWORD_ATTRIBUTE_NAME, quotedPassword.getBytes("UTF-16LE")));
ldapContext.modifyAttributes(dn, modifications);
这很好用。
现在我想添加对密码历史记录的控制,以使用户无法设置最后 x 组密码。
这不起作用:
final String LDAP_SERVER_POLICY_HINTS_OID = "1.2.840.113556.1.4.2239";
ldapContext = getContext(resourceName);
String quotedPassword = '"' + password.decryptToString() + '"';
ModificationItem[] modifications = new ModificationItem[1];
modifications[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(PASSWORD_ATTRIBUTE_NAME, quotedPassword.getBytes("UTF-16LE")));
BasicControl[] controls = new BasicControl[1];
final byte[] controlData = {48,(byte)132,0,0,0,3,2,1,1};
controls[0] = new BasicControl(LDAP_SERVER_POLICY_HINTS_OID, true, controlData);
ldapContext.setRequestControls(controls);
ldapContext.modifyAttributes(dn, modifications);
知道我正在使用 SSL 连接,并且我设置的 OID 列在 ROOT DSE 的支持控件中,我收到此错误:
javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 0000052D: SvcErr: DSID-031A12D2, problem 5003 (WILL_NOT_PERFORM), data 0
我被困住了,因为我不知道问题出在哪里,感谢任何帮助。
提前致谢
【问题讨论】:
-
如果与 SSL 无关,您可能会在 AD 环境中遇到密码策略。
-
感谢您的回答@Theo。我怎么做?你怀疑我没有遵守现有的密码政策吗?
标签: java active-directory change-password