SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 get al users from active directory group
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jimoomba
Yak Posting Veteran

India
90 Posts

Posted - 01/04/2013 :  05:33:35  Show Profile  Reply with Quote
Hi All,

I wanted to write a sql query to return all the users from a specific AD Group specifying the Group Name instead of the CN value in memberof.

I have written the query as shown below. kIndly help me on the same :

SELECT sAMAccountName as Login
FROM OPENQUERY( ADSI,
'SELECT sAMAccountname FROM ''LDAP:// DC=<<MyDomainName>>,DC=com''
WHERE objectCategory=''person'' AND objectClass=''user'' AND memberOf=''CN=<<MyGroupName>>,OU=BI,OU=Administrator Accounts,OU=MIS,OU=Corporate Users,DC=<<MyDomainName>>,DC=com''')

Kindly help me on the same

Thanks

rams

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 01/04/2013 :  21:36:10  Show Profile  Reply with Quote
try like


SELECT
*
FROM OPENQUERY(ADSI,'<LDAP://DC=<<MyDomainName>>,DC=com>;(&(objectCategory=person)(objectClass=user)(memberOf=<<YourGroupName>>,OU=BI,OU=Administrator Accounts,OU=MIS,OU=Corporate Users,DC=<<MyDomainName>>,DC=com));cn,ADsPath;subtree')


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000