这个问题说明了一切。当我打印属性时,它是:

cn: WF-008-DAM-PS

该代码段是:
private void searchGroup() throws NamingException {
    NamingEnumeration<SearchResult> searchResults = getLdapDirContext().search(groupDN, "(objectclass=groupOfUniqueNames)", getSearchControls());
    String searchGroupCn = getCNForBrand(m_binder.getLocal("brandId"), m_binder.getLocal("brandName"));
    Log.info(searchGroupCn);
    while (searchResults.hasMore()) {
        SearchResult searchResult = searchResults.next();
        Attributes attributes = searchResult.getAttributes();
        Attribute groupCn = attributes.get("cn");
        if(groupCn != null) {
            Log.info(groupCn.toString());
        }
    }
}

我如何只获取WF-008-DAM-PS的值,即没有关键部分?
问候。

最佳答案

调用getValue()方法或getValue(int)方法。

09-28 14:47