Hi there,
I have a small problem. The following php pulls data from the ldap search. It all works fine but once the person has logged in they are greeted with a "hello John welcome to the site". The issue is that it prints a "1" after the john like so: "hello John1 welcome to the site"
The authenticate code:
// verify user and password
if($bind = @ldap_bind($ldap, $user . $ldap_usr_dom, $password)) {
// valid
// check presence in groups
$filter = "(sAMAccountName=" . $user . ")";
$attr = array("memberof","cn","mail","givenName");
$result = ldap_search($ldap, $ldap_dn, $filter, $attr);
$entries = ldap_get_entries($ldap, $result);
ldap_unbind($ldap);
// check groups
foreach($entries[0]['memberof'] as $grps) {
// is manager, break loop
if (strpos($grps, $ldap_manager_group)) { $access = 2; break; }
// is user
if (strpos($grps, $ldap_user_group)) $access = 1;
}
if ($access != 0) {
// establish session variables
$_SESSION['user'] = $user;
$_SESSION['access'] = $access;
$_SESSION['name'] = $entries[0]['cn'][0];
$_SESSION['email'] = $entries[0]['mail'][0];
$_SESSION['givenname'] = $entries[0]['givenname'][0];
return true;
} else {
// user has no rights
return false;
}
} else {
// invalid name or password
return false;
}
}
And this is the code that prints the persons name:
<?php echo print_r($_SESSION['givenname']);?>
Any help with this would be great