doucheng5705 2013-12-29 02:36
浏览 37
已采纳

PHP LDAP使用哈希绑定

I have a client, a REST API server, and an LDAP server. I'd like the client to authenticate into the API using LDAP authentication, however I would like to avoid sending plaintext passwords.

How can I perform and PHP LDAP authentication using a hash instead of plaintext passwords?

  • 写回答

1条回答 默认 最新

  • dskm94301 2013-12-29 17:16
    关注

    That's not possible in this way. So you don't want to store the plaintext password on the client side, just the hash, and send nothing but the hash to the server. Now noone can get at the real password by a) reading the client config file or b) using a network trace tool like wireshark. But, in this scenario, the server can't know if the client knows the password or just the hash, so it trusts the hash alone. Which means anybody who can get the hash can use it instead of the password, so you gain no security at all.

    The correct thing to do is to setup your ldap server in a way that enables ssl-encryption, and to tell php to use the ssl encryption when connecting. From the PHP docs:

    <?php
    $ldaphost = "ldaps://ldap.example.com/";
    
    $ldapconn = ldap_connect( $ldaphost ) 
              or die( "Cannot connect" );
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
    
    ?>
    

    note the ldap*s* in the URL.

    To use SSL, you need a certificate as well -- otherwise the client doesn't know the server is the real server, and could possible send the credentials to a different server which is impersonating the real one.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题