Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    54

    Unanswered: Query users in a Security Group with LDAP

    I have a linked server set up and working correctly. I can create a query to get all the users from active directory with something like this:

    SELECT [name], [samaccountname] from OpenQuery( ADSI,
    'SELECT name, samaccountname FROM ''LDAP://DC=domain,DC=com'' WHERE objectClass = ''user'' and objectCategory=''Person''')

    Now I am trying to select all the users in a specifed security group, but I am not having much luck. What is the best way to get this?

    Thanks much.

  2. #2
    Join Date
    Aug 2004
    Posts
    54
    If that can't be done, is there anyway to check if a user is a member of a group or not through a linked server?

  3. #3
    Join Date
    Oct 2008
    Posts
    2
    Dear Ten Spoons,

    I've only just joined dBforums and am looking at the same sort of issue.

    If the security group is also defined as a login on the relevant SQL Server server, then members of a security can be retrieved as follows:

    exec master.. xp_logininfo 'yourDomain\yourSecurityGroup', 'members'

    (i.e. it won't work on any old security group, just ones that are known to SQL Server.)


    Cheers, Murray.

  4. #4
    Join Date
    Oct 2008
    Posts
    2
    Dear Ten Spoons,

    I'm sure you have tracked down an answer by now but one can be found here:

    http://www.eggheadcafe.com/software/...ference-o.aspx

    (i.e. add in ' and memberOf = ''CN=yourSecurityGroup,OU=yourOrganisationalUnit1, OU=yourOrganisationalUnit2,etc,DC=yourDCelement1,D C=yourDCelement2,etc' )


    Cheers, Murray.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •