Welcome Guest, Not a member yet? Register   Sign In
Getting a user's display name through LDAP/Active Directory
#1

[eluser]Ray Julich[/eluser]
I am successfully authenticating user's with my CI site using the LDAP library. I would like to be able to get the user's full name to be able to display on the web pages. In the LDAP library there is a user_info() function and it looks like I can just do something like:

Code:
$user_info = $this->ldap->user_info($username)

In looking at the LDAP library, it looks like to returns a 3D array, but when I try to print out the information in this array, I get an error.

Code:
echo $user_info[0]['displayname'][0]

[b]A PHP Error was encountered[/b]
Severity: Notice

Message: Undefined index: displayname

I'm not sure if the displayname is actually being set properly or if I'm referencing it incorrectly.
#2

[eluser]bretticus[/eluser]
Why not use the most useful PHP debugging function eva... Smile

Code:
print_r($user_info);

To see what you have exactly?
#3

[eluser]Ray Julich[/eluser]
When I use print_r($user_info), I get the following output:

Code:
Array ( [0] => Array ( [memberof] => Array ( [0] => ) ) )

Looks like it's not getting the user's information out of AD. These are the fields that the function user_info should be getting.
Code:
$fields=array(
"samaccountname",
"mail",
"memberof",
"department",
"displayname",
"telephonenumber",
"primarygroupid");
They are set with the following code:
Code:
$sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
        $entries=ldap_get_entries($this->_conn, $sr);
It looks like the only field that it is printing out is the one that is explicitly set:
Code:
$entries[0]["memberof"][]="CN=Domain Users,CN=Users,".$this->_base_dn;

Any thoughts?
#4

[eluser]bretticus[/eluser]
Sorry, wish I knew that adLDAP library better. However, I've never used it before. Looks like they have a support forum where you can try your luck though.
#5

[eluser]Ray Julich[/eluser]
I will do that, thank you.




Theme © iAndrew 2016 - Forum software by © MyBB