I have an odd issue where my root user can connect to an external LDAP server, but a normal cPanel user cannot.
I used EasyApache 4 to install the php ldap extension, and a function_exists check for ldap_bind returns true. So the extension is definitely installed and working. (Not to mention it works for root...)
The ldap server is an eDirectory.
Both cPanel and my ldap directory are in the same DMZ, so my external firewall is not interfering. Both cPanel and the ldap server have both 636 and 389 ports open.
I am using LVE for the users account.
My test script:
If I run the test script as the cpanel user:
Any suggestions on what I should do next?
I used EasyApache 4 to install the php ldap extension, and a function_exists check for ldap_bind returns true. So the extension is definitely installed and working. (Not to mention it works for root...)
The ldap server is an eDirectory.
Both cPanel and my ldap directory are in the same DMZ, so my external firewall is not interfering. Both cPanel and the ldap server have both 636 and 389 ports open.
I am using LVE for the users account.
My test script:
PHP:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$config['baseDn'] = 'ou=blah,dc=foo,dc=bar';
$config['bindDn'] = 'binduserdn';
$config['host'] = 'ldaps://<ldapserver hostname>';
$config['port'] = 636;
$config['bindPw'] = 'password';
$config['tls'] = NULL;
$connection = ldap_connect($config['host'], $config['port']);
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($connection == FALSE) {
//Note that OpenLDAP always returns a resource and does not actually
//connect until we use ldap_bind or other ldap_* functions.
//See http://www.php.net/manual/en/function.ldap-connect.php
syslog(LOG_ERR, "Unable to connect to LDAP server." . ldap_error($connection));
exit();
} else {
//turn on tls if set.
if (!empty($config['tls'])) {
ldap_start_tls($connection);
}
//Attempt to bind to the server.
$bind = ldap_bind($connection, $config['bindDn'], $config['bindPw']);
if (!$bind) {
syslog(LOG_ERR, "Unable to bind to LDAP server.");
exit();
} else {
echo "Bound to ldap server.\n\n";
}
}
If I run the test script inside the cpanel users home dir as root:[<user>@cpanel ~]$ php testldap.php
Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server in /home/<user>/testldap.php on line 29
If I run the same test script from inside root's home, as root:[[email protected] ~]# php /home/mattd/testldap.php
Bound to ldap server.
I assume it has something to do with how CloudLinux, CageFS, and LVE all work. Unfortunately, my searches of the documentation and Google have not turned up any clues.[[email protected] ~]# php testldap.php
Bound to ldap server.
Any suggestions on what I should do next?