Skip to content

Instantly share code, notes, and snippets.

@seanmckinley
Created March 29, 2018 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanmckinley/1914a1682725769b44bd5b2d3eb6430e to your computer and use it in GitHub Desktop.
Save seanmckinley/1914a1682725769b44bd5b2d3eb6430e to your computer and use it in GitHub Desktop.
## Code binds to LDAP, searches users, returns multi-dimensional array for groups like so.
## Each element in the array represents a given users AD groups
## user_groups = [ [group1,group2], [group2,group3], [group2,group4] ]
My goal here is to get the common groups among all of the arrays and the only way I've found so far is this:
user_groups[0] & user_groups[1] & user_groups[2]
=> [group2]
Unfortunately, that's pretty static and only works for 3 users and I'm too dumb to think of a clever way to do this better.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment