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
Solved

Undefined index Error - PHP LDAP

Posted on 2008-10-17
4
437 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
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Sub-Select Query Returning Duplicate Result 7 45
Perl Versus AWK? 7 52
subtr returning incorrect value 8 29
PHP 5.6 and 7.x 4 22
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

860 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