gpt4 book ai didi

java - 如何从 javax.naming.directory.Attribute 中提取值

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:10:30 25 4
gpt4 key购买 nike

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

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());
}
}
}

我怎样才能只得到没有 key 部分的值:WF-008-DAM-PS?问候。

最佳答案

解决方法是:

Attribute groupCn = attributes.get("cn");
String value = groupCn.get();

关于java - 如何从 javax.naming.directory.Attribute 中提取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12162898/

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