PHP警告:ldap_bind():无法绑定到服务器:无法联系LDAP服务器

时间:2011-03-15 08:51:17

标签: php ldap

我的php脚本存在以下问题:

  

PHP警告:ldap_bind():无法绑定到服务器:无法联系LDAP服务器....

ldap_connect()说“成功”,但ldap_bind()失败了,如何解决这个问题?

4 个答案:

答案 0 :(得分:8)

Connect打开会话。绑定是实际验证你的。因此,您已连接但未使用有效凭据登录。

答案 1 :(得分:5)

由于SELinux限制端口HTTPD可以使用RHEL7(CentOS7)上的此错误。

LDAP端口389和636不在默认允许列表中,您可以使用以下命令取消阻止:

setsebool -P httpd_can_network_connect 1

您可以尝试通过LDAP服务器的套接字来测试限制:

fsockopen('LDAP-Server-IP', 389);

它会拒绝权限'显示它已被屏蔽,而不是凭据问题。

还要检查SELinux审核日志文件以查找被阻止的其他内容。

答案 2 :(得分:0)

有时问题将取决于您的环境(Linux,Windows ......) 尝试使用以下选项之一进行绑定:

get_initial

def get_initial(self):
    patient = get_object_or_404(Patient, pk=self.kwargs.get('patient_id'))
    return {
        'patient': patient,
    }

答案 3 :(得分:-1)

ldap_bind()函数要求三个参数:

  1. 资源ID
  2. a rdn
  3. 与rdn相关联的密码rdn和密码是可选的
  4. 如果仅使用资源ID进行绑定: -

    // $ldap=ladap_connect(*hostname*,*port*);  
    // ldap_connect() returns a resource id
    ldap_bind() returns a boolean value(true or false)  
    ldap_bind($ladp); //annonymous bind    
    $lb=ldap_bind($ldap,"uid=xxx,ou=something,o=hostname.com","password"); //used to authenticate  
    

    如果没有,那么你应该使用无效的凭证。

相关问题