3 // the global lib sets alot of global variables, its fairly unexciting
4 $BASE_DIR = realpath(dirname(__FILE__)."/../../");
7 // the tcp port number we use for comms
8 $TCP_PORT_NUMBER = 21335;
9 global $TCP_PORT_NUMBER;
14 // the messages structure, used to extend gaas if needed
15 define("MSG_STATUS", 18);
16 define("MSG_INIT_SERVER", 19);
17 define("MSG_SET_AD_LOGIN", 20);
19 // the gaasd call's $MESSAGE[<MSG>]_server() for the server side
20 // and $MESSAGE[<msg>]_client() for the client side
21 $MESSAGES[MSG_STATUS] = "gaasStatus";
22 $MESSAGES[MSG_INIT_SERVER] = "gaasInitServer";
23 $MESSAGES[MSG_SET_AD_LOGIN] = "gaasSetADLogin";
32 function adTestLogin($domain, $user, $password)
34 $servers = dns_get_record("_gc._tcp.$domain");
35 if(count($servers)<1) {
36 echo "AD servers cant be found for $domain, fail!\n";
39 echo count($servers)." AD servers returned, using ".$servers[0]["target"]."\n";
41 // we should check all servers, but lets just go with 0 for now
42 $cnt = ldap_connect($servers[0]["target"], $servers[0]["port"]);
44 $bind = ldap_bind($cnt, "$user@$domain", "$password");
46 echo "login has succeeded\n";
49 echo "login has failed\n";
54 function getADGroups($domain, $user, $password)
59 function generateRandomString($len)
62 $strpos = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
64 for($i=0; $i<$len; $i++) {
65 $str .= $strpos[rand(0, strlen($strpos)-1)];
71 function generateHexString($len)
74 $strpos = "0123456789ABCDEF";
76 for($i=0; $i<$len; $i++) {
77 $str .= $strpos[rand(0, strlen($strpos)-1)];