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