Hello
My question is: How to retrieve all groups members from active directory.
I have created a linked server and I can query all users and all groups by:

/////////////// ALL USERS ////////////
SELECT sAMAccountname AS AccountName, GivenName AS [First Name], SN AS [Last Name],
mail AS [E-mail Address],
TelephoneNumber AS [Telephone Number], l AS Office,
PostalAddress AS [Postal Address], PostalCode, StreetAddress AS [Street Address],
wWWHomePage AS [Web Page], distinguishedname AS DN
FROM OPENQUERY(ADSI,
'SELECT GivenName, SN, company, department, TelephoneNumber, mail, distinguishedname, title, l, manager, mobile, name, PhysicalDeliveryOfficeName, PostalAddress, PostalCode, sAMAccountname, StreetAddress, wWWHomePage
FROM ''LDAP://MyDomain/DC=Domain,DC=com,DC=mk''
WHERE objectCategory = ''Person'' AND objectClass = ''user''
ORDER BY Name')
Rowset_1
///////////////
////////////// ALL GROUPS ///////////
SELECT sAMAccountname AS AccountName, GivenName AS [First Name], SN AS [Last Name],
mail AS [E-mail Address],
TelephoneNumber AS [Telephone Number], l AS Office,
PostalAddress AS [Postal Address], PostalCode, StreetAddress AS [Street Address],
wWWHomePage AS [Web Page], distinguishedname AS DN
FROM OPENQUERY(ADSI,
'SELECT GivenName, SN, company, department, TelephoneNumber, mail, distinguishedname, title, l, manager, mobile, name, PhysicalDeliveryOfficeName, PostalAddress, PostalCode, sAMAccountname, StreetAddress, wWWHomePage
FROM ''LDAP://MyDomain/DC=Domain,DC=com,DC=mk''
WHERE objectCategory = ''group'' AND objectClass = ''group''
ORDER BY Name')
Rowset_1
////////////////////////////////////////////
but I need to get something like this:
USER FullName Group
--------------------------------------------
User1 User1 User Administrators
User1 User1 User IT
User1 User1 User Reader
User2 User2 User Reader
User3 User3 User Writer
User3 User3 User Log Reader
User3 User3 User Ext Connect

Can somebody help me?

Thank you in advance