Connecting Tech Pros Worldwide Forums | Help | Site Map

Active directory and LDAP problem

kenobewan's Avatar
Moderator
 
Join Date: Dec 2006
Posts: 4,745
#1: Dec 4 '06
Hi there,

having a problem getting a complete users list out of AD. Code used in component:

oRoot = New DirectoryEntry("LDAP://LDAPServer/DC=domain,DC=com")
oSearcher = New DirectorySearcher(oRoot)

Dim strFilter As String
strFilter += "(&"
strFilter += "(objectCategory=CN=Person,CN=Schema,CN=Configurat ion,DC=rayaust,DC=au,DC=ray,DC=com)"
strFilter += "(samAccountName=*)"
strFilter += "(mail=*)"
strFilter += "(|"
strFilter += "(sn=*)"
strFilter += "(GivenName=*)"
strFilter += ")"
strFilter += ")"

oSearcher.Filter = (strFilter)
oResults = oSearcher.FindAll

Then in the VB.NET of the page:

Me.DsOwnerAD1 = comAD.GetAllUsers()
Dim dv As New DataView(Me.DsOwnerAD1.tblOwnerDetails())
Dim Row As dsOwnerAD.tblOwnerDetailsRow
dv.Sort = "Lastname"
For Each Row In dv.Table.Rows
If Not Row.LastName.ToString = "" Then
Dim Item As String
Dim Item2 As String
Item = Row.LastName.Trim + ", " + Row.FirstName.Trim
Item2 = Row.OwnerAD

Me.lbOwnerADs.Items.Add(New ListItem(Item, Row.FirstName))
End If
Next

Any ideas? I have played with the filter and got slightly different list, but never complete.

Many thanks.

kenobewan's Avatar
Moderator
 
Join Date: Dec 2006
Posts: 4,745
#2: Dec 5 '06

re: Active directory and LDAP problem


Turns out it was the page size that was the key:

[oSearcher.PageSize = 1000]
Reply