私は、LdapTemplateを使ってLdapリポジトリのユーザ情報を取得するためのアプリケーションspring-bootを開発しています。ldapリポジトリのuidを変更します。
ユーザーの電子メールをuidとして使用します。ユーザーが電子メールを更新すると、uidも更新する必要があります。問題は、以下のメソッドはすべてのPersonフィールドで動作しますが、UIDでは動作しません。私はエラーを取得する:
LDAP: error code 64 - value of naming attribute 'uid' is not present in entry
これは抜粋です:
public void updateUser(Person p) throws InvalidNameException {
Name dn = buildDn(p);
DirContextOperations context = ldapTemplate.lookupContext(dn);
LdapMapper.mapToContext(p, context);
ldapTemplate.modifyAttributes(context);
}
BuildDn:
public Name buildDn(Person p) throws InvalidNameException {
List<Rdn> lstRdn = new ArrayList<Rdn>();
lstRdn.add(new Rdn("dc", "priv"));
lstRdn.add(new Rdn("dc", "com"));
lstRdn.add(new Rdn("ou", "customers"));
lstRdn.add(new Rdn("ou", "myusers");
lstRdn.add(new Rdn("uid", "oldUid"));
Name name = new LdapName(lstRdn);
return name;
}
マッパー
public static void mapToContext(Person p, DirContextOperations context) {
context.setAttributeValues("objectclass", new String[] { "top", "person", "inetOrgPerson", "organizationalPerson" });
context.setAttributeValue("cn", p.getFirstName());
context.setAttributeValue("sn", p.getLastName());
context.setAttributeValue("mail", p.getEmail());
context.setAttributeValue("userPassword", p.getPassword());
context.setAttributeValue("uid", "NewUid");
}
は、あなたがこのバグを修正するための任意のアイデアを持っているでしょう?
敬具