3 // testing how i add stuff
5 require_once("../lib/gaasdClient.php");
7 $myga = new GAASClient();
14 echo "Usage: ".$argv[0]." command [options]\n";
15 echo "\nCommands:\n\tinit AD user password domain clientgroup admingroup - init for active directory installation\n";
16 echo "\tinit IN user password - init for internal database\n";
17 echo "\tstatus - return the status of the server\n";
18 echo "\tsetadlogin username password domain\n";
19 echo "\tsetclientgroup groupname - change the group membership requirements for client's with AD\n";
20 echo "\tsetadmingroup groupname - change the group membership requirements for admin's with AD\n";
21 echo "\tprovisiontoken username [HOTP|TOTP] [KEY] - provision the user \"username\"\n";
22 echo "\tassign username tokenid - assign a hardware token to a user\n";
23 echo "\taddtoken token_name token_key token_type - adds a hardware token to the DB\n";
24 echo "\tgethwtokens - gets a list of hardware tokens by token_name\n";
25 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";
26 echo "\tdeleteuser username - deletes the key for the specified user\n";
37 $ret = $myga->MSG_STATUS();
38 echo "Status: $ret\n";
41 if($argv[2] == "AD") {
42 if($argc < 7) usage();
44 $ret = $myga->MSG_INIT_SERVER("AD", $argv[3], $argv[4], $argv[5], $argv[6], $argv[7]);
46 echo "initialising server succeeded\n";
48 echo "initialising server failed\n";
52 $ret = $myga->MSG_SET_AD_LOGIN($argv[2], $argv[3], $argv[4]);
54 echo "Resetting AD login details succeeded\n";
56 echo "Resetting AD login details failed\n";
59 case "setclientgroup":
60 $ret = $myga->MSG_SET_CLIENT_GROUP($argv[2]);
62 echo "Resetting AD client group details succeeded\n";
64 echo "Resetting AD client group details failed\n";
68 $ret = $myga->MSG_SET_ADMIN_GROUP($argv[2]);
70 echo "Resetting AD admin group details succeeded\n";
72 echo "Resetting AD admin group details failed\n";
78 $ret = $myga->MSG_ASSIGN_TOKEN($username, $tokenid);
81 $ret = $myga->MSG_GET_HARDWARE();
82 foreach($ret as $tok) {
83 echo "Token, ".$tok["name"]." is of type ".$tok["type"]."\n";
89 $tokentype = $argv[4];
90 $ret = $myga->MSG_ADD_HARDWARE($tokenid, $tokenkey, $tokentype);
92 case "provisiontoken":
96 if(isset($argv[3])) $ttype = $argv[3];
97 if(isset($argv[4])) $tkey = $argv[4];
98 $ret = $myga->MSG_PROVISION_USER($username, $ttype, $tkey);
104 if(isset($argv[2])) $group = $argv[2];
105 if(isset($argv[3])) $partof = $argv[3];
106 if(isset($argv[4])) $onlytokens = $argv[4];
107 $ret = $myga->MSG_GET_USERS($group, $partof, $onlytokens);
108 foreach($ret as $key => $val) {
109 $real = $val["realname"];
110 $user = $val["username"];
112 if($val["hastoken"]) {
115 echo "$hastok$real ($user)\n";
119 $ret = $myga->MSG_DELETE_USER($argv[2]);
121 echo "Delete user token succeeded\n";
123 echo "Delete user token failed\n";
127 echo "No such command, ".$argv[1]."\n";