473,387 Members | 1,504 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,387 software developers and data experts.

Reading a list of users from XP

I am using VS 2005 (VB.NET) and I would like to get a list of all users who
have accounts on the server. How can I do this and populate a listbox with
the information?

Thanks in advance
Oct 2 '06 #1
10 1671
isn't that juse a WMI / WBEM query?

-Aaron
sam smith wrote:
I am using VS 2005 (VB.NET) and I would like to get a list of all users who
have accounts on the server. How can I do this and populate a listbox with
the information?

Thanks in advance
Oct 2 '06 #2
BK
Are you using Active Directory?

Oct 2 '06 #3
I have done this, at work, using fairly simple code. It works on Server
2003 and XP.
Unfortunately, the source code is at work and I can't remember how I did
it!!
However, I do remember that it used an Active Directory type function - even
though we don't use AD at all at work.

If no-one's replied in the next 24 hours, I'll give you my code!!
__________________________
The Reaper

"sam smith" <sa*@yada.comwrote in message
news:ez**************@TK2MSFTNGP03.phx.gbl...
>I am using VS 2005 (VB.NET) and I would like to get a list of all users who
have accounts on the server. How can I do this and populate a listbox with
the information?

Thanks in advance

Oct 2 '06 #4
Yes, I believe we are using Active Directory. We have a Windows 2003
server.

"BK" <bk******@hotmail.comwrote in message
news:11*********************@m7g2000cwm.googlegrou ps.com...
Are you using Active Directory?

Oct 3 '06 #5
BK
This is crude, but it should get you started. This code will give you
all the users in AD:

Console.WriteLine("** Listing Start")

Dim oDirectoryEntry As DirectoryServices.DirectoryEntry = New
DirectoryEntry("LDAP://SomeDomainHere")
Dim oDirectorySearcher As DirectorySearcher = New
DirectorySearcher(oDirectoryEntry)

oDirectorySearcher.Filter = ("(ObjectClass=User)")
Dim oResult As SearchResult = oDirectorySearcher.FindOne
For Each oResult In oDirectorySearcher.FindAll
Console.WriteLine(oResult.GetDirectoryEntry().Name )
Next

Console.WriteLine("Listing End **")

Oct 3 '06 #6
I copied the code into my project but my DirectoryServices are not defined.
How can I do that? Do I need to import a namespace? If so, which one? I
ran through Imports system. and couldn't find DirectoryServices.

Any help would be appreciated.
"BK" <bk******@hotmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
This is crude, but it should get you started. This code will give you
all the users in AD:

Console.WriteLine("** Listing Start")

Dim oDirectoryEntry As DirectoryServices.DirectoryEntry = New
DirectoryEntry("LDAP://SomeDomainHere")
Dim oDirectorySearcher As DirectorySearcher = New
DirectorySearcher(oDirectoryEntry)

oDirectorySearcher.Filter = ("(ObjectClass=User)")
Dim oResult As SearchResult = oDirectorySearcher.FindOne
For Each oResult In oDirectorySearcher.FindAll
Console.WriteLine(oResult.GetDirectoryEntry().Name )
Next

Console.WriteLine("Listing End **")

Oct 3 '06 #7
BK
I copied the code into my project but my DirectoryServices are not defined.
How can I do that? Do I need to import a namespace? If so, which one? I
ran through Imports system. and couldn't find DirectoryServices.
Yep...

Imports System.DirectoryServices

Oct 4 '06 #8
There is no System.DirectoryServices when I look at intellisense. Is there
something else to import first?

VS 2005 VB.NET
"BK" <bk******@hotmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>I copied the code into my project but my DirectoryServices are not
defined.
How can I do that? Do I need to import a namespace? If so, which one?
I
ran through Imports system. and couldn't find DirectoryServices.

Yep...

Imports System.DirectoryServices

Oct 4 '06 #9
Add a reference to System.DirectoryServices in the My Project thingammybob.
It's not referenced by default.
__________________________
The Reaper

"Sam Smith" <sa*@yada.comwrote in message
news:u6**************@TK2MSFTNGP06.phx.gbl...
There is no System.DirectoryServices when I look at intellisense. Is
there something else to import first?

VS 2005 VB.NET
"BK" <bk******@hotmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>>I copied the code into my project but my DirectoryServices are not
defined.
How can I do that? Do I need to import a namespace? If so, which one?
I
ran through Imports system. and couldn't find DirectoryServices.

Yep...

Imports System.DirectoryServices


Oct 4 '06 #10
I added the reference to DirectoryServices into my project and it now works.
Thanks for the tip.
"The Grim Reaper" <gr*********@REMOVEbtopenworld.comwrote in message
news:tK********************@bt.com...
Add a reference to System.DirectoryServices in the My Project
thingammybob.
It's not referenced by default.
__________________________
The Reaper

"Sam Smith" <sa*@yada.comwrote in message
news:u6**************@TK2MSFTNGP06.phx.gbl...
>There is no System.DirectoryServices when I look at intellisense. Is
there something else to import first?

VS 2005 VB.NET
"BK" <bk******@hotmail.comwrote in message
news:11**********************@k70g2000cwa.googleg roups.com...
>>>I copied the code into my project but my DirectoryServices are not
defined.
How can I do that? Do I need to import a namespace? If so, which one?
I
ran through Imports system. and couldn't find DirectoryServices.

Yep...

Imports System.DirectoryServices



Oct 5 '06 #11

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

Similar topics

3
by: R. de Vos | last post by:
Hi all you experts, I have a 'small' problem In a mdb I have a column called "PLACE" its value type = text rowsourcetype=list with values Rowsource = HOME;SCHOOL;STATION What I would like...
10
by: bobBaker | last post by:
Does anybody know of a good way to get a list of emails from the corporate exchange server from a corporate website?
5
by: kpp9c | last post by:
I have a several list of songs that i pick from, lets, say that there are 10 songs in each list and there are 2 lists. For a time i pick from my songs, but i only play a few of the songs in that...
3
by: darren via AccessMonster.com | last post by:
Hi I'm based in the UK and I've drifted into Access from building a simple db for myself, to then being asked to build a simple db for someone else, to now spending time building increasingly...
2
by: Lysander | last post by:
I have not seen this feature documented before, so I thought I would share it with you, as I will be using it in a later article. For a combo or list box, the source data is normally a...
4
by: Claire | last post by:
Hi, I'm writing an internal mail system module for my project. There may be several thousand 'users' on site, and I need the whole list for filtering, so I decided to load up the users in the main...
27
by: Mark | last post by:
Hi all, I have a scenario where I have a list like this: User Score 1 0 1 1 1 5 2 3 2 1
14
by: shapper | last post by:
Hello, I am creating a list as follows: list<person>users = (from p in database.Users); I get an error on list saying: "a get or set accessor expected" What am I doing wrong? Thanks,
1
by: Erick Perez - Quadrian Enterprises, S.A. | last post by:
Hi, I have a MS Windows AD domain, and have one OU with more tan 1000 users objects. When I try to read it, I hit the 1000 limit of AD while returning objects, so I'm asking for advice as to how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.