Skip to content

How to check if a user is a member of an Active Directory group

I had to write some quick code for a project at work where I needed to audit a group of users and confirm if the user appeared in a predefined Active Directory group. There are a number of examples online, and I read some interesting approaches from authors at:

  1. Find what Active Directory groups a user is in
  2. Create a SQL Server view of your Active Directory users
  3. How to: (Almost) Everything in Active Directory via C#
  4. Searching the Directory
  5. Quick List for C# Code Examples

Below is a an early release of what I ended up using. Feedback if any would be appreciated.

[snippet slug=check-user-member-active-directory-group lang=bsh]