Solved

SQL2005 query into AD via LDAP

Posted on 2010-11-22
3
823 Views
Last Modified: 2012-05-10
Hi

I am querying AD via SQL 2005 but really want to get the description field out of AD but the description field seems to be a reserved word or something in the OLE DB connection as throws an error of "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."

I can retrieve any other field other than the description one

Here is a copy of the query

SELECT * FROM OPENQUERY
      (ADSI,'SELECT description FROM ''LDAP://########'' WHERE objectCategory = ''Computer'' ')

yet this works
SELECT * FROM OPENQUERY
      (ADSI,'SELECT location, physicalDeliveryOfficeName, department, displayName, SN,  
            givenName, sAMAccountName, manager, mail, telephoneNumber, mobile  
            FROM ''LDAP://########WHERE objectCategory = ''Computer'' ')

The AD server is setup as a linked server
0
Comment
Question by:techmiss
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Sander Stad
ID: 34187213
Could you try to put "[" and "]" around the field like this:

SELECT * FROM OPENQUERY
      (ADSI,'SELECT [description] FROM ''LDAP://########'' WHERE objectCategory = ''Computer'' ')
0
 

Accepted Solution

by:
techmiss earned 0 total points
ID: 34187307
I have tried all the usual field validators i.e. [, ' and " but none seem to make any difference.

I am not 100% sure that it is a reserved word but maybe its just a strange data type so I have even tried SELECT * FROM OPENQUERY
      (ADSI,'SELECT CAST(description as varchar(50)) FROM ''LDAP://########'' WHERE objectCategory = ''Computer'' ')

But dont think the OLE DB driver can handle data converting requests.

Thanks for your reply tho as any suggestions are welcome
0
 

Author Closing Comment

by:techmiss
ID: 34399285
Not really answered but found solution elsewhere :-(
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now