无法通过LDAP更新ActiveDirectory中的EmployeeId

时间:2015-07-09 16:08:21

标签: java active-directory ldap spring-ldap

我正在使用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);

1 个答案:

答案 0 :(得分:1)

我明白了。 DTO上的数据类型是int。设置属性时更改为字符串可解决问题:

context.setAttributeValue("employeeId", Integer.toString(employee.getEmployeeID()));