ADSI Linked Server Errors in SQL Server

ADSI Linked Server Errors in SQL Server

Post by hawg » Sat, 05 Jul 2003 01:09:37

I have created a linked server in SQL Server to Active
Directory.  Now I want to query AD but I am having
problems.  The first problem I am having is in the SQL
Server EM, whenever I try to click on Tables or Views in
the linked server, I get the following error:

Error 7301:  Could not obtain a required interface from
OLE DB provider 'ADSDSOObject'

Am I doing something wrong?

Also, I am trying to learn how to query the AD using this
linked server.  I am able to do a basic query, such as
getting the name of a user or a group, but I can't do any
advanced queries.  For example, I want to get the name of
groups and the members of that group.

I can't find any documentation that helps me identify how
to setup this kind of query.  I want to do it from SQL and
not VB or some other language because I do many of these
ad-hoc and on the fly.

Any suggestions?


ADSI Linked Server Errors in SQL Server

Post by Jian-Shen Lin[M » Tue, 08 Jul 2003 11:54:36

. the detail step to use the SQL Distributed Query by Using ADSI all list
in the KB

To set up a distributed join, first set up ADSI mapping using the
sp_addlinkedserver stored procedure in a SQL Server Tool such as SQL Query
Analyzer. This procedure links a name to an OLE DB provider name.

The following code is an example.

sp_addlinkedserver 'ADSI12', 'Active Directory Services 2.5',
'ADSDSOObject', 'adsdatasource'

You can also use sp_addlinkedsrvlogin to specify which user should be run.

Example of an sp_addlinkedsrvlogin call:

sp_addlinkedsrvlogin ADSI12, true, 'lab\administrator',
'LDAP://,cn=users,dc=lab,dc=com', 'Password'

Then we can use SQL statement as follow:

select * from OpenQuery( ADSI12, 'select AdsPath, name from '
'LDAP://,dc=lab,dc=com' ' ')

2. Active Directory performed without paging are limited to returning a
maximum of the first 1000 record.  ADSI handles the page size
transparently. The client does not have to count the number of objects in
progress. ADSI encapsulates the server interaction for the client. From the
client perspective, the search comes back with a complete result set.

To specify a paged search, you need to set a value for
ADS_SEARCHPREF_PAGESIZE. This value is the number of items to return for
each page. You can also specify a time limit for the search by setting
ADS_SEARCHPREF_PAGED_TIME_LIMIT. This element specifies the maximum time,
in seconds, that the server should spend collecting a page of results
before returning the page to the client. If the limit is reached, the
server stops searching and returns the rows retrieved for the page. A paged
search is transparent to your application because ADSI automatically
continues to retrieve additional pages of results until it reaches the end
of the result set or the end of the time limit that you set.

So from client side, we just need to turn the parameters about these.

There is document about how to tune these parameters.


Jian Shen

This posting is provided "AS IS" with no warranties, and confers no rights.


1. SQL Server linked ADSI server query only returns 1000 records

We are using SQL Server 2000 and Exchange 2000.
I have set up a linked ADSI server and created views using it, however they
only return a maximum of 1000 records.
I know I can get more than 1000 records by querying directly using ADO and
paging, but is there anyway of getting all the records returned using the
SQL Server view?


2. major tech support site

3. Linking ADSI to SQL Server -> Error 7321

4. Please help!!

5. ADSI: SQL Linked Server Query Problems

6. FP editor jpg default compression

7. Adding SharePoint as a linked server to SQL Server

8. Cases for Ipaq with the expansion pack attached?

9. Sql server link to exch server

10. Exchange 5.5 as SQL Server 7 Linked Server

11. Linked Server query fails when SQL Server on remote machine (7321)

12. Returning ADSI in a SQL table (SQL Error 7399)

13. Upgrading From SQL Server 7.0 To SQL Server 2000