php - CodeIgniter - “ldap_bind():无法绑定到服务器:无法联系 LDAP 服务器”来自 localhost
问题描述
我必须使用 CodeIgniter 3 处理用 PHP 5.5 编写的旧应用程序。
对于身份验证,它使用 ldap 连接到具有 Auth_AD 库的私有服务器。
在生产服务器和测试服务器中,此 ldap 连接成功,但是当我尝试从本地主机内进行身份验证时,我收到此错误
A PHP Error was encountered
Severity: Warning
Message: ldap_bind(): Unable to bind to server: Can't contact LDAP server
Filename: libraries/Auth_AD.php
Line Number: 388
凭据在任何地方都完全相同。
这是在第 388 行调用的函数(第一次 ldap_bind() 调用):
private function bind_ad()
{
// preset the continuation marker
$continue = true;
// attempt to connect to each of the AD servers, stop if a connection is succesful
foreach ($this->_hosts as $host) {
$this->_ldap_conn = ldap_connect($host);
if ($this->_ldap_conn) {
break;
} else {
log_message('info', 'Auth_AD: Error connecting to AD server ' . $host);
}
}
// check for an active LDAP connection
if (!$this->_ldap_conn) {
log_message('error', "Auth_AD: unable to connect to any AD servers.");
show_error('Error connecting to any Active Directory server(s). Please check your configuration and connections.');
$continue = false;
}
if ($continue) {
// set some required LDAP options
ldap_set_option($this->_ldap_conn, LDAP_OPT_REFERRALS, 0);
ldap_set_option($this->_ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
// attempt to bind to the AD using the proxy user or anonymously if no user was configured
if ($this->_proxy_user != null) {
ldap_bind($this->_ldap_conn, $this->_proxy_user, $this->_proxy_pass);
} else {
$bind = ldap_bind($this->_ldap_conn);
}
// verify the LDAP binding
if (!$bind) {
if ($this->_proxy_user != null) {
log_message('error', 'Auth_AD: Unable to perform LDAP bind using user ' . $this->_proxy_user);
show_error('Unable to bind (i.e. login) to the AD for user ID lookup');
} else {
log_message('error', 'Auth_AD: Unable to perform anonymous LDAP bind.');
show_error('Unable to bind (i.e. login) to the AD for user ID lookup');
}
$continue = false;
} else {
log_message('debug', 'Auth_AD: Successfully bound to AD. Performing DN lookup for user');
}
}
// return the result
return $continue;
}
我认为这不是代码问题,因为代码库在 localhost 或生产环境中是相同的,可以正常工作。任何想法 ?
解决方案
推荐阅读
- amazon-web-services - AWS 上是否有任何服务可以帮助我将 mp4 文件转换为 mp3?
- react-admin - 在通知中显示 API 错误
- tensorflow - 如何避免 c++ 库依赖于 protobuf 库的重复定义?
- c# - 幕后发生了什么,所以代码返回 1 而不是 43?
- javascript - UI Grid 无法读取未定义的属性数据
- html - 如果不弄乱表格格式,就无法分页工作
- laravel - 如何获取 Laravel Blade 中被 Eloquent API Resource 转换的属性值?
- delphi - 如何为 FireMonkey 组件添加设计时图标?
- html - DIV左上角CSS动画后的额外像素
- angular - Angular Service Worker:子路由刷新时出现 404