gpt4 book ai didi

java - 无法通过 LDAP 更新 Active Directory 中的员工 ID

转载 作者:行者123 更新时间:2023-11-30 11:01:09 24 4
gpt4 key购买 nike

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

最佳答案

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

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

关于java - 无法通过 LDAP 更新 Active Directory 中的员工 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31322780/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com