fixed bug when cn!=uid (915041)
This commit is contained in:
parent
ccebe86595
commit
e7d6502217
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; $row2<sizeof($_SESSION['mass_accounts']); $row2++) {
|
||||
/* loops for every user
|
||||
* Check for double entries in $_SESSION['mass_accounts']
|
||||
|
|
|
@ -93,7 +93,7 @@ if ($_POST['apply']) {
|
|||
// Validate cache-array
|
||||
ldapreload('user');
|
||||
// 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
|
||||
foreach ($_SESSION['mass_accounts'] as $user_array) $users[] = $user_array->general_username;
|
||||
// unset old username in user-array
|
||||
|
|
Loading…
Reference in New Issue