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") {
48 echo "Backend is AD with params of\n";
52 // attempt connect to AD, verify creds
53 $addom = $msg["domain"];
54 $adlogin = $msg["user"];
55 $adpass = $msg["pass"];
56 $adclientdef = $msg["clientdef"];
57 $adadmindef = $msg["admindef"];
59 // now wee test our logins...
60 // first look up the domain name stuff
61 $servers = dns_get_record("_gc._tcp.$addom");
62 if(count($servers)<1) {
63 echo "AD servers cant be found, fail!\n";
66 // we should check all servers, but lets just go with 0 for now
67 $res = adTestLogin($addom, $adlogin, $adpass);
69 echo "AD login test failed\n";
72 echo "AD login test succeeded\n";
78 confSetVal("ad.domain", $addom);
79 confSetVal("ad.user", $adlogin);
80 confSetVal("ad.pass", $adpass);
81 confSetVal("ad.encryptionkey", generateHexString(32));
82 confSetVal("ad.clientdef", $adclientdef);
83 confSetVal("ad.admindef", $adadmindef);
88 // and that should be it... i think cept im in a forked erg.. lets assume it works, need pain i do not.
89 echo "its all good at the server\n";
92 } else if($msg["backend"] == "IN") {
97 // create the user in the db
98 $username = $msg["user"];
99 $password = $msg["pass"];
101 $myga = new gaasdGA();
102 $myga->setUser($username);
104 if($password == "") $pass = "";
105 else $pass = hash('sha512', $password);
108 $db->query($sql = "update users set users_password='$pass' where users_username='$username'");
110 $initState = "running";
118 function gaasSetADLogin_server($msg)
120 global $initState, $backEnd;
122 if($initState != "running") {
123 return "not in running init state";
126 if($backEnd != "AD") {
127 return "not setup as AD client";
130 $addom = $msg["domain"];
131 $adlogin = $msg["user"];
132 $adpass = $msg["pass"];
133 $adclientdef = $msg["clientdef"];
134 $adadmindef = $msg["admindef"];
136 $res = adTestLogin($addmo, $adlogin, $adpass);
138 return "not able to connect to AD with given cred's";
141 confSetVal("ad.domain", $addom);
142 confSetVal("ad.user", $adlogin);
143 confSetVal("ad.pass", $adpass);
144 confSetVal("ad.clientdef", $adclientdef);
145 confSetVal("ad.admindef", $adadmindef);