it's no possible again to create a group. But something strange is going on when trying to edit a group
This commit is contained in:
		
							parent
							
								
									7feba33196
								
							
						
					
					
						commit
						9127486894
					
				|  | @ -241,11 +241,9 @@ class cache { | ||||||
| 		for ($i=0; $i<count($allowed_types); $i++) { | 		for ($i=0; $i<count($allowed_types); $i++) { | ||||||
| 			if ($allowed_types[$i]!='*') { | 			if ($allowed_types[$i]!='*') { | ||||||
| 				$function = '$suffix = $$this->config->get_'.ucfirst($allowed_types[$i]).'Suffix();'; | 				$function = '$suffix = $$this->config->get_'.ucfirst($allowed_types[$i]).'Suffix();'; | ||||||
| 				print $function; |  | ||||||
| 				print "<br>"; |  | ||||||
| 				// *** fixme, where is get_DomainSuffix
 | 				// *** fixme, where is get_DomainSuffix
 | ||||||
| 				If ($scope != '*') //eval($function);
 | 				If ($scope != '*') //eval($function);
 | ||||||
| 					$suffix = call_user_func(array($$this->config, 'get_'.ucfirst($allowed_types[$i]).'Suffix')); | 					$suffix = call_user_func(array($this->config, 'get_'.ucfirst($allowed_types[$i]).'Suffix')); | ||||||
| 					else $suffix = ''; | 					else $suffix = ''; | ||||||
| 				if (substr($suffix, $dn)) $singlescope = $allowed_types[$i]; | 				if (substr($suffix, $dn)) $singlescope = $allowed_types[$i]; | ||||||
| 				} | 				} | ||||||
|  | @ -255,10 +253,12 @@ class cache { | ||||||
| 		// Everything seems to be OK, start processing data
 | 		// Everything seems to be OK, start processing data
 | ||||||
| 		// Get Scope
 | 		// Get Scope
 | ||||||
| 		foreach ($allowed_types as $scope) { | 		foreach ($allowed_types as $scope) { | ||||||
| 			$function = '$suffix = $this->config->get_'.ucfirst($scope).'Suffix();'; | 			//$function = '$suffix = $this->config->get_'.ucfirst($scope).'Suffix();';
 | ||||||
| 			//eval($function);
 | 			//eval($function);
 | ||||||
| 			$suffix = call_user_func(array($$this->config, 'get_'.ucfirst($scope).'Suffix')); | 			if ($scope!='*') { | ||||||
| 			if (strpos($dn, $suffix)) $singlescope = $scope; | 				$suffix = call_user_func(array($this->config, 'get_'.ucfirst($scope).'Suffix')); | ||||||
|  | 				if (strpos($dn, $suffix)) $singlescope = $scope; | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 		if (!isset($singlescope)) trigger_error(sprintf(_('Invalid dn: %s. DN not covered by any suffix.'), $dn), E_USER_WARN); | 		if (!isset($singlescope)) trigger_error(sprintf(_('Invalid dn: %s. DN not covered by any suffix.'), $dn), E_USER_WARN); | ||||||
| 		// Refresh Cache
 | 		// Refresh Cache
 | ||||||
|  | @ -326,12 +326,15 @@ class cache { | ||||||
| 	*/ | 	*/ | ||||||
| 	function getgrnam($gidNumber) { | 	function getgrnam($gidNumber) { | ||||||
| 		$dn_groups = $_SESSION['cache']->get_cache('gidNumber', 'posixGroup', 'group'); | 		$dn_groups = $_SESSION['cache']->get_cache('gidNumber', 'posixGroup', 'group'); | ||||||
| 		$DNs = array_keys($dn_groups); | 		if (is_array($dn_groups)) { | ||||||
| 		foreach ($DNs as $DN) { | 			$DNs = array_keys($dn_groups); | ||||||
| 			if ($dn_groups[$DN][0]==$gidNumber) | 			foreach ($DNs as $DN) { | ||||||
| 				$return = substr($DN, 3, strpos($DN, ',')-3); | 				if ($dn_groups[$DN][0]==$gidNumber) | ||||||
|  | 					$return = substr($DN, 3, strpos($DN, ',')-3); | ||||||
|  | 				} | ||||||
|  | 			return $return; | ||||||
| 			} | 			} | ||||||
| 		return $return; | 		else return -1; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -338,7 +338,7 @@ function getAvailablePDFFields($scope) { | ||||||
|  * @return array Available scopes |  * @return array Available scopes | ||||||
|  */ |  */ | ||||||
| function getAvailableScopes() { | function getAvailableScopes() { | ||||||
| 	return array('user','group','host'); | 	return array('user','group','host', 'domain'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | @ -356,8 +356,7 @@ class accountContainer { | ||||||
| 		if (!is_string($type)) trigger_error(_('Argument of accountContainer must be string.'), E_USER_ERROR); | 		if (!is_string($type)) trigger_error(_('Argument of accountContainer must be string.'), E_USER_ERROR); | ||||||
| 		if (!is_string($base)) trigger_error(_('Argument of accountContainer must be string.'), E_USER_ERROR); | 		if (!is_string($base)) trigger_error(_('Argument of accountContainer must be string.'), E_USER_ERROR); | ||||||
| 		// *** fixme use global variable to determine allowed types
 | 		// *** fixme use global variable to determine allowed types
 | ||||||
| 		$allowed_types = array ( 'user', 'group', 'host', 'domain' ); | 		if (!in_array($type, getAvailableScopes())) trigger_error(_('Account type not recognized.'), E_USER_ERROR); | ||||||
| 		if (!in_array($type, $allowed_types)) trigger_error(_('Account type not recognized.'), E_USER_ERROR); |  | ||||||
| 		$this->type = $type; | 		$this->type = $type; | ||||||
| 		$this->base = $base; | 		$this->base = $base; | ||||||
| 		// Name of variables in session
 | 		// Name of variables in session
 | ||||||
|  | @ -1156,9 +1155,6 @@ class accountContainer { | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		print $this->dn; |  | ||||||
| 		print $this->dn_orig; |  | ||||||
| 		print_r($attributes); |  | ||||||
| 		// Complete dn with uid or cn=
 | 		// Complete dn with uid or cn=
 | ||||||
| 		if ($this->type=='group') $search = 'cn'; | 		if ($this->type=='group') $search = 'cn'; | ||||||
| 			else $search = 'uid'; | 			else $search = 'uid'; | ||||||
|  | @ -1200,16 +1196,17 @@ class accountContainer { | ||||||
| 			} | 			} | ||||||
| 		// fixme *** ad update_cache after every ldap-change
 | 		// fixme *** ad update_cache after every ldap-change
 | ||||||
| 
 | 
 | ||||||
|  | 		print_r($attributes); | ||||||
| 		if (!$stopprocessing) { | 		if (!$stopprocessing) { | ||||||
| 			if ($this->dn != $this->dn_orig) { | 			if ($this->dn != $this->dn_orig) { | ||||||
| 				// move existing DN
 | 				// move existing DN
 | ||||||
| 				if ($this->dn_orig!='') { | 				if ($this->dn_orig!='') { | ||||||
| 					// merge attributes together
 | 					// merge attributes together
 | ||||||
| 					$attr = array_merge_recursive($attributes[$this->dn]['add'], $attributes[$this->dn]['notchanged'], $attributes[$this->dn]['modify']); | 					$attr = array_merge_recursive($attributes[$this->dn]['add'], $attributes[$this->dn]['notchanged'], $attributes[$this->dn]['modify']); | ||||||
| 					$success = @ldap_add($_SESSION[$this->ldap]->server(), $this->dn, $attr); | 					$success = ldap_add($_SESSION[$this->ldap]->server(), $this->dn, $attr); | ||||||
| 					if ($success) { | 					if ($success) { | ||||||
| 						$_SESSION[$this->cache]->update_cache($this->$dn, 'add', $attr); | 						$_SESSION[$this->cache]->update_cache($this->$dn, 'add', $attr); | ||||||
| 						$success = @ldap_delete($_SESSION[$this->ldap]->server(), $this->dn_orig); | 						$success = ldap_delete($_SESSION[$this->ldap]->server(), $this->dn_orig); | ||||||
| 						if (!$success) { | 						if (!$success) { | ||||||
| 							$errors[] = array('ERROR', 'LDAP', sprintf(_('Was unable to delete dn: %s.'), $this->dn_orig)); | 							$errors[] = array('ERROR', 'LDAP', sprintf(_('Was unable to delete dn: %s.'), $this->dn_orig)); | ||||||
| 							$stopprocessing = true; | 							$stopprocessing = true; | ||||||
|  | @ -1224,16 +1221,14 @@ class accountContainer { | ||||||
| 					} | 					} | ||||||
| 				// create complete new dn
 | 				// create complete new dn
 | ||||||
| 				else { | 				else { | ||||||
| 		print "XXXXXXXX"; |  | ||||||
| 					$attr = array_merge_recursive($attributes[$this->dn]['add'], $attributes[$this->dn]['notchanged'], $attributes[$this->dn]['modify']); | 					$attr = array_merge_recursive($attributes[$this->dn]['add'], $attributes[$this->dn]['notchanged'], $attributes[$this->dn]['modify']); | ||||||
| 					print_r($attribtues); | 					$success = ldap_add($_SESSION[$this->ldap]->server(), $this->dn, $attr); | ||||||
| 					$success = ldap_add($_SESSION[$this->ldap]->server(), $this->dn, $attributes[$this->dn]['add']); |  | ||||||
| 					if (!$success) { | 					if (!$success) { | ||||||
| 						$errors[] = array('ERROR', 'LDAP', sprintf(_('Was unable to create dn: %s. This is possible a bug. Please check your ldap logs and send a bug report if it is a possible bug.'), $this->dn)); | 						$errors[] = array('ERROR', 'LDAP', sprintf(_('Was unable to create dn: %s. This is possible a bug. Please check your ldap logs and send a bug report if it is a possible bug.'), $this->dn)); | ||||||
| 						$stopprocessing = true; | 						$stopprocessing = true; | ||||||
| 						} | 						} | ||||||
| 					else | 					else | ||||||
| 						$_SESSION[$this->cache]->update_cache($this->$dn, 'add', $attributes[$this->dn]['add']); | 						$_SESSION[$this->cache]->update_cache($this->$dn, 'add', $attr); | ||||||
| 					} | 					} | ||||||
| 				unset($attributes[$this->dn]); | 				unset($attributes[$this->dn]); | ||||||
| 				} | 				} | ||||||
|  | @ -1278,15 +1273,16 @@ class accountContainer { | ||||||
| 			foreach ($attributes as $DN) { | 			foreach ($attributes as $DN) { | ||||||
| 				if (is_array($DN['lamdaemon']['command'])) $result = $this->lamdaemon($DN['lamdaemon']['command']); | 				if (is_array($DN['lamdaemon']['command'])) $result = $this->lamdaemon($DN['lamdaemon']['command']); | ||||||
| 				// Error somewhere in lamdaemon
 | 				// Error somewhere in lamdaemon
 | ||||||
| 				foreach ($result as $singleresult) { | 				if (is_array($result)) | ||||||
| 					if (is_array($singleresult)) { | 					foreach ($result as $singleresult) { | ||||||
| 						if ($singleresult[0] = 'ERROR') $stopprocessing = true; | 						if (is_array($singleresult)) { | ||||||
| 						$temparray[0] = $singleresult[0]; | 							if ($singleresult[0] = 'ERROR') $stopprocessing = true; | ||||||
| 						$temparray[1] = _($singleresult[1]); | 							$temparray[0] = $singleresult[0]; | ||||||
| 						$temparray[2] = _($singleresult[2]); | 							$temparray[1] = _($singleresult[1]); | ||||||
| 						$errors[] = $temparray; | 							$temparray[2] = _($singleresult[2]); | ||||||
|  | 							$errors[] = $temparray; | ||||||
|  | 							} | ||||||
| 						} | 						} | ||||||
| 					} |  | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		if (count($errors)!=0) return $errors; | 		if (count($errors)!=0) return $errors; | ||||||
|  |  | ||||||
|  | @ -343,18 +343,20 @@ class posixGroup extends baseModule { | ||||||
| 
 | 
 | ||||||
| 		// Remove primary group from users from memberUid
 | 		// Remove primary group from users from memberUid
 | ||||||
| 		$users_dn = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixAccount', 'user'); | 		$users_dn = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixAccount', 'user'); | ||||||
| 		$DNs = array_keys($users_dn); | 		if (is_array($users_dn)) { | ||||||
| 		for ($i=0; $i<count($DNs); $i++) { | 			$DNs = array_keys($users_dn); | ||||||
| 			if ($users_dn[$DNs[$i]][0]==$this->attributes['gidNumber'][0]) { | 			for ($i=0; $i<count($DNs); $i++) { | ||||||
| 				$thisuser = substr($DNs[$i], 4, strpos($DNs[$i], ",")-4); | 				if ($users_dn[$DNs[$i]][0]==$this->attributes['gidNumber'][0]) { | ||||||
| 				if (@in_array($thisuser, $this->attribtues['memberUid'])) { | 					$thisuser = substr($DNs[$i], 4, strpos($DNs[$i], ",")-4); | ||||||
| 					$this->attribtues['memberUid'] = @array_flip($this->attribtues['memberUid']); | 					if (@in_array($thisuser, $this->attribtues['memberUid'])) { | ||||||
| 					unset($this->attribtues['memberUid'][$thisuser]); | 						$this->attribtues['memberUid'] = @array_flip($this->attribtues['memberUid']); | ||||||
| 					$this->attribtues['memberUid'] = @array_flip($this->attribtues['memberUid']); | 						unset($this->attribtues['memberUid'][$thisuser]); | ||||||
|  | 						$this->attribtues['memberUid'] = @array_flip($this->attribtues['memberUid']); | ||||||
|  | 						} | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 	 | ||||||
| 		// Change gids of users and hosts?
 | 		// Change gids of users and hosts?
 | ||||||
| 		if ($this->changegids) { | 		if ($this->changegids) { | ||||||
| 			// get gidNumber
 | 			// get gidNumber
 | ||||||
|  | @ -401,6 +403,8 @@ class posixGroup extends baseModule { | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | 		// Add ObjectClass
 | ||||||
|  | 		$return[$_SESSION[$this->base]->dn]['notchanged']['objectClass'][0] = 'posixGroup'; | ||||||
| 		return $return; | 		return $return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -443,8 +447,10 @@ class posixGroup extends baseModule { | ||||||
| 			$maxID = intval($this->moduleSettings['posixGroup_maxGID'][0]); | 			$maxID = intval($this->moduleSettings['posixGroup_maxGID'][0]); | ||||||
| 			$dn_gids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixGroup', '*'); | 			$dn_gids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixGroup', '*'); | ||||||
| 			// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
 | 			// get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
 | ||||||
| 			foreach ($dn_gids as $gid) $gids[] = $gid[0]; | 			if(is_array($dn_gids)) { | ||||||
| 			if(is_array($gids)) sort ($gids, SORT_NUMERIC); | 				foreach ($dn_gids as $gid) $gids[] = $gid[0]; | ||||||
|  | 				sort ($gids, SORT_NUMERIC); | ||||||
|  | 				} | ||||||
| 			if ($this->attributes['gidNumber'][0]=='') { | 			if ($this->attributes['gidNumber'][0]=='') { | ||||||
| 				// No id-number given
 | 				// No id-number given
 | ||||||
| 				if ($this->orig['gidNumber'][0]=='') { | 				if ($this->orig['gidNumber'][0]=='') { | ||||||
|  | @ -628,29 +634,31 @@ class posixGroup extends baseModule { | ||||||
| 	function display_html_user($post, $profile=false) { | 	function display_html_user($post, $profile=false) { | ||||||
| 		// load list with all groups
 | 		// load list with all groups
 | ||||||
| 		$dn_users = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'posixAccount', 'user'); | 		$dn_users = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'posixAccount', 'user'); | ||||||
| 		foreach ($dn_users as $user) $users[] = $user[0]; | 		if (is_array($dn_users)) { | ||||||
| 		// sort groups
 | 			foreach ($dn_users as $user) $users[] = $user[0]; | ||||||
| 		sort($users, SORT_STRING); | 			// sort groups
 | ||||||
| 		// remove groups the user is member of from grouplist
 | 			sort($users, SORT_STRING); | ||||||
| 		$users = array_delete($this->attributes['memberUid'], $users); | 			// remove groups the user is member of from grouplist
 | ||||||
| 		// Remove primary group from grouplist
 | 			$users = array_delete($this->attributes['memberUid'], $users); | ||||||
| 		$users_dn = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixAccount', 'user'); | 			// Remove primary group from grouplist
 | ||||||
| 		$DNs = array_keys($users_dn); | 			$users_dn = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixAccount', 'user'); | ||||||
| 		for ($i=0; $i<count($DNs); $i++) { | 			$DNs = array_keys($users_dn); | ||||||
| 			if ($users_dn[$DNs[$i]][0]==$this->attributes['gidNumber'][0]) { | 			for ($i=0; $i<count($DNs); $i++) { | ||||||
| 				$thisuser = substr($DNs[$i], 4, strpos($DNs[$i], ",")-4); | 				if ($users_dn[$DNs[$i]][0]==$this->attributes['gidNumber'][0]) { | ||||||
| 				if (in_array($thisuser, $users)) { | 					$thisuser = substr($DNs[$i], 4, strpos($DNs[$i], ",")-4); | ||||||
| 					$users = @array_flip($users); | 					if (in_array($thisuser, $users)) { | ||||||
| 					unset($users[$thisuser]); | 						$users = @array_flip($users); | ||||||
| 					$users = @array_flip($users); | 						unset($users[$thisuser]); | ||||||
|  | 						$users = @array_flip($users); | ||||||
|  | 						} | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
|  | 			// sort users
 | ||||||
|  | 			sort($users); | ||||||
| 			} | 			} | ||||||
| 		// sort users
 | 			 | ||||||
| 		sort($users); |  | ||||||
| 
 |  | ||||||
| 		$return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Group members"), 'value' => | 		$return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Group members"), 'value' => | ||||||
| 			array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected userss"), 'value' => | 			array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected users"), 'value' => | ||||||
| 				array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'removeusers[]', 'size' => '15', 'multiple', 'options' => $this->attributes['memberUid'])))), | 				array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'removeusers[]', 'size' => '15', 'multiple', 'options' => $this->attributes['memberUid'])))), | ||||||
| 			1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'addusers_button', | 			1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'addusers_button', | ||||||
| 				'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'removeusers_button', 'value' => '=>' )), | 				'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'removeusers_button', 'value' => '=>' )), | ||||||
|  |  | ||||||
|  | @ -229,6 +229,8 @@ class sambaGroupMapping extends baseModule { | ||||||
| 		if (!$wrid) $this->attributes['sambaSID'][0] == $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+1+$RIDbase); | 		if (!$wrid) $this->attributes['sambaSID'][0] == $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+1+$RIDbase); | ||||||
| 		$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); | 		$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); | ||||||
| 
 | 
 | ||||||
|  | 		// Add ObjectClass
 | ||||||
|  | 		$return[$_SESSION[$this->base]->dn]['notchanged']['objectClass'][0] = 'sambaGroupMapping'; | ||||||
| 		return $return; | 		return $return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue