【问题标题】:Unable to update EmployeeId in ActiveDirectory via LDAP无法通过 LDAP 更新 ActiveDirectory 中的 EmployeeId
【发布时间】: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


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-27
    • 1970-01-01
    相关资源
    最近更新 更多