Active directory examples.
[ga4php.git] / unittests / ldapbindtest.php
1 <?php 
2
3 // just trying to test how extensionAttributes work in AD. they seem to be exactly what we're looking for in terms of a place to plonk our data
4 require_once("../../../.dontappearingitandsvn.php");
5 $ds = ldap_connect("$host", 389);
6 if($ds) {
7         $r = ldap_bind($ds, "$binduser", "$bindpass");
8         if($r) {
9                 echo "r is r\n";
10         } else {
11                 echo "r is not r\n";
12         }
13         
14         $sr = ldap_search($ds, "$basecn", "objectclass=user");
15         
16         if($sr) {
17                 echo "sr is sr\n";
18         }
19         
20         $info = ldap_get_entries($ds, $sr);
21         //$info["extensionattribute2"] = "-----";
22         
23         
24         //print_r($info);
25         $i = 0;
26         foreach($info as $key => $val) {
27                 //echo "$key is ".$val["distinguishedname"][0]."\n";
28                 if($val["distinguishedname"][0] != "") {
29                         $user[$i]["dn"] = $val["distinguishedname"][0];
30                         $user[$i]["acn"] = $val["samaccountname"][0];
31                 }
32
33                 $i ++;
34                 //return 0;
35         }
36         
37         foreach($user as $value) {
38                 $cn = $value["dn"];
39                 $sr2 = ldap_search($ds, "$cn", "objectclass=*");
40                 $info = ldap_get_entries($ds, $sr2);
41                 print_r($info);
42                 return 0;
43         }
44         
45         print_r($user);
46         
47 }
48
49 ?>