3 // this file defines all the messages used by gaaasd
5 // there are only really two status messages at this point - "init" meaning we have no been defined yet
6 // and "running" meaning we have been defined
7 function gaasStatus_server($messages)
9 global $initState, $backEnd;
12 if($initState != false && $backEnd != "") {
20 function gaasInitServer_server($msg)
22 global $initState, $backEnd;
24 error_log("Init server called\n");
25 // here we "init" the server, if we're ad, we attempt to connect to AD and if it all works
26 // we then create the db
27 // $m["backend"] = "AD|IN";
29 // $m["domain"] = "somedomain.com";
30 // $m["user"] = "someuser";
31 // $m["pass"] = "somepassword";
32 // $m["userdef"] = "user definition paramaters";
34 // $m["user"] = "someuser";
35 // $m["pass"] = "somepass";
36 echo "initstate is $initState\n";
43 error_log("init server called when server already init'd\n");
47 if($msg["backend"] == "AD") {
49 // attempt connect to AD, verify creds
50 $addom = $msg["domain"];
51 $adlogin = $msg["user"];
52 $adpass = $msg["pass"];
53 $adclientdef = $msg["clientdef"];
54 $adadmindef = $msg["admindef"];
56 // now wee test our logins...
57 // first look up the domain name stuff
58 $servers = dns_get_record("_gc._tcp.$addom");
59 if(count($servers)<1) {
60 echo "AD servers cant be found, fail!\n";
63 // we should check all servers, but lets just go with 0 for now
64 $res = adTestLogin($addom, $adlogin, $adpass);
66 echo "AD login test failed\n";
69 echo "AD login test succeeded\n";
75 confSetVal("ad.domain", $addom);
76 confSetVal("ad.user", $adlogin);
77 confSetVal("ad.pass", $adpass);
78 confSetVal("ad.encryptionkey", generateHexString(32));
79 confSetVal("ad.clientdef", $adclientdef);
80 confSetVal("ad.admindef", $adadmindef);
85 // and that should be it... i think cept im in a forked erg.. lets assume it works, need pain i do not.
88 } else if($msg["backend"] == "IN") {
93 // create the user in the db
94 $username = $msg["user"];
95 $password = $msg["pass"];
97 $myga = new gaasdGA();
98 $myga->setUser($username);
100 if($password == "") $pass = "";
101 else $pass = hash('sha512', $password);
104 $db->query($sql = "update users set users_password='$pass' where users_username='$username'");
106 $initState = "running";
114 function gaasSetADLogin_server($msg)
116 global $initState, $backEnd;
118 if($initState != "running") {
119 return "not in running init state";
122 if($backEnd != "AD") {
123 return "not setup as AD client";
126 $addom = $msg["domain"];
127 $adlogin = $msg["user"];
128 $adpass = $msg["pass"];
129 $adclientdef = $msg["clientdef"];
130 $adadmindef = $msg["admindef"];
132 $res = adTestLogin($addmo, $adlogin, $adpass);
134 return "not able to connect to AD with given cred's";
137 confSetVal("ad.domain", $addom);
138 confSetVal("ad.user", $adlogin);
139 confSetVal("ad.pass", $adpass);
140 confSetVal("ad.clientdef", $adclientdef);
141 confSetVal("ad.admindef", $adadmindef);