dsquery ldap php

Posted on 2005-02-24
Medium Priority
Last Modified: 2008-01-09
Very noobish with ldap/dsquery. Simple question:

How can I do a dsquery in php and interpret the results. What i'm ultimately trying to do is simply get all the groups that exist only in this directory (no duplicates, just unique/distinct list).

The dsquery I'd like to use is:

dsquery group OU=Users and Groups,DC=Applications,DC=MHGroups

I'd probably need to format it with the -o option also.

Question by:whozie
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
LVL 25

Accepted Solution

Marcus Bointon earned 1000 total points
ID: 13401420
Have you looked at the built-in ldap stuff in PHP: http://www.php.net/manual/en/ref.ldap.php

If you're used to the command line version, you can just use that and parse the output using exec(), system() etc.

Author Comment

ID: 13415792
How do you actually call the query in php though? eg: ldap_search() ??
LVL 25

Expert Comment

by:Marcus Bointon
ID: 13418209
Yes, ldap_search() is the thing to use. You'll need to get the results of it using ldap_get_entries() and so on.

Author Comment

ID: 13423135
do I just put "dsquery group" in the filter?

function all_groups() {
            if($this->_bind) {
                  $sr=ldap_search($this->_conn,$this->_base_dn,"dsquery group");
                  $entries = ldap_get_entries($this->_conn, $sr);
                  return $entries;

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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.
Suggested Courses

765 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