author | Dan Fuhry <dan@fuhry.us> |
Sat, 16 Feb 2013 19:02:51 -0500 | |
changeset 6 | 3ac4e03f28b2 |
parent 4 | 2212b2ded8bf |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
||
4
2212b2ded8bf
Added OpenSSH public key support in LDAP
Dan Fuhry <dan@fuhry.us>
parents:
0
diff
changeset
|
3 |
define('NEED_ADMIN', 1); |
0 | 4 |
require('includes/starthere.php'); |
5 |
||
6 |
// POSTed actions |
|
7 |
if ( !empty($_SERVER['PATH_INFO']) ) |
|
8 |
{ |
|
9 |
$pi = explode('/', trim($_SERVER['PATH_INFO'], '/')); |
|
10 |
switch($pi[0]) |
|
11 |
{ |
|
12 |
case 'delete': |
|
13 |
if ( !isset($pi[1]) ) |
|
14 |
break; |
|
15 |
||
16 |
$group =& $pi[1]; |
|
17 |
||
18 |
if ( !ldap_get_group($group) ) |
|
19 |
{ |
|
20 |
break; |
|
21 |
} |
|
22 |
||
23 |
if ( delete_group($group) ) |
|
24 |
{ |
|
25 |
queue_message(E_NOTICE, "The group \"$group\" was deleted."); |
|
26 |
} |
|
27 |
else |
|
28 |
{ |
|
29 |
queue_message(E_ERROR, "Failed to delete the group. Ensure that no users have it set as their primary group."); |
|
30 |
} |
|
31 |
||
32 |
break; |
|
33 |
case 'create': |
|
34 |
||
35 |
if ( empty($_POST) ) |
|
36 |
{ |
|
37 |
queue_message(E_ERROR, "Bad request"); |
|
38 |
break; |
|
39 |
} |
|
40 |
||
41 |
if ( ldap_get_group($_POST['cn']) ) |
|
42 |
{ |
|
43 |
queue_message(E_ERROR, "This group already exists."); |
|
44 |
break; |
|
45 |
} |
|
46 |
||
47 |
if ( create_group($_POST['cn'], $_POST['description']) ) |
|
48 |
queue_message(E_NOTICE, "The group \"{$_POST['cn']}\" was created."); |
|
49 |
else |
|
50 |
queue_message(E_ERROR, "Failed to create group"); |
|
51 |
||
52 |
break; |
|
53 |
} |
|
54 |
} |
|
55 |
||
56 |
// list groups |
|
57 |
$groups = ldap_list_groups(); |
|
58 |
||
59 |
// Present the UI |
|
60 |
display_template('groups', array( |
|
61 |
'groups' => $groups |
|
62 |
, 'users_json' => json_encode(ldap_list_users()) |
|
63 |
, 'next_gid' => get_next_available_gid() |
|
64 |
)); |
|
65 |