Rename $ds to $ldap_connection

$ds is a global variable, there are many name collisions in the code.  Rename it to avoid the collisions.
This commit is contained in:
Tony Murray
2016-06-03 10:56:42 -05:00
parent f3e79af61b
commit 9b0bd4c15a
4 changed files with 87 additions and 87 deletions

View File

@@ -12,14 +12,14 @@ if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional
function authenticate($username, $password) {
global $config, $ds;
global $config, $ldap_connection;
if ($username && $ds) {
if ($username && $ldap_connection) {
if ($config['auth_ldap_version']) {
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
}
if (ldap_bind($ds, $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'], $password)) {
if (ldap_bind($ldap_connection, $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'], $password)) {
if (!$config['auth_ldap_group']) {
return 1;
}
@@ -27,7 +27,7 @@ function authenticate($username, $password) {
$ldap_groups = get_group_list();
foreach ($ldap_groups as $ldap_group) {
$ldap_comparison = ldap_compare(
$ds,
$ldap_connection,
$ldap_group,
$config['auth_ldap_groupmemberattr'],
get_membername($username)
@@ -39,7 +39,7 @@ function authenticate($username, $password) {
}
}
else {
echo ldap_error($ds);
echo ldap_error($ldap_connection);
}
}
else {
@@ -83,11 +83,11 @@ function adduser($username, $password, $level, $email='', $realname='', $can_mod
function user_exists($username) {
global $config, $ds;
global $config, $ldap_connection;
$filter = '('.$config['auth_ldap_prefix'].$username.')';
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
return 1;
}
@@ -98,14 +98,14 @@ function user_exists($username) {
function get_userlevel($username) {
global $config, $ds;
global $config, $ldap_connection;
$userlevel = 0;
// Find all defined groups $username is in
$filter = '(&(|(cn='.join(')(cn=', array_keys($config['auth_ldap_groups'])).'))('.$config['auth_ldap_groupmemberattr'].'='.get_membername($username).'))';
$search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ldap_connection, $search);
// Loop the list and find the highest level
foreach ($entries as $entry) {
@@ -121,11 +121,11 @@ function get_userlevel($username) {
function get_userid($username) {
global $config, $ds;
global $config, $ldap_connection;
$filter = '('.$config['auth_ldap_prefix'].$username.')';
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
return $entries[0]['uidnumber'][0];
@@ -144,13 +144,13 @@ function deluser($username) {
function get_userlist() {
global $config, $ds;
global $config, $ldap_connection;
$userlist = array();
$filter = '('.$config['auth_ldap_prefix'].'*)';
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
foreach ($entries as $entry) {
@@ -161,7 +161,7 @@ function get_userlist() {
$ldap_groups = get_group_list();
foreach ($ldap_groups as $ldap_group) {
$ldap_comparison = ldap_compare(
$ds,
$ldap_connection,
$ldap_group,
$config['auth_ldap_groupmemberattr'],
get_membername($username)
@@ -205,14 +205,14 @@ function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
function get_membername($username) {
global $config, $ds;
global $config, $ldap_connection;
if ($config['auth_ldap_groupmembertype'] == 'fulldn') {
$membername = $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'];
}
elseif ($config['auth_ldap_groupmembertype'] == 'puredn') {
$filter = '('.$config['auth_ldap_attr']['uid'].'='.$username.')';
$search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ldap_connection, $search);
$membername = $entries[0]['dn'];
}
else {