Is it possible to get information about Active Directory in to SQL Server so I can do different tasks depending on what information the user has in Active Directory?
1. set up a linked server to active directory
2. set up a view to display the information you want.
Code:
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'adsdatasource'
CREATE VIEW viewADContacts
AS
SELECT [Name], SN [Last Name], ST State
FROM OPENQUERY( ADSI,
'SELECT Name, SN, ST
FROM ''LDAP://ADSISrv/ OU=Sales,DC=sales,DC=northwind,DC=com''
WHERE objectCategory = ''Person'' AND
objectClass = ''contact''')
GO
SELECT * FROM viewADContacts
One thing to know. you cannot query 1 to many relationships in AD. Example: you cannot get the groups the person is associated with. you can get their address, email, phone number.
thread183-587842 may also help along with BOL Index: [tt]linked servers, access Windows Directory[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.