added hardware token add/list methods.
[ga4php.git] / gaas / lib / globalLib.php
index f3fe9fb..bbfd2fc 100644 (file)
@@ -5,7 +5,7 @@ $BASE_DIR = realpath(dirname(__FILE__)."/../../");
 global $BASE_DIR;
 
 // the tcp port number we use for comms
-$TCP_PORT_NUMBER = 21336;
+$TCP_PORT_NUMBER = 21256;
 global $TCP_PORT_NUMBER;
 
 
@@ -19,6 +19,10 @@ define("MSG_SET_CLIENT_GROUP", 21);
 define("MSG_SET_ADMIN_GROUP", 22);
 define("MSG_PROVISION_USER",23);
 define("MSG_GET_USERS", 24);
+define("MSG_DELETE_USER", 25);
+define("MSG_ASSIGN_TOKEN",26);
+define("MSG_ADD_HARDWARE",27);
+define("MSG_GET_HARDWARE",28);
 
 // the gaasd call's $MESSAGE[<MSG>]_server() for the server side
 // and $MESSAGE[<msg>]_client() for the client side 
@@ -27,8 +31,12 @@ $MESSAGES[MSG_INIT_SERVER] = "gaasInitServer";
 $MESSAGES[MSG_SET_AD_LOGIN] = "gaasSetADLogin"; // domain, user, password
 $MESSAGES[MSG_SET_CLIENT_GROUP] = "gaasSetClientGroup"; // groupname
 $MESSAGES[MSG_SET_ADMIN_GROUP] = "gaasSetAdminGroup";
-$MESSAGES[MSG_PROVISION_USER] = "gaasProvisionUser"; // username
+$MESSAGES[MSG_PROVISION_USER] = "gaasProvisionUser"; // username, tokentype, tokenkey, hardware|software
 $MESSAGES[MSG_GET_USERS] = "gaasGetUsers"; // [admin|client], [name pattern], [only with tokens]
+$MESSAGES[MSG_DELETE_USER] = "gaasDeleteUser"; // username
+$MESSAGES[MSG_ASSIGN_TOKEN] = "gaasAssignToken"; // username, tokenid
+$MESSAGES[MSG_ADD_HARDWARE] = "gaasAddHardwareToken"; // username, tokenid
+$MESSAGES[MSG_GET_HARDWARE] = "gaasGetHardwareTokens"; //
 
 global $MESSAGES;
 
@@ -140,13 +148,15 @@ function userInGroup($user, $domain, $adlogin, $adpass, $group)
        
        //exit(0);
        
+       //echo "usercn: $usercn\n";
        $basecn = preg_replace("/,$/", "", $tcn);
        $sr = ldap_search($cnt, "$basecn", "(&(objectCategory=group)(member:1.2.840.113556.1.4.1941:=$usercn))");
        $fil = "(&(objectCategory=group)(member:1.2.840.113556.1.4.1941:=$usercn))";
        $info = ldap_get_entries($cnt, $sr);
        foreach($info as $kpot => $lpot) {
                if(isset($lpot["samaccountname"])) {
-                       if($lpot["cn"][0] == $group) return true;
+                       //echo "checking: ".$lpot["cn"][0]."\n";
+                       if(strtolower($lpot["cn"][0]) == strtolower($group)) return true;
                }
        }
        return false;
@@ -198,9 +208,7 @@ function getUsersInGroup($domain, $adlogin, $adpass, $group)
        $i = 0;
        foreach($info as $kpot => $lpot) {
                if(isset($lpot["samaccountname"])) {
-                       $arbi[$i]["username"] = $lpot["samaccountname"][0];
-                       $arbi[$i]["realname"] = $lpot["name"][0];
-                       $i++;
+                       $arbi[$lpot["samaccountname"][0]] =  $lpot["name"][0];
                }
        }