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 // here we "init" the server, if we're ad, we attempt to connect to AD and if it all works
25 // we then create the db
26 // $m["backend"] = "AD|IN";
28 // $m["domain"] = "somedomain.com";
29 // $m["user"] = "someuser";
30 // $m["pass"] = "somepassword";
31 // $m["userdef"] = "user definition paramaters";
33 // $m["user"] = "someuser";
34 // $m["pass"] = "somepass";
35 if($initState != "init") {
39 if($msg["backend"] == "AD") {
41 // attempt connect to AD, verify creds
42 $addom = $msg["domain"];
43 $adlogin = $msg["user"];
44 $adpass = $msg["pass"];
45 $adclientdef = $msg["clientdef"];
46 $adadmindef = $msg["admindef"];
48 // now wee test our logins...
49 // first look up the domain name stuff
50 $servers = dns_get_record("_gc._tcp.$addom");
51 if(count($servers)<1) {
52 echo "AD servers cant be found, fail!\n";
55 // we should check all servers, but lets just go with 0 for now
56 $cnt = ldap_connect($servers[0]["target"], $servers[0]["port"]);
57 ldap_bind($cnt, "$adlogin", "$adpass");
63 confSetVal("ad.domain", $addom);
64 confSetVal("ad.user", $adlogin);
65 confSetVal("ad.pass", $adpass);
66 confSetVal("ad.encryptionkey", generateHexString(32));
67 confSetVal("ad.clientdef", $adclientdef);
68 confSetVal("ad.admindef", $adadmindef);
70 $initState = "running";
73 // and that should be it... i think cept im in a forked erg.. lets assume it works, need pain i do not.
76 } else if($msg["backend"] == "IN") {
81 // create the user in the db
82 $username = $msg["user"];
83 $password = $msg["pass"];
85 $myga = new gaasdGA();
86 $myga->setUser($username);
88 if($password == "") $pass = "";
89 else $pass = hash('sha512', $password);
92 $db->query($sql = "update users set users_password='$pass' where users_username='$username'");
94 $initState = "running";