Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2427
  • Last Modified:

How to pull list of AD users and groups they belong to?

I need to produce a list of all of my Active Directory users and what groups they are members of.

My first thought was some kind of vb script to pull the data.  Has anyone done this?  I hate reinventing the wheel.
0
jcits
Asked:
jcits
  • 4
  • 3
  • 2
1 Solution
 
thenoneCommented:
You can go into Active Directory users and groups.Create a query and then export list.
0
 
jcitsAuthor Commented:
Ok, I can see how you can create what I would call a filter.  I don't see any way to tell AD to pull the group data from the user, though.

Doesn't seem to be any way to define what fields to return at all.
0
 
thenoneCommented:
click on common queries and thne click on advanced.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
Farhan KaziSystems EngineerCommented:
Greetings Jcits,

Click Start -> Run -> Cmd.exe -> OK -> Now type following command line statement.

DSQuery * -Filter "(sAMAccountType=805306368)" -Attr samAccountName memberof -Limit 0 -L >UserGoups.txt

Check "UserGoups.txt" file.

Hope this helps!
Farhan
0
 
jcitsAuthor Commented:
Exactly what I needed.  Farhan, can I ask where you came up with the SAM account type?  Perhaps I can educate myself a bit and save questions in the future.
0
 
jcitsAuthor Commented:
Oops.  Looks like the solution you gave pulls all groups EXCEPT the primary group.
0
 
Farhan KaziSystems EngineerCommented:
Following is the of possible value for samAccountType attribute.

268435456 = GROUP_OBJECT
268435457 = NON_SECURITY_GROUP_OBJECT
536870912 = ALIAS_OBJECT
536870913 = NON_SECURITY_ALIAS_OBJECT
805306368 = NORMAL_USER_ACCOUNT
805306369 = MACHINE_ACCOUNT
805306370 = TRUST_ACCOUNT
1073741824 = APP_BASIC_GROUP
1073741825 = APP_QUERY_GROUP
2147483647 = ACCOUNT_TYPE_MAX

>> Exactly what I needed.  
Can I ask why did you assign grade 'B' ??
0
 
jcitsAuthor Commented:
Only because the primary group is missing.  
0
 
Farhan KaziSystems EngineerCommented:
OK that good :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now