dsfdsf21312 2014-01-21 06:45
浏览 51

php activerecord身份验证无法连接ldap服务器

I need to authenticate user in active directory in php (using yii framewrok). On one of computer in the network I have virtual machine with windows 2008 server with active directory (port 5000 is used) and I try to connect it using ldap and authenticate user. Controller name is (server1.domain_name).

My code is like this one:

$hostName = '192.168.139.94'; 
$port = 5000;

$userName = 'User1@domain_name';
$password = 'password';

$ldap = ldap_connect($hostName, $port);
if ($bind = ldap_bind($ldap, $userName, $password)) {
    echo 'success';
    // log them in!
} else {
    // error message
    echo 'failed';
}

But get warning:

ldap_bind() [<a href='function.ldap-bind'>function.ldap-bind</a>]: Unable to bind to server: Can't contact LDAP server

Could you please tell what's the problem? How to get more information what causes problem?

  • 写回答

3条回答 默认 最新

  • doulai2025 2014-01-21 08:31
    关注

    Very strange port 5000 for Active-Directory. Native Active-Directory waits on 389, and Lightweigh Directory Server (LDS) naturaly waits on port 50000, when AD exists on the machine. Are you sure for the port ?

    Once the port verified, you can add these two lines between ldap_connect and ldap_bind

    ldap_connec(...)
    ldap_set_option ($ldap, LDAP_OPT_REFERRALS, 0);
    ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_bind(...)
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?