我一直在尝试设置/重置我在AD中创建的用户的用户密码。我使用Spring启动Ldaptemplate以连接到我的Active目录。我成功地创建了用户,但每当我尝试设置密码时,我都会得到LDAP异常53,这就是说
javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 0000001F: SvcErr: DSID-031A11E5, problem 5003 (WILL_NOT_PERFORM), data 0
我用谷歌搜索并按照不同帖子中提到的选项但没有运气。
以下用于添加新用户的代码段。
Name dn = buildDn(email);
DirContextAdapter context = new DirContextAdapter(dn);
context.setAttributeValues("objectclass", new String[] { "top", "person", "organizationalPerson", "user" });
context.setAttributeValue("mail", email);
context.setAttributeValue("userPrincipalName", "user principal email");
context.setAttributeValue("userAccountControl","544"); //somehow 512 throws an exception not sure of the reason (user account is enabled with no password required)
context.setAttributeValue("sAMAccountName", "***");
context.setAttributeValue("pwdLastSet", "-1");
ldapTemplate.bind(context); //this creates user successfully.
以下是我迄今为止尝试过的事情:
ModificationItem[] mods = new ModificationItem[1]; mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("UnicodePwd", pwdArray)); context.modifyAttributes(dn, mods); ldapTemplate.modifyAttributes(buildDn(email), new ModificationItem[] { mods[0] }); LDAP://servername:636.
我仍然看到与LDAP 53 svcerror相同的错误。请让我知道我在这里失踪了什么。