X-Git-Url: http://git.pjr.cc/?p=ga4php.git;a=blobdiff_plain;f=example%2Factivedirectory%2Findex.php;h=bf25053caeba08c7bbc951172d3eef4c7d50905e;hp=e0d5ea28a4cc2b7df75e0068b2ee990486d3dc86;hb=6d65f8b20aa37e21eb2f68bb47c8ef30059aba71;hpb=a492905529352ba1c6f7bf675f53e8498745c9bf diff --git a/example/activedirectory/index.php b/example/activedirectory/index.php index e0d5ea2..bf25053 100644 --- a/example/activedirectory/index.php +++ b/example/activedirectory/index.php @@ -3,17 +3,87 @@ * This example shows how you might store user data directly into AD. * AD has several attributes you can use for storing your own data, and * thats what we use + * + * This is only the beginning code, */ // set these -$host = ""; -$binduser = ""; -$bindpass = ""; -$basecn = ""; +$host = ""; // for eg "1.2.3.4" +$binduser = ""; // for eg "administrator" +$bindpass = ""; // for eg "password" +$basecn = ""; // for eg "CN=users, DC=google, dc=com" + +//require our GoogleAuthenticator sub classed class +require_once("extend.php"); +$myga = new myGA(); // this is here so i can keep my atributes somewhere in the tree and not have them float around on git/svn -if(file_exists("../../../.dontappearingitandsvn.php")) require_once("../../../.dontappearingitandsvn.php"); +if(file_exists("../../../../.dontappearingitandsvn.php")) require_once("../../../../.dontappearingitandsvn.php"); + +$error = false; + +// first, lets bind our AD with out management creds +error_log("host is $host"); +$dsconnect = ldap_connect("$host", 389); + +// we mark it global so we can get it in our class +global $dsconnect, $host, $binduser, $bindpass, $basecn; + +if(!$dsconnect) { + $error = true; + $errorText = "Can't Connect to AD"; +} +$ldapbind = ldap_bind($dsconnect, "$binduser", "$bindpass"); +?> + +

Welcome to GA4PHP Talking to Active Directory

+ +$errorText
"; +} +?> + +Our user list within AD: + + + $val) { + //echo "$key is ".$val["distinguishedname"][0]."\n"; + if($val["distinguishedname"][0] != "") { + $user[$i]["dn"] = $val["distinguishedname"][0]; + $user[$i]["acn"] = $val["samaccountname"][0]; + $user[$i]["cn"] = $val["cn"][0]; + } + + $i ++; + //return 0; + } + + foreach($user as $value) { + $cn = $value["cn"]; + $un = $value["acn"]; + echo ""; + } +?> -?> \ No newline at end of file +
NameLogin Name
$cn$un
+testing administrator
+hasToken("administrator")) { + echo "administrator has a token
"; +} else { + echo "administrator has no token, setting one
"; + $myga->setUser("administrator"); +} +?> + \ No newline at end of file