【问题标题】:LDAP Search json outputLDAP 搜索 json 输出
【发布时间】:2022-02-02 16:56:38
【问题描述】:

在我的 mule 流程中,我有一个 LDAP 分页结果搜索,如下所示。我想以 json 格式获取输出。我正在取回一个 ArrayList。

<flow name="ldapsearchFlow1" doc:name="ldapsearchFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="3555" doc:name="HTTP"/>
    <ldap:paged-result-search config-ref="LDAP" baseDn="${xxx.ad.base}" filter="(objectClass=*)" pageSize="100" doc:name="LDAP">
        <ldap:attributes>
            <ldap:attribute>uid</ldap:attribute>
            <ldap:attribute>cn</ldap:attribute>
        </ldap:attributes>          
    </ldap:paged-result-search>
     <ldap:ldap-entry-to-ldif doc:name="ldap1"/>             
    <json:object-to-json-transformer doc:name="Object to JSON" />       
</flow>

输出如下。我也不需要计数,属性计数等。

���sr�java.util.ArrayListx����a��I�sizexp��%w��%t�W{"dn":"CN=aaronj,ou=people,dc=xxx,dc=org","attributes":{"count":1},"attributeCount":1}t�W{"dn":"CN=abbasa,ou=people,dc=xxx,dc=org","attributes":{"count":1},"attributeCount":1}t�X{"dn":"CN=abbottl,ou=people,dc=xxx,dc=org","attributes":{"count":1},"attributeCount":1}t�\{"dn":"CN=abeyrathnep,ou=people,dc=xxx,dc=org","attributes":{"count":1},"attributeCount":1}t�Z

【问题讨论】:

    标签: mule


    【解决方案1】:

    您的配置中有两个问题与ldap-entry-to-ldif 的使用有关:

    • 它将单个 LDAP 条目转换为LDIF,但您使用它来处理来自ldap:paged-result-search集合结果。您需要从搜索结果中选择一个 LDAP 条目(使用 MEL 表达式转换器)或使用 ldap:lookup 返回单个 LDAP 条目。
    • 它将 LDAP 条目转换为它的 LDIF 表示形式,即String。然后将此字符串序列化为 JSON。我认为您需要选择一个,或者将ldap-entry-to-ldif 替换为ldap-entry-to-map,以便它可以正确地序列化为JSON,或者删除json:object-to-json-transformer 并让您的流程返回LDIF 表示。因为您声明要从最终表示中删除一些值,所以我觉得您对 JSON 表示比 LDIF 更感兴趣。在这种情况下,前一种方法是做什么:在ldap-entry-to-map 之后,您可以在 JSON 序列化地图之前使用 MEL 表达式转换器过滤您不想要的保留。

    【讨论】:

      猜你喜欢
      • 2011-08-22
      • 1970-01-01
      • 1970-01-01
      • 2018-01-26
      • 2018-04-27
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多