troubleshooting Question

T-SQL OPENQUERY to return user 'description' from Active Directory help needed

Avatar of softbreeze
softbreezeFlag for United States of America asked on
DatabasesMicrosoft SQL ServerActive Directory
6 Comments1 Solution11109 ViewsLast Modified:
I'm trying to get the user 'description' attribute from W2K3 Active Directory. I use the following T-SQL to add a link server:
sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces', 'ADSDSOObject', 'adsdatasource'

and the following to get the givenName, sn, and mail
                'SELECT givenName, sn, mail
                 FROM ''LDAP://DC=wcc,DC=net''
                 WHERE objectCategory = ''Person'' AND objectClass = ''user''')

but when I add 'description' like this:
                'SELECT givenName, sn, mail, description
                 FROM ''LDAP://DC=wcc,DC=net''
                 WHERE objectCategory = ''Person'' AND objectClass = ''user''')

it fails with the error:
Msg 7346, Level 16, State 2, Line 1
Cannot get the data of the row from the OLE DB provider "ADSDSOObject" for linked server "ADSI". Could not convert the data value due to reasons other than sign mismatch or overflow.

Can someone show me how to get the 'description' attribute with a T_SQL Statement?

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros