PHP(Bluemix)安全网关,如何连接和获取数据?

PHP(Bluemix)安全网关,如何连接和获取数据?,php,node.js,sockets,ibm-cloud,secure-gateway,Php,Node.js,Sockets,Ibm Cloud,Secure Gateway,所以我在bluemix上有一个安全的网关。 安全网关正在连接到我本地的LDAP服务。 在安全网关中,我配置了一个相互TLS 目前,我正在使用React\socket客户端进行连接,并且连接成功。我刚才不知道如何在LDAP中查询数据。将始终存在无法连接到LDAP服务器的问题 $loop = React\EventLoop\Factory::create(); $tcpConnector = new React\SocketClient\TcpConnector($loop); $dnsResolv

所以我在bluemix上有一个安全的网关。 安全网关正在连接到我本地的LDAP服务。 在安全网关中,我配置了一个相互TLS

目前,我正在使用React\socket客户端进行连接,并且连接成功。我刚才不知道如何在LDAP中查询数据。将始终存在无法连接到LDAP服务器的问题

$loop = React\EventLoop\Factory::create();
$tcpConnector = new React\SocketClient\TcpConnector($loop);
$dnsResolverFactory = new React\Dns\Resolver\Factory();
$dns = $dnsResolverFactory->createCached('8.8.8.8', $loop);

$dnsConnector = new React\SocketClient\DnsConnector($tcpConnector, $dns);
$secureConnector = new React\SocketClient\SecureConnector($dnsConnector, $loop, array(
    'verify_peer' => true,
    'verify_peer_name' => true,
    'allow_self_signed' => true,
    'cafile' => <CACERT>,
    'local_pk' => <PK_CERT>,
    'local_cert' => <LOCALCERT>
));

$secureConnector->create(<Secure Gateway Link>)->then(function(React\Stream\Stream $stream)
{
 //I'M CONNECTED HERE
//Secure gateway status is establishing connection and not closing
    $ldap_server = "ldap://0.0.0.0";
    $basedn = "<xxx>";
    $auth_user = "<xxx>";
    $auth_pass = "<xxx>";

    if (!($connect = @ldap_connect($ldap_server)))
    {
        throw new Exception("Cannot connect to LDAP");
    } else
    {
        try
        {
            //In order to avoid unable bind to server
            ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
            $bind = ldap_bind($connect, $auth_user, $auth_pass);

            if (!$bind)
            {
                if (ldap_get_option($connect, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error))
                {
                    throw new Exception("Error Binding to LDAP: $extended_error");;
                } else
                {
                    throw new Exception("Error Binding to LDAP: No additional information is available.");
                }

            } else
            {
                //connected to LDAP and do search
               //never goes here
            }
        } catch (Exception $exc)
        {
            $exc->getMessage();
            $stream->end();
        }
    }

}, function($err)
{
    echo $err . '<br>';
    die();
});

$loop->run();
$loop=React\EventLoop\Factory::create();
$tcpConnector=newreact\SocketClient\tcpConnector($loop);
$dnsResolverFactory=new React\Dns\Resolver\Factory();
$dns=$dnsResolverFactory->createCached('8.8.8.8',$loop);
$dnsConnector=new React\SocketClient\dnsConnector($tcpConnector,$dns);
$secureConnector=new React\SocketClient\secureConnector($dnsConnector,$loop,array(
“验证对等体”=>true,
“验证\u对等\u名称”=>true,
“允许自签名”=>true,
“cafile”=>,
“本地_pk”=>,
“本地证书”=>
));
$secureConnector->create()->then(函数(React\Stream\Stream$Stream)
{
//我在这里接通了
//安全网关状态为建立连接而不是关闭
$ldap_服务器=”ldap://0.0.0.0";
$basedn=“”;
$auth_user=“”;
$auth_pass=“”;
如果(!($connect=@ldap\u connect($ldap\u server)))
{
抛出新异常(“无法连接到LDAP”);
}否则
{
尝试
{
//为了避免无法绑定到服务器
ldap_设置_选项($connect,ldap_OPT_协议版本,3);
$bind=ldap\u bind($connect、$auth\u user、$auth\u pass);
如果(!$bind)
{
if(ldap\u get\u选项($connect,ldap\u OPT\u诊断消息,$extended\u error))
{
抛出新异常(“错误绑定到LDAP:$extended_Error”);;
}否则
{
抛出新异常(“绑定到LDAP时出错:没有其他可用信息”);
}
}否则
{
//已连接到LDAP并执行搜索
//从不到这里来
}
}捕获(例外$exc)
{
$exc->getMessage();
$stream->end();
}
}
},函数($err)
{
回显$err.“
”; 模具(); }); $loop->run();
我正在翻译nodejs的代码 到这个代码。。。。 如果有必要,我可以用另一个包,我只是不知道该用什么。 请帮帮我

提前谢谢