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



The information in this article applies to:

  • Microsoft Active Directory Client Extension, when used with:
    • Microsoft Exchange Server 5.5
    • Microsoft Exchange Server 5.5 SP1
    • Microsoft Exchange Server 5.5 SP2
    • Microsoft Exchange Server 5.5 SP3
    • Microsoft Exchange Server 5.5 SP4

This article was previously published under Q269840

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.

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.

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.

STATUS

This behavior is by design.

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
				

REFERENCES

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

Modification Type:MinorLast Reviewed:11/18/2005
Keywords:kbprb KB269840