delphiactive-directoryldapadodelphi-2006

Querying if a user is a member of a group


I have no experience with Active Directory.

I am using Delphi to develop an application which interacts with Active Directory. I need to know the best way to test whether an Active Directory user belongs to a specified group. How do I do that?

I'm using Delphi 2006 BDS.


Solution

  • You should take nested groups into account, the easiest way is to use the tokenGroups attribute that contains a (computed) array of SID's (including nested groups). From there you can either convert this list of sids to names (by feeding it to DsCrackNames) or get the SID from the group you wish to check and compare sids (EqualSid)