Solved

Undefined index Error - PHP LDAP

Posted on 2008-10-17
4
438 Views
Last Modified: 2013-12-19
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
Comment
Question by:alumwell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Sander Stad
ID: 22739814
Try the column name "SAMAccountName", maybe that helps
0
 

Author Comment

by:alumwell
ID: 22741030
Unfortunatly not. Just tried it. Thanks.

Anyone got any suggestions?

Thanks.
0
 
LVL 9

Accepted Solution

by:
Sander Stad earned 500 total points
ID: 22755791
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
 

Author Closing Comment

by:alumwell
ID: 31507081
Worked. Thanks.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question