lgduong
asked on
PHP: Get all groups from Active Directory
I am trying to just get all the global and local groups from active directory.
I am able to bind to the ldap, but I don't know how to go about getting the groups.
Can someone help?
The following code worked with set variables:
This is where I don't know what filter to use to get the group:
I am able to bind to the ldap, but I don't know how to go about getting the groups.
Can someone help?
The following code worked with set variables:
$ldapconn = ldap_connect($ad_host,$ad_port) or die("Could not connect to LDAP server.");
@ldap_set_option($ldapconn , LDAP_OPT_PROTOCOL_VERSION, 3);
@ldap_set_option($ldapconn , LDAP_OPT_REFERRALS, 0);
// binding to ldap server
$ldapbind = ldap_bind($ldapconn,$userlogin, $password);
This is where I don't know what filter to use to get the group:
if ($ldapbind)
{
$baseDN = "dc=test,dc=local";
$strFilter = "(ou=accounts)";
$strAttributes = array("Group");
$group_search = ldap_search($ldapconn,$baseDN,$strFilter,$strAttributes);
}
Try filter objectcategory=group
ASKER
JulianH,
It is not objectcategory=group. It is objectClass=group. I was able to parse out the group from this. As a follow up, do you know how I can get the name or number of users that belong to this group?
Thanks for your assistance.
It is not objectcategory=group. It is objectClass=group. I was able to parse out the group from this. As a follow up, do you know how I can get the name or number of users that belong to this group?
Thanks for your assistance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.