Solved

ADSI Linked Server not connecting using SQL Server 2008 R2

Posted on 2011-03-11
3
2,341 Views
Last Modified: 2012-05-11
We have two namespaces:
sasnet.external (for our customers)
 and sas.sasinc.com (for our internal users)

Can't wrap my head around why I'm not able to query AD within one namespace but I have no issues with the other.
In using a linked ADSI server, ADSI is the generic name to use correct? Any suggestions would be very helpful.

We have set up an ADSI linked server on one of our SQL Servers to conect to the sas.sasinc.com Active Directory. This works fine with the following Query on sqlserver1:
SELECT     TOP (100) PERCENT employeeID, department, telephoneNumber, mail, sn, givenName
FROM         OPENQUERY(adsi,
                      '  
select  employeeID, givenName,  
    sn,  
    mail,  
    telephoneNumber,  
   department  

from    ''LDAP://dc=sas, dc=sasinc, dc=com''  
where   objectCategory = ''Person''  
        and  
        objectClass = ''user''  
')
                       AS derivedtbl_1
ORDER BY sn

The above query also works fine on sqlserver2, however when I attempt to change the distinquished name to connecto to the external domain we receive errors such as:
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "ADSDSOObject" for linked server "ADSI".

Below is the following query we are using for the sasnet.external on sqlserver2:
SELECT TOP (10) PERCENT  Name, displayName,givenname,distinguishedName, SAMAccountName  FROM OPENQUERY( ADSI, 'SELECT Name, displayName,givenname,distinguishedName, SAMAccountName
                FROM ''LDAP:// dc=sasnet,dc=external''
               
                                ')
GO

I added the linked server using:
/****** Object:  LinkedServer [ADSI]    Script Date: 03/11/2011 11:39:50 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'ADSI', @srvproduct=N'adsdatasource', @provider=N'ADsDSOObject'
 /* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'ADSI',@useself=N'False',@locallogin=NULL,@rmtuser=N'Ldaproaccess',@rmtpassword='########'

GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'collation compatible', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'data access', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'dist', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'pub', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'rpc', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'rpc out', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'sub', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'connect timeout', @optvalue=N'0'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'collation name', @optvalue=null
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'lazy schema validation', @optvalue=N'false'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'query timeout', @optvalue=N'0'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'use remote collation', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'ADSI', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO

EXEC sp_addlinkedsrvlogin @rmtsrvname = N'SASNETDC1', @locallogin = NULL , @useself = N'False',
      @rmtuser = N'SASNET\ldapaccess', @rmtpassword = N'*******'
GO
0
Comment
Question by:SasDev
  • 2
3 Comments
 
LVL 14

Expert Comment

by:Daniel_PL
Comment Utility
Hi,
Is that TOP (10) PERCENT more that 1000 rows? Is so it won't work regarding pagesize in AD.
0
 
LVL 1

Accepted Solution

by:
SasDev earned 0 total points
Comment Utility
The issue ended  up being that our dns could not resolve the Host name. We were initially able to get this working using the ip address. We then flushed the dns on that box specifically and were able to run the above query using the host name.
0
 
LVL 1

Author Closing Comment

by:SasDev
Comment Utility
This was the solution that worked and was not suggested via EE.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

10 Experts available now in Live!

Get 1:1 Help Now