Get AD group's member IDs

I am trying to come up with a sql server script that will list IDs and their level of access. I have done the part where t checks for all Logins on the SQL Server and database user. But a lot of these logins are actually Windows AD groups and not individual IDs. Is there a way that I can pass the groupID to a bat file and the bat file checks if its a group and returns all the IDs that are a part of that group?

Many thanks,
Chetan1981
chetan1981Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BodestoneCommented:
Try the following. It should return all the AD members of the SQL login if that login is a group

xp_logininfo @acctname = 'mySQLLogin',
   @option = 'members'
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BodestoneCommented:
Did you have any luck with that by the way? If you need to do more complex queries on it you can put it in a temp table and run scripts from there:


INSERT #groupInfo
exec xp_logininfo @acctname = 'mySQLLogin', @option = 'members'

SELECT * FROM #groupInfo
--and the other stuff you need to do

DROP TABLE #groupInfo
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.