Microsoft KB Archive/269840

= PRB: Errors Querying Exchange 5.5 Directory Using ADSI OLE DB Provider =

Article ID: 269840

Article Last Modified on 11/18/2005

-

APPLIES TO

 Microsoft Active Directory Client Extension, when used with:  Microsoft Exchange Server 5.5 Standard Edition

 Microsoft Exchange Server 5.5 Service Pack 1

 Microsoft Exchange Server 5.5 Service Pack 2

 Microsoft Exchange Server 5.5 Service Pack 3</li></ul>

 Microsoft Exchange Server 5.5 Service Pack 4</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q269840

<div class="symptoms_section">

SYMPTOMS
When you query the Microsoft Exchange 5.5 directory using the Active Directory Service Interfaces (ADSI) OLE DB provider, ADSDSOObject, one of the following errors may be returned:

Server: Msg 7330, Level 16, State 2, Line 1 Could not fetch a row from OLE DB provider 'ADSDSOObject'. (SQL Server Distributed Query)

-or-

Admin Limit Exceeded

In some cases, no error is returned but a blank recordset is returned when there should be records.

<div class="cause_section">

CAUSE
This problem is caused by the query returning more records than are specified in the Maximum number of search results returned LDAP property in both the Server and Site LDAP properties.

<div class="resolution_section">

RESOLUTION
There are three possible ways to resolve this problem:
 * Modify the Page Size property to be less than the value of the Maximum number of search results returned property. (This is the recommended resolution.)
 * Increase the value in the Maximum number of search results returned property; this, however, can result in performance problems.
 * If you are doing a Microsoft SQL Server distributed query, modify the filter in the query to return fewer records than are set in the Maximum number of search results returned property.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
The following code sample demonstrates both the problem and the solution.

NOTE: The default setting for the Maximum number of search results returned LDAP property is 100. Increasing this setting can affect the performance of the Exchange server. Also note that it is only possible to set the Page Size property when accessing the OLE DB provider through ActiveX Data Objects (ADO). 'For regular Visual Basic, add project references for: '  Active DS Type Library '  Microsoft ActiveX Data Objects

Dim oConn As New ADODB.Connection Dim oCmd As New ADODB.Command Dim oRS As ADODB.Recordset

'Uncomment the following two lines for use in VBScript. 'Set oConn = CreateObject(&quot;adodb.connection&quot;) 'Set oCmd = CreateObject(&quot;adodb.command&quot;)

oConn.Provider = &quot;ADSDSOObject&quot;

'TO DO: Modify userID and userDomain as appropriate. oConn.Properties(&quot;User ID&quot;) = &quot;cn=userID,dc=userDomain&quot; oConn.Properties(&quot;Password&quot;) = InputBox(&quot;Enter Password&quot;) oConn.Properties(&quot;Encrypt Password&quot;) = True

'The following setting is available with DSClient and later. 'It is not available with ADSI 2.5. 'oConn.Properties(&quot;ADSI Flag&quot;) = 0 oConn.Open &quot;My ADSI Connection&quot;

oCmd.ActiveConnection = oConn oCmd.CommandType = 1 'adCmdText

'TO DO: Modify the distinguished name values: '   Server, Organization, and Site as appropriate. oCmd.CommandText = &quot;Select mail,cn from &quot; _ & &quot;'LDAP://sk_nt4:1003/ou=Land,o=Disney' &quot; _ & &quot;where objectClass='organizationalPerson'&quot;

'The page size is set to 99 to avoid the default 'Exchange server query result limit of 100. oCmd.Properties(&quot;Page Size&quot;) = 99 Set oRS = oCmd.Execute

Do While Not oRS.EOF If Not IsNull(oRS.Fields(&quot;mail&quot;).Value) Then 'Comment for VBScript. Debug.Print oRS.Fields(&quot;mail&quot;).Value 'Uncomment for VBScript. 'wscript.echo oRS.Fields(&quot;mail&quot;).Value End If   If Not IsNull(oRS.Fields(&quot;cn&quot;).Value) Then 'Comment for VBScript Debug.Print oRS.Fields(&quot;cn&quot;).Value 'Uncomment for VBScript. 'wscript.echo oRS.Fields(&quot;cn&quot;).Value End If   oRS.MoveNext Loop

Set oRS = Nothing Set oCmd = Nothing Set oConn = Nothing

<div class="references_section">