0
を必要LDAP: error code 65 - object class 'inetOrgPerson' requires attribute 'sn'
LDAP:エラー・コード65 - オブジェクトクラス 'のinetOrgPersonは' 属性 'のsn' 私はそれがエラーに与えてレコードを追加私の春application.WhileでLdapTemplateを使用しています
私のリポジトリのコードは
@Autowired
private LdapTemplate ldapTemplate;
@Autowired
private PasswordEncoder passwordEncoder;
public void setLdapTemplate(LdapTemplate ldapTemplate) {
this.ldapTemplate = ldapTemplate;
}
public void create(User user) {
Name dn = buildDn(user);
DirContextAdapter context = new DirContextAdapter(dn);
mapToContext(user, context);
ldapTemplate.bind(dn, context, null);
}
private LdapName buildDn(User user) {
return LdapNameBuilder
.newInstance()
.add("cn", user.getName())
.add("sn", user.getLname())
.add("uid", user.getUid())
.add("userPassword", passwordEncoder.encode(user.getPassword()))
.build();
}
private void mapToContext(User user, DirContextAdapter context) {
context.setAttributeValues("objectclass", new String[] { "top", "inetOrgPerson" });
context.setAttributeValue("uid", user.getName());
context.setAttributeValue("userPassword",
passwordEncoder.encode(user.getPassword()));
}
}
ですまた、inetOrgPersonをperson、organizationalPersonに変更しますが、動作しません。私は以下のコードで、このコードを置き換えるために
dn: ou=roles,dc=cofinding,dc=com
objectclass: top
objectclass: organizationalUnit
ou: roles
dn: ou=people,dc=cofinding,dc=com
objectclass: top
objectclass: organizationalUnit
ou: people
# Users
dn: uid=admin1,ou=people,dc=cofinding,dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Prashant
sn:Thorat
uid: admin1
userPassword: admin1Pass
dn: uid=admin2,ou=people,dc=cofinding,dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Aniket
sn:Patil
uid: admin2
userPassword: admin2Pass
dn: uid=user1,ou=people,dc=cofinding,dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Gautam
sn:Kanawade
uid: user1
userPassword: user1Pass
# Roles
dn: cn=USER,ou=roles,dc=cofinding,dc=com
objectclass: top
objectclass: groupOfNames
cn: USER
member: uid=admin1,ou=people,dc=cofinding,dc=com
member: uid=admin2,ou=people,dc=cofinding,dc=com
member: uid=user2,ou=people,dc=cofinding,dc=com
dn: cn=ADMIN,ou=roles,dc=cofinding,dc=com
objectclass: top
objectclass: groupOfNames
cn: ADMIN
member: uid=admin1,ou=people,dc=cofinding,dc=com
member: uid=admin2,ou=people,dc=cofinding,dc=com