470,641 Members | 1,541 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

VB.NET: DirectoryServices Member.Count limit of 1000

The System.directoryservices.dll has an error, and this error was described
in http://support.microsoft.com/default...b;en-us;839424

At the moment we have Framework version v1.0.3705 and I have remove
System.directoryservices.dll from current Framework version v1.0.3705. In
state of old version I load die new System.directoryservices.dll from the
Framework version v1.1.4322.

I work with the following function of Joe Kaplan \(MVP - ADSI ) 8 Jan. In
2004 uses 22:59 (see below). But if I have more than 1000 Members, I receive
this error:

_COMPlusExceptionCode:-532459699
_message: "In operations error occurred."
_HResult:-2147016672
_xcode:-532459699
StackTrace:"at System . DirectoryServices . Interop . IAds . GetInfoEx
(Object vProperties, Int32 lnReserved) at System . DirectoryServices .
DirectoryEntry . RefreshCache (String [] propertyNames) at SWDIS.MainSWDis .
GetAllAttributeValues (DirectoryEntry entry, String attributeName) in
C:\Develop\TestAD\MainTestAD.vb:line 679"

I has reduced Increment from 1000 to 500 and has ignored code line

....If attributeValues.Count < 1000 Then...

,till 999 (1000) I receive all Members. By 3-rd loop (the range string was
"member;range=1000-1499") I get this error by the function entry.RefreshCache
(New string () {currentRange})!

The version of system.EnterpriseServices.dll is 1.1.4322.2032 88.0 KB
(90'112 bytes). And old version of system.EnterpriseServices.dll was
1.0.3705.6018 84.0 KB (86'016 bytes).

Can somebody help?

VB.NET Code from Joe Kaplan \(MVP - ADSI ) 8 Jan. In 2004 uses 22:59
################################################## ##########
Protected Shared Function GetAllAttributeValues(ByVal entry As
DirectoryEntry, ByVal attributeName As String) As ArrayList

Dim propValues As PropertyValueCollection
Dim propValue As Object
Dim attributeValues As PropertyValueCollection
Dim values As ArrayList
Dim currentRange As String
Dim startCount As Integer
Dim endCount As Integer
Dim iteration As Integer
Dim increment As Integer = 500 '1000
Dim expectedErrorCode As Integer = -2147016672
'This optimization reads the attributey directly if it
'contains less than 1000 values and returns an arraylist based
'on that. If we have 1000 values, we assume that there are likely
more than
'1000 values and we resort to the slower attribute ranging method()
'done below
entry.RefreshCache(New String() {attributeName})
attributeValues = entry.Properties(attributeName)
If attributeValues.Count < 1000 Then
Dim memberValue As Object
values = New ArrayList(attributeValues.Count)
For Each memberValue In attributeValues
values.Add(memberValue)
Next
values.TrimToSize()
Return values
End If
'here we go into ranging mode
values = New ArrayList(1000)
Do
startCount = iteration * increment
endCount = (iteration + 1) * increment - 1
'This is the attribute ranging method for retrieving the
contents of large attributes
currentRange = String.Format("{0};Range={1}-{2}", attributeName,
startCount, endCount)
currentRange = String.Format("member;range={0}-{1}", startCount,
endCount)
'this will throw when the lower bound on the range is too high()
Try
entry.RefreshCache(New String() {currentRange})
Catch e As Exception 'I might check for the expected hresult,
but I don't know if I need to
Exit Do
End Try
'Get the values for for the current range of attributes
propValues = entry.Properties(attributeName)
For Each propValue In propValues
values.Add(propValue)
Next
iteration += 1
values.Capacity += increment
Loop
values.TrimToSize()
Return values
End Function
################################################## ##########

Thanks and Best regards

Aug 25 '05 #1
0 1900

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

47 posts views Thread by Mountain Bikn' Guy | last post: by
9 posts views Thread by Patrick | last post: by
reply views Thread by rias | last post: by
3 posts views Thread by Sambo | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.