0
|
1 |
<?php
|
|
2 |
|
|
3 |
require('includes/starthere.php');
|
|
4 |
|
|
5 |
if ( !isset($_GET['op']) )
|
|
6 |
die();
|
|
7 |
|
|
8 |
$result = false;
|
|
9 |
switch($_GET['op'])
|
|
10 |
{
|
|
11 |
case 'checkAvailability':
|
|
12 |
if ( !preg_match('/^[a-z0-9]{3,32}$/', $_GET['uid']) )
|
|
13 |
{
|
|
14 |
$result = 'Username contains invalid characters, or does not meet length requirement (3-32 characters).';
|
|
15 |
break;
|
|
16 |
}
|
|
17 |
$userinfo = ldap_get_user($_GET['uid']);
|
|
18 |
if ( !$userinfo )
|
|
19 |
$result = true;
|
|
20 |
else
|
|
21 |
$result = 'This username is already taken.';
|
|
22 |
case 'listUsers':
|
|
23 |
$result = ldap_list_users();
|
|
24 |
break;
|
|
25 |
case 'getGroup':
|
|
26 |
$result = ldap_get_group($_GET['gid']);
|
|
27 |
break;
|
|
28 |
case 'removeUserFromGroup':
|
|
29 |
$group = ldap_get_group($_GET['gid']);
|
|
30 |
if ( in_array($_GET['uid'], $group['memberUid']) )
|
|
31 |
$result = ldap_delete_group_member($_GET['gid'], $_GET['uid']);
|
|
32 |
break;
|
|
33 |
case 'addUserToGroup':
|
|
34 |
$group = ldap_get_group($_GET['gid']);
|
|
35 |
if ( $group && !in_array($_GET['uid'], $group['memberUid']) )
|
|
36 |
$result = ldap_add_group_member($_GET['gid'], $_GET['uid']);
|
|
37 |
break;
|
|
38 |
}
|
|
39 |
|
|
40 |
header('Content-type: text/javascript');
|
|
41 |
echo json_encode($result);
|