• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

Undefined index Error - PHP LDAP

I'm using php to display users from the LDAP and i'm trying to output their usernames, so i am using this piece of code:
    for ($i=0; $i < $entries["count"]; $i++)
    {
        echo $entries[$i]["sAMAccountName"][0]."<br />";
    }

Although this produces the following error for each user:
Notice: Undefined index: sAMAccountName in C:\xampp\htdocs\test4.php on line 45

Using 'displayname' works. Anyone know what is causing this?

Thanks.
0
alumwell
Asked:
alumwell
  • 2
  • 2
1 Solution
 
Sander StadSysteemontwikkelaar, Database AdministratorCommented:
Try the column name "SAMAccountName", maybe that helps
0
 
alumwellAuthor Commented:
Unfortunatly not. Just tried it. Thanks.

Anyone got any suggestions?

Thanks.
0
 
Sander StadSysteemontwikkelaar, Database AdministratorCommented:
I had a script that had the same problem ones and I looked it up and I changed the column to the following name "samaccountname" all in lower case.
At this script to your code to see all the results maybe that can help you:
 

foreach ($entries[$i] as $k => $v) {
    echo "Key is ".$k;
}

Open in new window

0
 
alumwellAuthor Commented:
Worked. Thanks.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now