473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Using Active Directory

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
Nov 20 '05 #1
1 3112
Nak
> 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"


Hi there,

As a matter of interest how comes you are not using Try blocks? You are
looking for errors by examining an error number, which seems to be a bit VB6
if my memory serves me correctly. i.e.

---------

try
cont = GetObject("WinNT://VAIO" & ",computer")
catch ex as exception
'handle error here
end try

...

try
cont.Filter = strFilter
catch ex as exception
'handle error here
end try

---------

I'm not to sure about your loop error though as I can't really test it
with my current setup. But maybe this information will be usefull none the
less. But small questions, what type is

* user.Name

Is this a string ? And what is selectUser? is that a collection,
arraylist, listview? Is the error actually occuring when it tries to add to
selectUser or when it initiates the loop?

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Slow internet connection?
Having problems with you job?
You're marriage is on the rocks?
You can't sleep at night?
You have a drink and drugs addiction?
You are sexually impotent?
Then enable Option Strict!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Henning Kristensen | last post by:
Hi I need a little help with some VB.Net code.. I am pulling my computer's GUID out using WMI Dim wmiObj As New System.Management.ManagementObjectSearcher("SELECT UUID FROM...
4
by: ASGMikeG | last post by:
Hi, How do I find the user object for the current user in Active Directory i.e. the user running my program ? Regards Michael
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
1
by: Sriram Venkataramani | last post by:
In our application we have to authenticate users using Forms authentication, but using the username and password of the Windows 2000 Active Directories. That is, the user will enter his username...
6
by: Leo_Surf | last post by:
Hello, I need your help adding user in Active Directory from ASP.net website. Could any one provide me the complete code for the html page. As this is my curriculam project and I dont have any...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
4
by: Patirck Ige | last post by:
Would it be easier to have an intranetsystem built based on some security gruopson Active directory or having to use a Database to have a validation store and Roles. Which way would be the best to...
3
by: Jay-nospam | last post by:
Hi there, I am having trouble getting an ASP.NET web application to connect to another computer and passing the proper credentials and I hope someone can help me. I have a stand-alone Windows...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.