Hi,
AM trying to develop a report that audits sql server AD Groups. I am trying to retrieve the list of all the members in the AD groups on SQL server that starts with a common prefix, Say 'XYZ_'
SO far i have managed to write the query till here.
SELECT sAMAccountName as Login, CN as Name, GivenName as FirstName,SN as LastName, DisplayName as FullName, UserAccountControl FROM OPENQUERY( ADSI, 'SELECT sAMAccountname,givenname,sn,displayname,useraccountcontrol,CN FROM ''LDAP:// DC=xyz,DC=com'' WHERE objectCategory=''person'' AND objectClass=''user'' AND memberOf=''CN=XYZ_MyGroup,OU=abc,OU=SQL Security,OU=Groups,DC=xyz,DC=com'' ORDER BY CN')
The above query will give me member details of the AD group 'XYZ_MyGroup'. However am trying to get the member details of all the AD groups that have the prefix 'XYZ_'. Any suggestions would be greatly appreciated.
Many Thanks
BHanu