3 require_once("../lib/gaasdClient.php");
5 $myga = new GAASClient();
12 echo "Usage: ".$argv[0]." command [options]\n";
13 echo "\nCommands:\n\tinit AD user password domain clientgroup admingroup - init for active directory installation\n";
14 echo "\tinit IN user password - init for internal database\n";
15 echo "\tstatus - return the status of the server\n";
16 echo "\tsetadlogin username password domain\n";
17 echo "\tsetclientgroup groupname - change the group membership requirements for client's with AD\n";
18 echo "\tsetadmingroup groupname - change the group membership requirements for admin's with AD\n";
19 echo "\tprovisiontoken username [HOTP|TOTP] [KEY] - provision the user \"username\"\n";
20 echo "\tassign username tokenid - assign a hardware token to a user\n";
21 echo "\taddtoken token_name token_key token_type - adds a hardware token to the DB\n";
22 echo "\tgethwtokens - gets a list of hardware tokens by token_name\n";
23 echo "\tgetusers [admin|client] [part-of-username] [yes] - get user list with admin or client group, part of a username and return only those with tokens (yes)\n";
24 echo "\tdeleteuser username - deletes the key for the specified user\n";
35 $ret = $myga->MSG_STATUS();
36 echo "Status: $ret\n";
39 if($argv[2] == "AD") {
40 if($argc < 7) usage();
42 $ret = $myga->MSG_INIT_SERVER("AD", $argv[3], $argv[4], $argv[5], $argv[6], $argv[7]);
44 echo "initialising server succeeded\n";
46 echo "initialising server failed\n";
50 $ret = $myga->MSG_SET_AD_LOGIN($argv[2], $argv[3], $argv[4]);
52 echo "Resetting AD login details succeeded\n";
54 echo "Resetting AD login details failed\n";
57 case "setclientgroup":
58 $ret = $myga->MSG_SET_CLIENT_GROUP($argv[2]);
60 echo "Resetting AD client group details succeeded\n";
62 echo "Resetting AD client group details failed\n";
66 $ret = $myga->MSG_SET_ADMIN_GROUP($argv[2]);
68 echo "Resetting AD admin group details succeeded\n";
70 echo "Resetting AD admin group details failed\n";
76 $ret = $myga->MSG_ASSIGN_TOKEN($username, $tokenid);
79 $ret = $myga->MSG_GET_HARDWARE();
80 foreach($ret as $tok) {
81 echo "Token, ".$tok["name"]." is of type ".$tok["type"]."\n";
87 $tokentype = $argv[4];
88 $ret = $myga->MSG_ADD_HARDWARE($tokenid, $tokenkey, $tokentype);
90 case "provisiontoken":
94 if(isset($argv[3])) $ttype = $argv[3];
95 if(isset($argv[4])) $tkey = $argv[4];
96 $ret = $myga->MSG_PROVISION_USER($username, $ttype, $tkey);
102 if(isset($argv[2])) $group = $argv[2];
103 if(isset($argv[3])) $partof = $argv[3];
104 if(isset($argv[4])) $onlytokens = $argv[4];
105 $ret = $myga->MSG_GET_USERS($group, $partof, $onlytokens);
106 foreach($ret as $key => $val) {
107 $real = $val["realname"];
108 $user = $val["username"];
110 if($val["hastoken"]) {
113 echo "$hastok$real ($user)\n";
117 $ret = $myga->MSG_DELETE_USER($argv[2]);
119 echo "Delete user token succeeded\n";
121 echo "Delete user token failed\n";
125 echo "No such command, ".$argv[1]."\n";