1 回答

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
ctx.getAttributes(username, new String[] {"*", "+"});
用戶名 - 根據(jù)文檔,這應(yīng)該是 DN 這就是 LDAP 知道您從哪個(gè)記錄中提取數(shù)據(jù)的方式
第二個(gè)參數(shù),如果設(shè)置為null,它將檢索所有屬性
我相信您的錯(cuò)誤被拋出,因?yàn)槟鷤鬟f的是用戶名而不是專有名稱。
/**
* Retrieves selected attributes associated with a named object.
* See {@link #getAttributes(Name, String[])} for details.
*
* @param name
* The name of the object from which to retrieve attributes
* @param attrIds
* the identifiers of the attributes to retrieve.
* null indicates that all attributes should be retrieved;
* an empty array indicates that none should be retrieved.
* @return the requested attributes; never null
*
* @throws NamingException if a naming exception is encountered
*/
public Attributes getAttributes(String name, String[] attrIds)
throws NamingException;
添加回答
舉報(bào)