Undefined index Error - PHP LDAP

Posted on 2008-10-17
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?

Question by:alumwell
  • 2
  • 2

Expert Comment

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

Author Comment

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

Anyone got any suggestions?


Accepted Solution

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


Author Closing Comment

ID: 31507081
Worked. Thanks.

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to join on ID, with prefix? 15 58
Insert values are dynamic 11 41
Cannot call a static method on an Eloquent object 6 29
Loop through multiple arrays 13 27
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now