AndyPet74 AndyPet74 - 7 months ago 79
PHP Question

Get all users in a group PHP/LDAP

I have code to get whatever groups a user is in but I want to build a sync function for a project I am working on and how this function would work is if we just added a new group and we needed to quickly add those users to the Database we'd like to just press sync and have some sort of php code that would take the new group and grab all the users from it and add them to the database instead of having to have them all log in to populate it we'd like that information to be already there. So What I am having trouble finding out how to do is finding who is a member of a group by using the group instead of having the person and checking their group membership. Can this be done, in our current application using C#.net/ASP.net it is being done but this is PHP and slightly different. Is what I am trying to do possible with php and LDAP functions?

Answer

I'm not sure how to do this using the built-in PHP LDAP functions, but I do know it can be done using the adLDAP library.

The basic usage instructions are here, and here is an example from their documentation on how to find all members of a specific group:

$groupMembers = $adldap->group()->members('My Distribution List');