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,16 +2925,29 @@ class posixAccount extends baseModule implements passwordService {
// add users to group of names // add users to group of names
elseif ($temp['counter'] < (sizeof($temp['groups']) + sizeof($temp['createHomes']) + sizeof($temp['dn_gon']))) { 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'])]; $gonDn = $temp['dn_gon_keys'][$temp['counter'] - sizeof($temp['groups']) - sizeof($temp['createHomes'])];
$gonAttr = $temp['dn_gon'][$gonDn]; $gonAttrToAdd = $temp['dn_gon'][$gonDn];
$success = @ldap_mod_add($_SESSION['ldap']->server(), $gonDn, $gonAttr); $gonAttrNames = array_keys($gonAttrToAdd);
$errors = array(); $gonAttrs = ldapGetDN($gonDn, $gonAttrNames);
if (!$success) { foreach ($gonAttrNames as $gonAttrName) {
$errors[] = array( $gonAttrNameLower = strtolower($gonAttrName);
"ERROR", if (!empty($gonAttrs[$gonAttrNameLower])) {
_("LAM was unable to modify group memberships for group: %s"), $gonAttrToAdd[$gonAttrName] = array_delete($gonAttrs[$gonAttrNameLower], $gonAttrToAdd[$gonAttrName]);
getDefaultLDAPErrorString($_SESSION['ldap']->server()), }
array($temp['groups'][$temp['counter']]) 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(
"ERROR",
_("LAM was unable to modify group memberships for group: %s"),
getDefaultLDAPErrorString($_SESSION['ldap']->server()),
array($temp['groups'][$temp['counter']])
);
}
} }
$temp['counter']++; $temp['counter']++;
return array ( return array (