Thursday, August 16, 2012

Fun with active Directory

How to find out what ActiveDirectory groups you, or anyone else belongs to.

$de = New-Object System.DirectoryServices.DirectoryEntry          
$searcher = New-Object System.DirectoryServices.DirectorySearcher($de) 
$searcher.Filter = "(sAMAccountName=qatest13)" 
$result = $searcher.FindOne()        
$result.Properties

Also extremely useful, and from SysInternals, is Active Directory Explorer.

LDAP factors prominently in all of this. Someday I might like to have some confidence in what to use as a filter in the searcher. But for now, I'll settle for making a note about what works and not caring why.
(SAM-Account-Name)