3 require_once("../../lib/ga4php.php");
5 // TODO: This code works, but needs to be fixed and commented properly
6 // TODO: setup encryption into AD
9 // define our token class
10 class myGA extends GoogleAuthenticator {
11 function getData($username) {
12 global $dsconnect, $host, $binduser, $bindpass, $basecn;
14 // set this to default to begin with
17 // we search for a username that matches what we've been passed
18 $sr = ldap_search($dsconnect, "$basecn", "samaccountname=$username");
19 $info = ldap_get_entries($dsconnect, $sr);
26 for($i=1; $i<15; $i++) {
27 $valname = "extensionattribute$i";
28 if(isset($info[0]["$valname"][0])) {
29 $val = $info[0]["$valname"][0];
30 // we are looking for an extension attribute that has a start of "ga4php"
31 if(preg_match('/^ga4php.*/', $val)>0) {
32 $attr_name = $valname;
38 // yeah, totally works.... HAH
39 if($attr_name != false) {
40 $tokend = $info[0]["$attr_name"][0];
41 $expl = explode(":", $tokend);
42 $tokendata = $expl[1];
47 // and there you have it, simple eh?
51 // now we need a function for putting the data back into our user table.
52 // in this example, we wont check anything, we'll just overwrite it.
53 function putData($username, $data) {
54 global $dsconnect, $host, $binduser, $bindpass, $basecn;
60 // set this to default to begin with
63 // we need to track the "first" blank attribute
66 // we search for a username that matches what we've been passed
67 $sr = ldap_search($dsconnect, "$basecn", "samaccountname=$username");
68 $info = ldap_get_entries($dsconnect, $sr);
69 $dn = $info[0]["distinguishedname"][0];
76 for($i=1; $i<15; $i++) {
77 $valname = "extensionattribute$i";
78 if(isset($info[0]["$valname"][0])) {
79 $val = $info[0]["$valname"][0];
80 // we are looking for an extension attribute that has a start of "ga4php"
81 if(preg_match('/^ga4php.*/', $val)>0) {
82 $attr_name = $valname;
85 if($blank_attr == false) {
86 // this will cathc the first unset extension variable name, if we need it
87 $blank_attr = "$valname";
93 // if the attr_name is not set, we need to set $blank_attr
94 if($attr_name == false) {
96 error_log("setting for $username, $blank_attr");
97 $infod["$blank_attr"][0] = "$data";
99 error_log("setting for $username, $attr_name");
100 $infod["$attr_name"][0] = "$data";
103 error_log("att end of put data for $dn, $infod");
105 return ldap_modify($dsconnect, $dn, $infod);
109 // not implemented yet
110 function getUsers() {