Had a request a few weeks ago to get a list of AD users by writing some custom code. While I love to write code, I thought there had to be an easier (faster) way to get my data. There is... t-sql! Here's what I did: 1. Add a linked server to Active Directory.