I am trying to query a list of users within a specific active directory group using PHP and LDAP.
I am making the connection and bind as normal:
$connection = ldap_connect($hostname);
$bind = ldap_bind($connection, $username, $password);
For this example, the name of the group I need to acquire the list of users from is "Test Group". There is also a OU of "LDAPTest".
I have tried all of the following, plus a bunch of other ways, and I am just not finding the method to get all of the users within the group "Test Group", which has four users that have been added to it.
$result = ldap_search($connection,"OU=LDAPTest,DC=example,DC=net", "(CN=*)");
$result = ldap_search($connection,"OU=LDAPTest,DC=example,DC=net", "memberOf=Test Group");
$result = ldap_search($connection,"memberOf=Test Group,DC=example,DC=net", "CN=*");
$result = ldap_search($connection,"memberOf=Test Group,DC=example,DC=net", "CN=*");