July 14, 2009 at 6:09 am
Hi hopefully someone can help me with this as well.
I'm trying to query my LDAP server.
This is what I have setup:
I have access to our Active Directory and can view users and machines in active directory
- SQL Server 2005 Develper Edition installed on my machine.
- All services started.
SQL Server, SQL Server Agent, SSAS, SQL Server Browser, SQL Full Text Search & SQL Server VSS Writer all started as Local System
SSIS is started as Network Service
- OpenQuery is enabled
(I can run open query commands to other systems)
- I have defined a AD linked server as follows:
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'adsdatasource'
- Having configure the linked server I have run the following query:
select * from openquery
(ADSI,'SELECT cn, mail, co, distinguishedName, displayName
FROM "LDAP://DC=MyDOMAIN,DC=net" where objectClass = "User" ')
where the domain is MyDOMAIN.NET.
I get the error:
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT cn, mail, co, distinguishedName, displayName
FROM "LDAP://DC=MyDOMAIN,DC=net" where objectClass = "User" " for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI".
What is: MSSQLServerADHelper - should this be started??
How do I know if SQL Server is operating in Kerboros mode - where do I change it?
Have I missed anything else??
Sorry - I know this has been covered several times, but I' struggling to see what the issue is!
_____________________________________________________________________________MCITP: Business Intelligence Developer (2005)
July 14, 2009 at 6:51 am
try this code...
select * from openquery
(ADSI,'SELECT cn, mail, co, distinguishedName, displayName
FROM ''LDAP://mydomain''
where objectClass = ''User'' '
)
replaced the " (double quotes) with two ' (single quotes) and of course substitute with your domain information.
July 14, 2009 at 7:33 am
Works a treat - thank you.
Do you mind me asking, if you know the anwser that is, Why does it use single quotes??
I wrongly assumed it would appear that the examples I was looking at used double quotes in the SELECT statement of the open query.
In other script/ programming languages you get problems with statements like the LDAP query you mention as it effectively terminates the statement an starts a new one for every pair of quote marks?
Just curious as I find it unusaul.
Thanks again! 😎
_____________________________________________________________________________MCITP: Business Intelligence Developer (2005)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply