Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
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…
Suggested Courses

579 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