From e7d6502217c55beaddb606ede4982f08711a851d Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 13 Mar 2004 13:44:55 +0000 Subject: [PATCH] fixed bug when cn!=uid (915041) --- lam-0.4/lib/account.inc | 12 ++++++------ lam-0.4/templates/account/groupedit.php | 10 +++++----- lam-0.4/templates/account/useredit.php | 2 +- lam-0.4/templates/masscreate.php | 2 +- lam-0.4/templates/massdetail.php | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lam-0.4/lib/account.inc b/lam-0.4/lib/account.inc index fd049334..9a4ab713 100644 --- a/lam-0.4/lib/account.inc +++ b/lam-0.4/lib/account.inc @@ -607,14 +607,14 @@ function ldapreload($type) { $_SESSION['userDN'][0] = time(); // Search 4 values which should be cached $result = @ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), - '(&(objectClass=posixAccount)(!(uid=*$)))', array('cn', 'uidNumber'), 0); + '(&(objectClass=posixAccount)(!(uid=*$)))', array('uid', 'uidNumber'), 0); // Write search result in array $entry = @ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { $dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry)); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); - if (isset($attr['cn'][0])) - $_SESSION['userDN'][$dn]['cn'] = $attr['cn'][0]; + if (isset($attr['uid'][0])) + $_SESSION['userDN'][$dn]['uid'] = $attr['uid'][0]; if (isset($attr['uidNumber'][0])) $_SESSION['userDN'][$dn]['uidNumber'] = $attr['uidNumber'][0]; $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); @@ -660,14 +660,14 @@ function ldapreload($type) { $_SESSION['hostDN'][0] = time(); // Search 4 values which should be cached $result = @ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_HostSuffix(), - '(&(objectClass=posixAccount)(uid=*$))', array('cn', 'uidNumber'), 0); + '(&(objectClass=posixAccount)(uid=*$))', array('uid', 'uidNumber'), 0); // Write search result in array $entry = @ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { $dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry)); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); - if (isset($attr['cn'][0])) - $_SESSION['hostDN'][$dn]['cn'] = $attr['cn'][0]; + if (isset($attr['uid'][0])) + $_SESSION['hostDN'][$dn]['uid'] = $attr['uid'][0]; if (isset($attr['uidNumber'][0])) $_SESSION['hostDN'][$dn]['uidNumber'] = $attr['uidNumber'][0]; $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); diff --git a/lam-0.4/templates/account/groupedit.php b/lam-0.4/templates/account/groupedit.php index 0c3d1c29..19cd03fa 100644 --- a/lam-0.4/templates/account/groupedit.php +++ b/lam-0.4/templates/account/groupedit.php @@ -482,7 +482,7 @@ switch ($select_local) { // unset timestamp stored in $temp2[0] unset($temp2[0]); // load list with all users - foreach ($temp2 as $temp) $users[] = $temp['cn']; + foreach ($temp2 as $temp) $users[] = $temp['uid']; // sort users if (is_array($users)) sort($users, SORT_STRING); // remove users which are allready additional members of group @@ -493,16 +493,16 @@ switch ($select_local) { */ // Do a ldap-search if (isset($account_old->general_uidNumber)) - $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), "(&(objectClass=PosixAccount)(gidNumber=$account_old->general_uidNumber))", array('cn')); - else $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), "(&(objectClass=PosixAccount)(gidNumber=$account_new->general_uidNumber))", array('cn')); + $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), "(&(objectClass=PosixAccount)(gidNumber=$account_old->general_uidNumber))", array('uid')); + else $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), "(&(objectClass=PosixAccount)(gidNumber=$account_new->general_uidNumber))", array('uid')); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); // loop for every user which is primary member of group while ($entry) { $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); - if (isset($attr['cn'][0])) { + if (isset($attr['uid'][0])) { // Remove user from user list $users = @array_flip($users); - unset ($users[$attr['cn'][0]]); + unset ($users[$attr['uid'][0]]); $users = @array_flip($users); } // Go to next entry diff --git a/lam-0.4/templates/account/useredit.php b/lam-0.4/templates/account/useredit.php index e53302f2..2a5deda5 100644 --- a/lam-0.4/templates/account/useredit.php +++ b/lam-0.4/templates/account/useredit.php @@ -774,7 +774,7 @@ switch ($select_local) { // unset timestamp stored in $temp2[0] unset($temp2[0]); // Remove $ from workstations - foreach ($temp2 as $temp) $hosts[] = str_replace("$", '',$temp['cn']); + foreach ($temp2 as $temp) $hosts[] = str_replace("$", '',$temp['uid']); // sort workstations sort($hosts, SORT_STRING); // get workstation array diff --git a/lam-0.4/templates/masscreate.php b/lam-0.4/templates/masscreate.php index 94410cac..d91e0fac 100644 --- a/lam-0.4/templates/masscreate.php +++ b/lam-0.4/templates/masscreate.php @@ -505,7 +505,7 @@ function loadfile() { ldapreload('user'); // Get List with all existing usernames $users = array(); - foreach ($_SESSION['userDN'] as $user_array) $users[] = $user_array['cn']; + foreach ($_SESSION['userDN'] as $user_array) $users[] = $user_array['uid']; for ($row2=0; $row2general_username; // unset old username in user-array