check group of names before adding members

This commit is contained in:
Roland Gruber 2018-08-18 10:48:44 +02:00
parent 316ed2d0a8
commit 458b3c454f
1 changed files with 23 additions and 10 deletions

View File

@ -2925,8 +2925,20 @@ class posixAccount extends baseModule implements passwordService {
// add users to group of names
elseif ($temp['counter'] < (sizeof($temp['groups']) + sizeof($temp['createHomes']) + sizeof($temp['dn_gon']))) {
$gonDn = $temp['dn_gon_keys'][$temp['counter'] - sizeof($temp['groups']) - sizeof($temp['createHomes'])];
$gonAttr = $temp['dn_gon'][$gonDn];
$success = @ldap_mod_add($_SESSION['ldap']->server(), $gonDn, $gonAttr);
$gonAttrToAdd = $temp['dn_gon'][$gonDn];
$gonAttrNames = array_keys($gonAttrToAdd);
$gonAttrs = ldapGetDN($gonDn, $gonAttrNames);
foreach ($gonAttrNames as $gonAttrName) {
$gonAttrNameLower = strtolower($gonAttrName);
if (!empty($gonAttrs[$gonAttrNameLower])) {
$gonAttrToAdd[$gonAttrName] = array_delete($gonAttrs[$gonAttrNameLower], $gonAttrToAdd[$gonAttrName]);
}
if (empty($gonAttrToAdd[$gonAttrName])) {
unset($gonAttrToAdd[$gonAttrName]);
}
}
if (!empty($gonAttrToAdd)) {
$success = @ldap_mod_add($_SESSION['ldap']->server(), $gonDn, $gonAttrToAdd);
$errors = array();
if (!$success) {
$errors[] = array(
@ -2936,6 +2948,7 @@ class posixAccount extends baseModule implements passwordService {
array($temp['groups'][$temp['counter']])
);
}
}
$temp['counter']++;
return array (
'status' => 'inProgress',