Solved

SQL2005 query into AD via LDAP

Posted on 2010-11-22
3
829 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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