P
Patrick McGuire
I am trying to load a combobox with all the existing
users on a computer (there are currently 4 users). I'm
using the following code:
Imports ActiveDirectory
..
..
..
Private Sub Form_Load
Dim cont As IADsContainer
Dim user As IADsUser
Dim strFilter() As String
cont = GetObject("WinNT://VAIO" & ",computer")
If (Err.Number <> 0) Then
HandleErrors(Err.Number, "on GetObject
method")
End If
ReDim strFilter(0)
strFilter(0) = "User"
cont.Filter = strFilter
If (Err.Number <> 0) Then
HandleErrors(Err.Number, "on
IADsContainer::Filter method")
End If
For Each user In cont
selectUser.Items.Add(user.Name)
Next
selectUser.Text = selectUser.Items(0)
end sub
The problem is the ForEach/Next loop. After executing
successfully for each of the four usrs, the loop throws
an invalid cast exception. I can't use a counter because
cont.count throws a "not implemented exception"
How do I work around this?
Thanks for the help
Pat
users on a computer (there are currently 4 users). I'm
using the following code:
Imports ActiveDirectory
..
..
..
Private Sub Form_Load
Dim cont As IADsContainer
Dim user As IADsUser
Dim strFilter() As String
cont = GetObject("WinNT://VAIO" & ",computer")
If (Err.Number <> 0) Then
HandleErrors(Err.Number, "on GetObject
method")
End If
ReDim strFilter(0)
strFilter(0) = "User"
cont.Filter = strFilter
If (Err.Number <> 0) Then
HandleErrors(Err.Number, "on
IADsContainer::Filter method")
End If
For Each user In cont
selectUser.Items.Add(user.Name)
Next
selectUser.Text = selectUser.Items(0)
end sub
The problem is the ForEach/Next loop. After executing
successfully for each of the four usrs, the loop throws
an invalid cast exception. I can't use a counter because
cont.count throws a "not implemented exception"
How do I work around this?
Thanks for the help
Pat