【问题标题】:LDAP UnboundId: get all values of attribute from single entryLDAP UnboundId:从单个条目中获取所有属性值
【发布时间】:2014-09-17 02:11:34
【问题描述】:

我有这个代码

    // get the search results, getConnection = LDAPConnection
    SearchResult searchResults = getConnection().search(basedn,
            SearchScope.SUB, "(cn=JacobKranz)", "description");

    System.out.println(searchResults.getEntryCount());
    if (searchResults.getEntryCount() > 0)
    {
        for(int i=0; i < searchResults.getEntryCount(); i++)
        {
            //System.out.println(i);
            SearchResultEntry entry = searchResults.getSearchEntries().get(i);

            System.out.println(entry.getAttributeValue("description"));

        }

    }

cn=JacobKranz 的条目添加了多个描述,但我只能获得第一个值,而不是循环遍历每个值。

我将如何获取所有值?

【问题讨论】:

    标签: java ldap unboundid-ldap-sdk


    【解决方案1】:

    使用多值 API:

    for(String v : entry.getAttributeValues("description")) {
        System.out.println(String.format("description value: %s", v));
    }
    

    【讨论】:

    • 我知道我忽略了一些简单的事情。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多