Jump to content

LDAP search in groups


Recommended Posts



I already tried out many different ways but I haven't found a solution yet. I want that my ldap query just filters or search in a group in my example called 'InternetAccess'. But it still give me the student even he is not in that group. It works fine on OUs but it fails on groups.... Somebody has an idea what could be the problem?


    $ad = ldap_connect("");

    //Set some variables
    ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);

    //Bind to the ldap directory
    $bd = ldap_bind($ad,"test@test.edu.au","password")
        or die("Couldn't bind to AD!");

    //Search the directory
    $result = ldap_search($ad, "OU=Students,OU=test,DC=test,DC=edu,DC=au", "CN=InternetAccess");

    //Create result set
    $entries = ldap_get_entries($ad, $result);

    //Sort and print
    echo "User count: " . $entries["count"] . "<br /><br /><b>Users:</b><br />";

    for ($i=0; $i < $entries["count"]; $i++)
        echo $entries[$i]["displayname"][0]."<br />";

    //never forget to unbind!




Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.