1
누군가 Ldap의 posixAccount에서이 오류를 이미 발견 했습니까? Ldap에 대한 uidNumber 생성 LdapTemplate을 사용하는 posixAccount
javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - object class 'posixAccount' requires attribute 'uidNumber']
대신 고유성을 찾아 돌보는의 LDAP에 작성을 위임 고유 UidNumber를 생성하는 현명한 방법이 있나요?
감사 (부여 됨으로써 SQL Server의 ID 열 등) 여기
코드 내가 사용 : 서버가 수정 - 증가 요청 제어를 지원
public class LdapService {
//...
private LdapTemplate ldapTemplate;
public UserInfo save(final UserInfo user) {
Name dn = buildDn(user);
ldapTemplate.bind(dn, null, buildUserAttributes(user));
// Update Groups
for (String group : user.getGroups()) {
try {
DistinguishedName groupDn = new DistinguishedName();
groupDn.add("ou", "groups");
groupDn.add("cn", group);
DirContextOperations context = ldapTemplate
.lookupContext(groupDn);
context.addAttributeValue("memberUid", user.getUid());
ldapTemplate.modifyAttributes(context);
} catch (Exception e) {
e.printStackTrace();
}
}
return user;
}
private Attributes buildUserAttributes(final UserInfo user) {
Attributes attrs = new BasicAttributes();
BasicAttribute ocattr = new BasicAttribute("objectclass");
ocattr.add("top");
ocattr.add("inetOrgPerson");
ocattr.add("posixAccount");
attrs.put(ocattr);
attrs.put("givenName", user.getName());
attrs.put("sn", user.getSurname());
if (user.getDisplayName() != null)
attrs.put("cn", user.getDisplayName());
attrs.put("userPassword", "{SHA}" + this.encrypt(user.getPassword()));
attrs.put("mail", user.getEmail());
return attrs;
}
//...
}