gpt4 book ai didi

java - OpenLDAP - 获取密码属性

转载 作者:行者123 更新时间:2023-12-01 06:22:22 26 4
gpt4 key购买 nike

我正在编写一个 OpenLdap Controller ,其中有很多 ldap 函数。其中一个功能是获取一个 LdapUser 及其不同的属性。

例如:

    NamingEnumeration<SearchResult> enumResult = null;
UserData ldapUser = new UserData();

private String[] user_attributes = new String[]{"uid","cn", "sn", "dn", "description", "mail", "displayName",
"userPassword","pwdChangedTime","pwdExpires", "lastLogonTime"};

try
{
SearchControls searchCtrls = new SearchControls();
searchCtrls.setSearchScope(SearchControls.SUBTREE_SCOPE);
searchCtrls.setReturningAttributes(user_attributes);


String filter = "(&(objectClass=inetOrgPerson)(uid="+userUid+"))";

enumResult = ctx.search(ou,filter,searchCtrls);

SearchResult result = (SearchResult) enumResult.next();


ldapUser.setUid(getAttribute(result,"uid"));
ldapUser.setCN(getAttribute(result, "cn"));
ldapUser.setSN(getAttribute(result, "sn"));
ldapUser.setGivenName(getAttribute(result, "givenName"));
ldapUser.setDescription(getAttribute(result, "description"));
ldapUser.setMail(getAttribute(result, "mail"));

}

效果很好。我的 ldapUser 类充满了属性。我之前对 TDS Controller 做了同样的事情,我什至可以使用以下属性:

        ldapUser.setPassword(getAttribute(result, "userPassword"));
ldapUser.setpwdExpires(getAttribute(result,"pwdExpires"));
ldapUser.setpwdChangedTime(getAttribute(result, "pwdChangedTime"));
ldapUser.setlastLogonTime(getAttribute(result,"lastLogonTime"));

但这似乎不再适用于 OpenLdap。有谁知道或有解决方案从 OpenLdap 获取 java 中的这些密码属性吗?

致以诚挚的问候

最佳答案

The "password" is most likely either a hash of the real password or an encrypted version.

来源:How to retrieve LDAP password via JNDI

另请参阅http://bethecoder.com/applications/tutorials/java/ldap/how-to-query-password-attribute-of-ldap-entry.html

关于java - OpenLDAP - 获取密码属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45281548/

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