Skip to content

Instantly share code, notes, and snippets.

@booyaa
Created October 24, 2012 11:04
Show Gist options
  • Save booyaa/3945485 to your computer and use it in GitHub Desktop.
Save booyaa/3945485 to your computer and use it in GitHub Desktop.
Query Active Directory using SQL
SELECT sAMAccountName
,Name
,userAccountControl
,givenName
,sn
FROM 'LDAP://DC=domain,DC=co,DC=uk'
WHERE sAMAccountType = 805306368
AND userAccountControl = 512
ORDER BY sAMAccountName ASC
-- Caveat: will only return 1000 results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment