fixed bug when cn!=uid (915041)

This commit is contained in:
Roland Gruber 2004-03-13 13:44:55 +00:00
parent ccebe86595
commit e7d6502217
5 changed files with 14 additions and 14 deletions

View File

@ -607,14 +607,14 @@ function ldapreload($type) {
$_SESSION['userDN'][0] = time(); $_SESSION['userDN'][0] = time();
// Search 4 values which should be cached // Search 4 values which should be cached
$result = @ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), $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 // Write search result in array
$entry = @ldap_first_entry($_SESSION['ldap']->server(), $result); $entry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
while ($entry) { while ($entry) {
$dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry)); $dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
if (isset($attr['cn'][0])) if (isset($attr['uid'][0]))
$_SESSION['userDN'][$dn]['cn'] = $attr['cn'][0]; $_SESSION['userDN'][$dn]['uid'] = $attr['uid'][0];
if (isset($attr['uidNumber'][0])) if (isset($attr['uidNumber'][0]))
$_SESSION['userDN'][$dn]['uidNumber'] = $attr['uidNumber'][0]; $_SESSION['userDN'][$dn]['uidNumber'] = $attr['uidNumber'][0];
$entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry);
@ -660,14 +660,14 @@ function ldapreload($type) {
$_SESSION['hostDN'][0] = time(); $_SESSION['hostDN'][0] = time();
// Search 4 values which should be cached // Search 4 values which should be cached
$result = @ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_HostSuffix(), $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 // Write search result in array
$entry = @ldap_first_entry($_SESSION['ldap']->server(), $result); $entry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
while ($entry) { while ($entry) {
$dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry)); $dn = (ldap_get_dn($_SESSION['ldap']->server(), $entry));
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
if (isset($attr['cn'][0])) if (isset($attr['uid'][0]))
$_SESSION['hostDN'][$dn]['cn'] = $attr['cn'][0]; $_SESSION['hostDN'][$dn]['uid'] = $attr['uid'][0];
if (isset($attr['uidNumber'][0])) if (isset($attr['uidNumber'][0]))
$_SESSION['hostDN'][$dn]['uidNumber'] = $attr['uidNumber'][0]; $_SESSION['hostDN'][$dn]['uidNumber'] = $attr['uidNumber'][0];
$entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry);

View File

@ -482,7 +482,7 @@ switch ($select_local) {
// unset timestamp stored in $temp2[0] // unset timestamp stored in $temp2[0]
unset($temp2[0]); unset($temp2[0]);
// load list with all users // load list with all users
foreach ($temp2 as $temp) $users[] = $temp['cn']; foreach ($temp2 as $temp) $users[] = $temp['uid'];
// sort users // sort users
if (is_array($users)) sort($users, SORT_STRING); if (is_array($users)) sort($users, SORT_STRING);
// remove users which are allready additional members of group // remove users which are allready additional members of group
@ -493,16 +493,16 @@ switch ($select_local) {
*/ */
// Do a ldap-search // Do a ldap-search
if (isset($account_old->general_uidNumber)) 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')); $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('cn')); 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); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
// loop for every user which is primary member of group // loop for every user which is primary member of group
while ($entry) { while ($entry) {
$attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
if (isset($attr['cn'][0])) { if (isset($attr['uid'][0])) {
// Remove user from user list // Remove user from user list
$users = @array_flip($users); $users = @array_flip($users);
unset ($users[$attr['cn'][0]]); unset ($users[$attr['uid'][0]]);
$users = @array_flip($users); $users = @array_flip($users);
} }
// Go to next entry // Go to next entry

View File

@ -774,7 +774,7 @@ switch ($select_local) {
// unset timestamp stored in $temp2[0] // unset timestamp stored in $temp2[0]
unset($temp2[0]); unset($temp2[0]);
// Remove $ from workstations // Remove $ from workstations
foreach ($temp2 as $temp) $hosts[] = str_replace("$", '',$temp['cn']); foreach ($temp2 as $temp) $hosts[] = str_replace("$", '',$temp['uid']);
// sort workstations // sort workstations
sort($hosts, SORT_STRING); sort($hosts, SORT_STRING);
// get workstation array // get workstation array

View File

@ -505,7 +505,7 @@ function loadfile() {
ldapreload('user'); ldapreload('user');
// Get List with all existing usernames // Get List with all existing usernames
$users = array(); $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; $row2<sizeof($_SESSION['mass_accounts']); $row2++) { for ($row2=0; $row2<sizeof($_SESSION['mass_accounts']); $row2++) {
/* loops for every user /* loops for every user
* Check for double entries in $_SESSION['mass_accounts'] * Check for double entries in $_SESSION['mass_accounts']

View File

@ -93,7 +93,7 @@ if ($_POST['apply']) {
// Validate cache-array // Validate cache-array
ldapreload('user'); ldapreload('user');
// Get List with all existing usernames // Get List with all existing usernames
foreach ($_SESSION['userDN'] as $user_array) $users[] = $user_array['cn']; foreach ($_SESSION['userDN'] as $user_array) $users[] = $user_array['uid'];
// Get List with all users in array // Get List with all users in array
foreach ($_SESSION['mass_accounts'] as $user_array) $users[] = $user_array->general_username; foreach ($_SESSION['mass_accounts'] as $user_array) $users[] = $user_array->general_username;
// unset old username in user-array // unset old username in user-array