?
Solved

PHP LDAP query

Posted on 2007-08-03
8
Medium Priority
?
361 Views
Last Modified: 2008-02-01
I am trying to convert this ldap query how would I do that?

<cfldap action="QUERY" name="UserData2" attributes="sn,givenname,telephonenumber,manager,ntUserDomainId,cupJobTitle,ou,uid,EMPLOYEENUMBER,managerEMPLOYEENUMBER,cn,mailRoutingAddress"
start="o=cup.com"
scope="SUBTREE"
filter="uid=#user#"
server="ldap.cce.cup.com"
port="389">
0
Comment
Question by:lhaluska
  • 4
  • 4
8 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 19627093
See http://www.php.net/ldap basicly like this:

$ds=ldap_connect("ldap.cce.cup.com:389");
$r=ldap_bind($ds);
$sr=ldap_search($ds, "o=cup.com", 'uid='.$user, explode(',', 'n,givenname,telephonenumber,manager,ntUserDomainId,cupJobTitle,ou,uid,EMPLOYEENUMBER,managerEMPLOYEENUMBER,cn,mailRoutingAddress');


$info = ldap_get_entries($ds, $sr);
0
 
LVL 1

Author Comment

by:lhaluska
ID: 19627256
I am getting this error.
Parse error: syntax error, unexpected ';' in C:\Inetpub\wwwroot\ServiceRequest\ldaptest.php on line 4
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 2000 total points
ID: 19627352
Yes that code is untested. Missed a closing ) of ldap_search before the mailRoutingAddress');
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:lhaluska
ID: 19655553
Hi Hernst42 I don't see where you missed the ) can you repaste the new code?
0
 
LVL 1

Author Comment

by:lhaluska
ID: 19655602
I think I found where it goes but I am getting a new error..
Notice: Undefined variable: user in C:\Inetpub\wwwroot\ServiceRequest\ldaptest.php on line 4
0
 
LVL 48

Expert Comment

by:hernst42
ID: 19656616
You will need to define $user in your php-code, don't know where it was comming from in CF
0
 
LVL 1

Author Comment

by:lhaluska
ID: 19719694
Hey hernst42,
If I want from that ldap query the email address and the phone number how would that?
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 2000 total points
ID: 19719773
It should be in the $sr.
make a var_dump($sr) and have a look at the returned array structure.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

840 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