X-Git-Url: http://git.pjr.cc/?p=ga4php.git;a=blobdiff_plain;f=gaas%2Flib%2FgaasdMessages.php;h=3b59931274645077400964b7364d53c51eb4ceea;hp=a74df01d1e1e51f62dd85e8b62610b3300e2b48c;hb=40dc7f97626a703a943e27cdcd1a3d6a332a8f27;hpb=085d6c9a7c2286e1e17c6c4573d8910e152addf8 diff --git a/gaas/lib/gaasdMessages.php b/gaas/lib/gaasdMessages.php index a74df01..3b59931 100644 --- a/gaas/lib/gaasdMessages.php +++ b/gaas/lib/gaasdMessages.php @@ -21,6 +21,7 @@ function gaasInitServer_server($msg) { global $initState, $backEnd; + error_log("Init server called\n"); // here we "init" the server, if we're ad, we attempt to connect to AD and if it all works // we then create the db // $m["backend"] = "AD|IN"; @@ -32,7 +33,14 @@ function gaasInitServer_server($msg) // IN expects // $m["user"] = "someuser"; // $m["pass"] = "somepass"; - if($initState != "init") { + echo "initstate is $initState"; + if($initState) { + echo "true\n"; + } else { + echo "false\n"; + } + if($initState) { + error_log("init server called when server already init'd\n"); return false; } @@ -44,7 +52,19 @@ function gaasInitServer_server($msg) $adpass = $msg["pass"]; $adclientdef = $msg["clientdef"]; $adadmindef = $msg["admindef"]; + // now wee test our logins... + // first look up the domain name stuff + $servers = dns_get_record("_gc._tcp.$addom"); + if(count($servers)<1) { + echo "AD servers cant be found, fail!\n"; + } + + // we should check all servers, but lets just go with 0 for now + $res = adTestLogin($addom, $adlogin, $adpass); + if(!$res) { + return false; + } // then @@ -55,12 +75,12 @@ function gaasInitServer_server($msg) confSetVal("ad.encryptionkey", generateHexString(32)); confSetVal("ad.clientdef", $adclientdef); confSetVal("ad.admindef", $adadmindef); + confSetVal("backend", "AD"); - $initState = "running"; + $initState = true; $backEnd = "AD"; // and that should be it... i think cept im in a forked erg.. lets assume it works, need pain i do not. - return true; } else if($msg["backend"] == "IN") { // this ones simpler @@ -86,4 +106,38 @@ function gaasInitServer_server($msg) return false; } } + + +function gaasSetADLogin_server($msg) +{ + global $initState, $backEnd; + + if($initState != "running") { + return "not in running init state"; + } + + if($backEnd != "AD") { + return "not setup as AD client"; + } + + $addom = $msg["domain"]; + $adlogin = $msg["user"]; + $adpass = $msg["pass"]; + $adclientdef = $msg["clientdef"]; + $adadmindef = $msg["admindef"]; + + $res = adTestLogin($addmo, $adlogin, $adpass); + if($res != 0) { + return "not able to connect to AD with given cred's"; + } + + confSetVal("ad.domain", $addom); + confSetVal("ad.user", $adlogin); + confSetVal("ad.pass", $adpass); + confSetVal("ad.clientdef", $adclientdef); + confSetVal("ad.admindef", $adadmindef); + + return true; + +} ?> \ No newline at end of file