function XMLRPCaddUserGroupPriv($name, $affiliation, $nodeid, $permissions) {
	require_once(".ht-inc/privileges.php");
	global $user;

	if(! is_numeric($nodeid)) {
		return array('status' => 'error',
		             'errorcode' => 78,
		             'errormsg' => 'Invalid nodeid specified');
	}

	if(! checkUserHasPriv("userGrant", $user['id'], $nodeid)) {
		return array('status' => 'error',
		             'errorcode' => 52,
		             'errormsg' => 'Unable to add a user group to this node');
	}

	$validate = array('name' => $name,
	                  'affiliation' => $affiliation);
	$rc = validateAPIgroupInput($validate, 1);
	if($rc['status'] == 'error')
		return $rc;

	$groupid = $rc['id'];
	#$name = "$name@$affiliation";
	$perms = explode(':', $permissions);
	$usertypes = getTypes('users');
	array_push($usertypes["users"], "block");
	array_push($usertypes["users"], "cascade");

	$diff = array_diff($perms, $usertypes['users']);
	if(count($diff) || (count($perms) == 1 && $perms[0] == 'cascade')) {
		return array('status' => 'error',
		             'errorcode' => 66,
		             'errormsg' => 'Invalid or missing permissions list supplied');
	}

	$cnp = getNodeCascadePrivileges($nodeid, "usergroups");
	$np = getNodePrivileges($nodeid, "usergroups", $cnp);

	$diff = array_diff($perms, $np['usergroups'][$name]['privs']);
	if(empty($diff))
		return array('status' => 'success');

	updateUserOrGroupPrivs($groupid, $nodeid, $diff, array(), "group");
	return array('status' => 'success');
}
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.