我必须使用CodeIgniter 3处理用PHP 5.5编写的旧应用程序。
对于身份验证,它使用具有Auth_AD库的专用服务器的ldap连接。
在生产服务器和测试服务器中,此ldap连接成功运行,但是当我尝试从localhost进行身份验证时,出现此错误
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;
}
我认为这不是代码问题,因为在本地主机或生产环境中,代码库是相同的,并且可以正常工作。有什么想法吗?