I wonder if anyone out there has done much in PHP with LDAP, connecting to AD for an Intranet?
I have built the site, but need to connect with AD, so I can see who has logged on, and assign certain levels of access.
The queries based on levels is straight forward enough - but the LDAP is proving impossible.
I have added this code:
Code: Select all
<?
$ldap = ldap_connect('roy-archive');
if(!$ldap) {
die('Could not connect to LDAP server.');
}
if(!ldap_bind($ldap, $ldap_user, $password)) {
die('Could not bind to LDAP server.');
}
$base_dn = 'dc=name,dc=co,dc=uk';
$search = ldap_search($ldap, $base_dn, 'uid='.$username);
if(ldap_count_entries($ldap, $search) < 1) {
die('Username not found');
}
$info = ldap_get_entries($ldap, $search);
if(isset($info[0]['name'])) {
echo 'Username '.$username.' has name '.$info[0]['name'];
} else {
echo 'Entry -name- not found in username '.$username;
}
ldap_close($ldap);
?>It looks like LDAP isn't even switched on, but I haven't a clue how to do that. So if anyone can answer it for me, or guide me, I'd be most grateful.Fatal error: Call to undefined function ldap_connect() in C:\xampp\phpmyadmin\royintranet\index.php on line 7
Regards
Simon