473,466 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

User listing in a domain (VB.NET 2005 - Windows XP)

I would like a listing of all users in the current domain (or on my
computer). I'm running Windows XP Home Edition and I've set up four user, one
for each member of my family.

'My.User.Name' just lists me. How do I get the others? I looked at some code
posted here on 4/27/07 and it doesn't work, I've already tried it.

Thanks in advance.

--
Dave B.
Jun 3 '07 #1
3 4916
dmbuso,

Here is some Console code to grab all the users in the Administrators group
and display their name and SID. You can change the group name in the code.

Code:

Imports System.Security.Principal
Imports System.DirectoryServices

Module Module1
Sub Main()
Dim localMachine As New DirectoryEntry("WinNT://" &
Environment.MachineName)
Dim admGroup As DirectoryEntry =
localMachine.Children.Find("administrators", "group")
Dim members As Object = admGroup.Invoke("members", Nothing)
For Each groupMember As Object In CType(members, IEnumerable)
Dim member As New DirectoryEntry(groupMember)
Console.WriteLine(member.Name)

Dim si As New
SecurityIdentifier(CType(member.Properties("object Sid")(0), Byte()), 0)
Dim sid As String = si.Value
Console.WriteLine(sid)
Next

Console.ReadLine()
End Sub
End Module

Hope this helps,
Steve

"dmbuso" <dm*****@community.nospamwrote in message
news:14**********************************@microsof t.com...
>I would like a listing of all users in the current domain (or on my
computer). I'm running Windows XP Home Edition and I've set up four user,
one
for each member of my family.

'My.User.Name' just lists me. How do I get the others? I looked at some
code
posted here on 4/27/07 and it doesn't work, I've already tried it.

Thanks in advance.

--
Dave B.

Jun 4 '07 #2
Steve,

I wanted all user, not administrators. I will try your code and see if I can
modify it for all users.
--
Dave B.
"PlatinumBay" wrote:
dmbuso,

Here is some Console code to grab all the users in the Administrators group
and display their name and SID. You can change the group name in the code.

Code:

Imports System.Security.Principal
Imports System.DirectoryServices

Module Module1
Sub Main()
Dim localMachine As New DirectoryEntry("WinNT://" &
Environment.MachineName)
Dim admGroup As DirectoryEntry =
localMachine.Children.Find("administrators", "group")
Dim members As Object = admGroup.Invoke("members", Nothing)
For Each groupMember As Object In CType(members, IEnumerable)
Dim member As New DirectoryEntry(groupMember)
Console.WriteLine(member.Name)

Dim si As New
SecurityIdentifier(CType(member.Properties("object Sid")(0), Byte()), 0)
Dim sid As String = si.Value
Console.WriteLine(sid)
Next

Console.ReadLine()
End Sub
End Module

Hope this helps,
Steve

"dmbuso" <dm*****@community.nospamwrote in message
news:14**********************************@microsof t.com...
I would like a listing of all users in the current domain (or on my
computer). I'm running Windows XP Home Edition and I've set up four user,
one
for each member of my family.

'My.User.Name' just lists me. How do I get the others? I looked at some
code
posted here on 4/27/07 and it doesn't work, I've already tried it.

Thanks in advance.

--
Dave B.


Jun 4 '07 #3
Hi Dave,

In that case, I think you can simply replace 'administrators' with 'users':

Dim admGroup As DirectoryEntry = localMachine.Children.Find("users",
"group")
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '07 #4

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

Similar topics

3
by: Jason | last post by:
I need to get a listing of users from Active Directory. Getting the list is no problem using the DirectorySearcher class. My problem is getting the full legacy-style domain name of the user (in the...
0
by: Norbert Heidbüchel | last post by:
Hi all, I have read a lot of postings and web pages about drag and drop and treeviews, but could not find an answer to my problem. Sorry, if I missed something. I am trying to drag and drop...
8
by: Razak | last post by:
Hi, I have a class which basically do Impersonation in my web application. From MS KB sample:- ++++++++++++++++++++code starts Dim impersonationContext As...
8
by: Oliver Rainer | last post by:
Hi, I have the following problem... Pre-requisites: Installation of an Asp.net webservice on a IIS5 server (win2k). Anonymous access is not allowed, only using windows authentication (intranet...
5
by: Dany C. | last post by:
We have install a valid SSL certificate issued to www.mycompany.com on our web server running IIS 6.0 / win2003 SP1. Then we have created a sub domain pointing to the same server for our web...
3
by: Doug | last post by:
Using Visual Studio 2005, SQL Server 2000, and ASP.NET/VB.NET for a Web Application. We have a System DSN using Windows NT authentication defined on the development box to connect to the SQL...
0
by: godsmustbcrazy | last post by:
Here is my problem. Brand new SQL Server 2005 Installation 1. Create a database "Test" 2. Create a database user "Domain\user" and set user mapping to "Test" with datareader, datawriter...
1
by: Ben Hanson | last post by:
I've scoured Google searching for an answer that seems like it should be easy but apparently isn't...when I open SSMS to connect to a SQL 2005 database and choose Windows authentication, it greys...
4
by: eruth | last post by:
There are loads of post on this, but nothing that seems to cover my exact problem ;) I have an ASP.Net 1.1 web application running on my local machine. I want to connect to an SQL 2005 server...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.