Sunday, March 22, 2009

Get user details from Active directory by using SQL Commands

select cn, mail, distinguishedname, displayname, samaccountname FROM OPENROWSET('ADSDSOObject',
'adsdatasource;', 'SELECT cn, mail, distinguishedName, displayName, samaccountname
FROM ''LDAP://COMPANY.com'' where objectClass = ''User'' and objectCategory=''Person'' ') ad
inner join usermanagement.dbo.[user] u
on u.useremail = ad.mail

No comments:

Post a Comment

 
span.fullpost {display:inline;}