Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q269840

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


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("adodb.connection")
'Set oCmd = CreateObject("adodb.command")

oConn.Provider = "ADSDSOObject"

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

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

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

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

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

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

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

↑ Back to the top


References

For additional information, see the "Search LDAP (Directory) Settings - Server" topic in the Microsoft Exchange Administrator Help file.

↑ Back to the top


Keywords: KB269840, kbprb

↑ Back to the top

Article Info
Article ID : 269840
Revision : 5
Created on : 11/18/2005
Published on : 11/18/2005
Exists online : False
Views : 348