Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 50 lines (39 sloc) 1.41 KB
* Add a new user to a group.
* @since 8/28/09
* @package
* @copyright Copyright &copy; 2009, Middlebury College
* @license GNU General Public License (GPL)
if (!isset($_POST['group_id']) || !$_POST['group_id'])
throw new InvalidArgumentException("No group_id passed");
$groupId = base64_decode_fix($_POST['group_id'], true);
if (!$groupId)
throw new InvalidArgumentException("Invalid group_id passed");
if (!isset($_POST['user_id']) || !$_POST['user_id'])
throw new InvalidArgumentException("No user_id passed");
$userId = base64_decode_fix($_POST['user_id'], true);
if (!$userId)
throw new InvalidArgumentException("Invalid user_id passed");
// Verify that the current user really can manage the group.
$groups = $ldap->read('(objectclass=group)', $groupId, array('managedby', 'member'));
if (count($groups) != 1)
throw new UnknownIdException("Could not find the group specified");
$group = $groups[0];
if (!canModifyGroup($group))
throw new PermissionDeniedException("You are not authorized to manage this group.");
// Verify that the user is not already in the group
if (!in_array($userId, $group['member'])) {
throw new Exception("The user is not a member of this group.", 506);
// Add the user.
$ldap->delAttribute($groupId, 'member', $userId);
header('Content-Type: text/plain');
print "Success";