I posted about this earlier today, and the solution was so simple and straight-forward that I’m posting the solution in a separate post. So, to create a view in SQL Server of your AD users, simply do this:
Step 1: Create a linked server to your Active Directory
sp_addlinkedserver ‘ADSI’, ‘Active Directory Service Interfaces’, ‘ADSDSOObject’, ‘adsdatasource’
Step 2: Create a view in SQL server using OPENQUERY to select from Active Directory
CREATE VIEW dbo.vw_AD_USER_INFO
SELECT * FROM OpenQuery(ADSI, ‘SELECT title, displayName, sAMAccountName, givenName, telephoneNumber, facsimileTelephoneNumber, sn FROM ”LDAP://DC=whaever,DC=domain,DC=org” where objectClass = ”User”’)
Now, this might not exactly work for you if your AD Schema is different than ours, etc, but for me it worked like a charm, and the general concept should apply to your LDAP server.