作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人在 Ldap 中创建 posixAccount 时遇到过这个错误吗?
javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - object class 'posixAccount' requires attribute 'uidNumber']
有没有一种聪明的方法来生成一个唯一的 UidNumber,将创建委托(delegate)给 Ldap 而不是注意找出唯一性? (例如 SQL Server 中的标识列)
谢谢
这里是我使用的代码:
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;
}
//...
}
最佳答案
如果您的服务器支持修改-递增请求控制,LDAP 客户端可以使用它在一个原子操作中递增一个整数。另请参阅:LDAP: Modify-Increment Extension .
关于java - 使用 LdapTemplate 为 Ldap posixAccount 生成 uidNumber,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17110452/
在我的 ldap 用户创建中只想自动生成属性 uidNumber。一个唯一的自动生成的,以便我可以将其用作主键或唯一的用户 ID。 最佳答案 你不能。 OpenLDAP 不支持。 关于ldap - O
我正在尝试在 Linux (Centos) 上设置 OpenLDAP 服务器和客户端。搜索了一下后,我的理解是 gidnumber 和 uidnumber 像 unix 上的 uid 和 gid 一样
有人在 Ldap 中创建 posixAccount 时遇到过这个错误吗? javax.naming.directory.SchemaViolationException: [LDAP: error
我是一名优秀的程序员,十分优秀!