|
-
November 21st, 2007, 02:53 PM
#1
ADO, LDAP default 1000 records??
Does anyone know how to get around the default 1000 records (limitation) that are returned when doing LDAP queries? The code below only returns 1000 records. Records consisting of network login IDs and other information. There are well over 1000 login ids but the server only sends the first 1000. There is some sort of MaxPageSize attribute that is set to 1000 but I have no idea how to change it or get the full list of records from our LDAP server. If possible I need to know how go get around this from within VB. . . Anyone have any ideas?
This sample code requires a reference to
<Active DS Type Library>
and
<Microsoft ActiveX Data Objects 2.x Library>
Code:
Private Sub Command1_Click()
Dim cnn As ADODB.Connection
Dim rsLogins As ADODB.Recordset
Dim oRoot As IADs
Dim oDomain As IADs
Dim sBase As String
Dim sFilter As String
Dim sDomain As String
Dim sAttribs As String
Dim sDepth As String
Dim sQuery As String
On Error GoTo GetLoginIDsErrHandler
Set cnn = New ADODB.Connection
Set oRoot = GetObject("LDAP://rootDSE")
sDomain = oRoot.Get("defaultNamingContext")
Set oDomain = GetObject("LDAP://" & sDomain)
sBase = "<" & oDomain.ADsPath & ">"
sFilter = "(&(objectCategory=person)(objectClass=user))"
sAttribs = "distinguishedName"
sDepth = "subTree"
sQuery = sBase & ";" & sFilter & ";" & sAttribs & ";" & sDepth
cnn.Open "Data Source=Active Directory Provider;Provider=ADsDSOObject"
Set rsLogins = cnn.Execute(sQuery)
rsLogins.MoveLast
MsgBox rsLogins.RecordCount
GetLoginIDsExitPoint:
On Error Resume Next
cnn.Close
rsLogins.Close
Set rsLogins = Nothing
Set cnn = Nothing
Set oRoot = Nothing
Set oDomain = Nothing
Exit Sub
GetLoginIDsErrHandler:
Select Case Err.Number
Case Else
MsgBox "Error in blah " & vbCrLf & vbCrLf & Err.Description, vbOKOnly + vbExclamation
Resume GetLoginIDsExitPoint
End Select
End Sub
Last edited by DinoVaught; November 21st, 2007 at 02:55 PM.
-
November 21st, 2007, 05:24 PM
#2
Re: ADO, LDAP default 1000 records??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|