【发布时间】:2015-07-09 16:08:21
【问题描述】:
我正在使用 Spring LDAP 在 Active Directory 中创建新用户帐户。这很好用,但是当我添加 EmployeeId 属性时,我得到一个 javax.naming.directory.InvalidAttributeValueException (找不到属性)。默认情况下,该属性不可见,并且已在我们的 Active Directory 中启用 - 如果我使用 Spring LdapQuery 进行搜索,我可以在属性列表中看到它。通过 LDAP 设置 EmployeeId 有什么技巧吗?代码很简单,我怀疑这将是一些 AD 配置设置。
DirContextAdapter context = new DirContextAdapter(dn);
context.setAttributeValues("objectclass", new String[] { "person", "user" });
context.setAttributeValue("displayName", employee.getFullName());
context.setAttributeValue("givenName", employee.getFirstName());
context.setAttributeValue("sn", employee.getLastName());
context.setAttributeValue("cn", employee.getCn());
**context.setAttributeValue("employeeID", employee.getEmployeeID());**
context.setAttributeValue("sAMAccountName", employee.getAccountName());
...
ldapTemplate.bind(context);
【问题讨论】:
-
employee.getEmployeeID()的返回类型是什么?您是否有更新权限(仅限域管理员)来添加/更改此值? msdn.microsoft.com/en-us/library/windows/desktop/… -
该帐户确实具有域管理员权限。
-
尝试使用
organizationalPerson作为额外的objectClass。属性employeeID是Organizational-Person 的属性。 -
感谢您的推荐。我也试过了,没有变化:
'context.setAttributeValues("objectclass", new String[] { "person", "user", "organizationalPerson" });javax.naming.directory.InvalidAttributeValueException: Malformed 'employeeId' 属性值 -
employee.getEmployeeID()的返回类型是String还是null?
标签: java active-directory ldap spring-ldap