Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL2005 query into AD via LDAP

Posted on 2010-11-22
3
Medium Priority
?
831 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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