LDAP wso2 esb中的SearhEntry操作

时间:2017-08-21 07:16:09

标签: search ldap wso2 esb

我正在尝试在wso2 esb中使用LDAP中的searchEntry操作来搜索特定的emailid。我将如何为此创建请求有效负载?你能举个例子吗?任何帮助将不胜感激。 提前致谢

2 个答案:

答案 0 :(得分:0)

请您尝试使用以下示例代理进行上述操作(searchEntry): 这里我们使用有效负载工厂中介为代理内部的searchEntry操作构建请求有效负载。

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ldap_search_payload"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="https,http">
   <target>
      <inSequence>
         <payloadFactory media-type="json">
            <format>
            {
              "providerUrl": "ldap://XYZ.example.com:389/",
              "securityPrincipal": "cn=admin,dc=example,dc=com",
              "securityCredentials": "password",
              "secureConnection": "",
              "disableSSLCertificateChecking": "false",
             "dn": "ou=People,dc=example,dc=com",
             "objectClass": "inetOrgPerson",
             "attributes": "uid",
             "filters": {
                "mail": "testDim2@wso2.com"
              },
            "onlyOneReference": "false"
 }
       </format>
            <args/>
         </payloadFactory>
         <property expression="json-eval($.objectClass)" name="objectClass"/>
         <property expression="json-eval($.dn)" name="dn"/>
         <property expression="json-eval($.attributes)" name="attributes"/>
         <property expression="json-eval($.onlyOneReference)" name="onlyOneReference"/>
         <property expression="json-eval($.providerUrl)" name="providerUrl"/>
         <property expression="json-eval($.securityPrincipal)" name="securityPrincipal"/>
         <property expression="json-eval($.securityCredentials)"
                   name="securityCredentials"/>
         <property expression="json-eval($.filters)" name="filters"/>
         <property name="messageType" scope="axis2" value="application/json"/>
         <property name="ContentType" scope="axis2" value="application/json"/>
         <ldap.init>
            <providerUrl>{$ctx:providerUrl}</providerUrl>
            <securityPrincipal>{$ctx:securityPrincipal}</securityPrincipal>
            <securityCredentials>{$ctx:securityCredentials}</securityCredentials>
            <secureConnection>{$ctx:secureConnection}</secureConnection>
            <disableSSLCertificateChecking>{$ctx:disableSSLCertificateChecking}</disableSSLCertificateChecking>
         </ldap.init>
         <ldap.searchEntry>
            <objectClass>{get-property('objectClass')}</objectClass>
            <dn>{get-property('dn')}</dn>
            <attributes>{get-property('attributes')}</attributes>
            <filters>{get-property('filters')}</filters>
            <onlyOneReference>{get-property('onlyOneReference')}</onlyOneReference>
         </ldap.searchEntry>
         <respond/>
      </inSequence>
      <faultSequence>
         <respond/>
      </faultSequence>
   </target>
   <description/>
</proxy>

请在调用上述代理时找到响应

{
    "result": {
        "entry": [
            {
                "dn": "uid=john_002,ou=People,dc=example,dc=com",
                "uid": "john_002"
            },
            {
                "dn": "uid=john_003,ou=People,dc=example,dc=com",
                "uid": "john_003"
            }
        ]
    }
}  

在此示例中,我获得了相关的搜索条目,其中包含电子邮件ID&#34; testDim2@wso2.com"与&#34; uid&#34;该电子邮件ID属性在响应中的属性。

答案 1 :(得分:0)

我通过设置以下与ldap匿名连接的参数来实现它。

"securityPrincipal":"",
   "securityCredentials":"",
   "secureConnection":"true",
   "disableSSLCertificateChecking":"true",