Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP LDAP工作不安全_Php_Ldap_Ssl - Fatal编程技术网

PHP LDAP工作不安全

PHP LDAP工作不安全,php,ldap,ssl,Php,Ldap,Ssl,我正在尝试让一个PHP中的LDAPs客户端工作。我的代码已经就位,并且使用标准LDAP协议工作 然而,当我改变ldap://server 到ldaps://server,它不起作用。将调试模式设置为7会产生此错误。我应该补充一点,这是一个使用openSSL的linux服务器 有没有办法克服这个问题?在LDAP服务器上更改任何内容都不是一个选项,因为我对它只有客户端权限 编辑:只有我的LDAP.conf中的设置是 TLS_请求证书从不 这是我的密码 if(isset($_POST['pass'])

我正在尝试让一个PHP中的LDAPs客户端工作。我的代码已经就位,并且使用标准LDAP协议工作

然而,当我改变ldap://server 到ldaps://server,它不起作用。将调试模式设置为7会产生此错误。我应该补充一点,这是一个使用openSSL的linux服务器

有没有办法克服这个问题?在LDAP服务器上更改任何内容都不是一个选项,因为我对它只有客户端权限

编辑:只有我的LDAP.conf中的设置是

TLS_请求证书从不

这是我的密码

if(isset($_POST['pass'])){
    $username = $_POST['user'];
    $password = $_POST['pass'];

    ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);



    $ds=ldap_connect("ldaps://server.com");  

    ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3) ;
    //Check LDAP server for user
        if(!@ldap_bind($ds, "uid={$username},ou=people,o=site.ca,o=site", "{$password}") || strlen($password)==0){
    //      LDAP login was not successful
            printf("Sorry, wrong username/password\n\n\n");
            return;
        }

    $ldapSearch=@ldap_search($ds, "ou=people,o=site.ca,o=site", "uid={$_POST['user']}");
    $result = @ldap_get_entries($ds, $ldapSearch);


}

首先,这是给Ryerson的?来吧(我以前在约克大学工作过!我得逗一下城里的人。更糟的是,你可能在T大学工作!)。但说真的,根据后端的LDAP服务器,通常有两种方法

ldaps://ldap.ryerson.ca:636 可能工作得更好,因为它将尝试执行SSL绑定,希望您信任为SSL使用的证书签名的CA的公钥

TLS实际上是SSL V3.1,它添加的一个非常好的特性是,它在端口389上也可以正常工作,但可以发出StartTLS命令,该命令接受您在389上启动的明文连接并启用加密


我的怀疑是,从错误代码来看,它试图在明文端口上通过SSL创建LDAP,这将失败

这可能是由于您的libgnutls版本中存在错误造成的

if(isset($_POST['pass'])){
    $username = $_POST['user'];
    $password = $_POST['pass'];

    ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);



    $ds=ldap_connect("ldaps://server.com");  

    ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3) ;
    //Check LDAP server for user
        if(!@ldap_bind($ds, "uid={$username},ou=people,o=site.ca,o=site", "{$password}") || strlen($password)==0){
    //      LDAP login was not successful
            printf("Sorry, wrong username/password\n\n\n");
            return;
        }

    $ldapSearch=@ldap_search($ds, "ou=people,o=site.ca,o=site", "uid={$_POST['user']}");
    $result = @ldap_get_entries($ds, $ldapSearch);


}