我正在为 LDAP 使用 openDJ,我无法从 spring ldap 模板更改 openDJ 中的 ds-pwp-account-disabled 属性值。
我已经通过 spring ldap 创建了 DirContextOperations 类对象。当我使用 spring ldap 获取 ds-pwp-account-disabled 属性的值时,它会给出。但它不允许通过 spring ldap 更新 ds-pwp-account-disabled 属性值。你能帮我如何通过spring ldap更新ds-pwp-account-disabled属性值。我在谷歌读了很多文章,可以通过springldap修改opendj中的权限问题,也可以是其他的。
我正在分享一些代码来确定我如何使用 open DJ 使用 spring ldap -
私人 LdapTemplate ldapTemplate;
ErrorDTO createAccountIfNotExists(Account account){
DirContextAdapter context = new DirContextAdapter(dn);
context.setAttributeValues(OBJECTCLASS, new String[] { TOP, USERACCOUNTS });
mapToContext(account, context);
try {
ldapTemplate.bind(context);
} catch (Exception e) {
}
return error;
}
public LdapTemplate getLdapTemplate() {
return ldapTemplate;
}
public void setLdapTemplate(LdapTemplate ldapTemplate) {
this.ldapTemplate = ldapTemplate;
}
void mapToContext(Account account, DirContextOperations context) {
context.setAttributeValue("cn", account.getFirstName());
context.setAttributeValue("sn", account.getLastName());
context.setAttributeValue("x-user-id", account.getUserId());
context.setAttributeValue("mail", account.getEmail());
context.setAttributeValue("givenname", account.getFirstName());
context.setAttributeValue("mobile", account.getMobilePhone());
context.setAttributeValue("telephonenumber", account.getBusinessPhone());
context.setAttributeValue("title", account.getJobTitle());
context.setAttributeValue("x-incident-ref", account.getIncidentRef());
context.setAttributeValue("x-client-category", account.getClientCategory());
context.setAttributeValue("x-organization", account.getOrganization());
context.setAttributeValue("facsimiletelephonenumber", account.getFax());
context.setAttributeValue("x-bureau", account.getBureau());
context.setAttributeValue("x-company", account.getCompany());
context.setAttributeValue("ds-pwp-account-disabled", account.getEnabled());
if (account.getAccountCode() != null) {
context.setAttributeValue("x-account-code", account.getAccountCode());
context.setAttributeValue("uid", account.getAccountCode() + "#" + account.getUserId());
} else {
context.setAttributeValue("uid", account.getUserId());
}
}
下面给出错误 - org.springframework.ldap.InvalidAttributeValueException: Malformed 'ds-pwp-account-disabled' 属性值;嵌套异常是 javax.naming.directory.InvalidAttributeValueException: Malformed 'ds-pwp-account-disabled' 属性值;剩余名称 'uid=coy#user8,ou=User Accounts'