locked
retrieve list of users in a group in active directory RRS feed

  • Question

  • Does anyone know the T-SQL to pull the list of users from a specific group in AD?
    Frank
    Wednesday, November 17, 2010 9:46 PM

Answers

  • This will give the users in the group if that group is a SQL Login. If you directly want to query the active directory then you have to go through LDAP.

    see the below link to do that

    http://sql.dzone.com/news/querying-active-directory-thro


    Regards, Deven ----------------------------------------- Please vote if you find any of my post helpful.
    • Proposed as answer by sqlity.net Wednesday, November 17, 2010 10:07 PM
    • Marked as answer by Frank Kearney Wednesday, November 17, 2010 10:09 PM
    Wednesday, November 17, 2010 10:04 PM

All replies

  • EXEC sys.xp_logininfo @acctname = 'DOMAIN\DEPT', -- sysname
      @option = 'MEMBERS'
    

    Regards, Deven ----------------------------------------- Please vote if you find any of my post helpful.
    • Proposed as answer by Arbi Baghdanian Wednesday, November 17, 2010 10:28 PM
    Wednesday, November 17, 2010 9:58 PM
  • so no more adding a linked server to SQL Server and querying through LDAP?
    Frank
    Wednesday, November 17, 2010 9:59 PM
  • This will give the users in the group if that group is a SQL Login. If you directly want to query the active directory then you have to go through LDAP.

    see the below link to do that

    http://sql.dzone.com/news/querying-active-directory-thro


    Regards, Deven ----------------------------------------- Please vote if you find any of my post helpful.
    • Proposed as answer by sqlity.net Wednesday, November 17, 2010 10:07 PM
    • Marked as answer by Frank Kearney Wednesday, November 17, 2010 10:09 PM
    Wednesday, November 17, 2010 10:04 PM