473,654 Members | 3,074 Online
Bytes | Software Development & Data Engineering Community
+ 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 4925
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.Director yServices

Module Module1
Sub Main()
Dim localMachine As New DirectoryEntry( "WinNT://" &
Environment.Mac hineName)
Dim admGroup As DirectoryEntry =
localMachine.Ch ildren.Find("ad ministrators", "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.WriteLi ne(member.Name)

Dim si As New
SecurityIdentif ier(CType(membe r.Properties("o bjectSid")(0), Byte()), 0)
Dim sid As String = si.Value
Console.WriteLi ne(sid)
Next

Console.ReadLin e()
End Sub
End Module

Hope this helps,
Steve

"dmbuso" <dm*****@commun ity.nospamwrote in message
news:14******** *************** ***********@mic rosoft.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.
"PlatinumBa y" 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.Director yServices

Module Module1
Sub Main()
Dim localMachine As New DirectoryEntry( "WinNT://" &
Environment.Mac hineName)
Dim admGroup As DirectoryEntry =
localMachine.Ch ildren.Find("ad ministrators", "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.WriteLi ne(member.Name)

Dim si As New
SecurityIdentif ier(CType(membe r.Properties("o bjectSid")(0), Byte()), 0)
Dim sid As String = si.Value
Console.WriteLi ne(sid)
Next

Console.ReadLin e()
End Sub
End Module

Hope this helps,
Steve

"dmbuso" <dm*****@commun ity.nospamwrote in message
news:14******** *************** ***********@mic rosoft.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.Ch ildren.Find("us ers",
"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
1835
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 form of domain\username). The "sAMAccountName" property only gives me the username portion. What property gives with the domain? Or do I need to be looking at a different AD object altogether? Thanks, Jason
0
2415
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 treenodes defined by myself and don't understand, how to get the nodes data in the dragdrop event. I'm not very experienced in .NET and for sure there is a simple solution. I've written a short sample program, based on well known examples,
8
9449
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 System.Security.Principal.WindowsImpersonationContext Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
8
13140
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 app), webmethoda are using the Principalpermssion attribute () for identification. Result --> does not work
5
2704
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 services at ws.mycompany.com. We have properly installed the server certificate on the client machine. When the client try to connect to our secure webservice at https:\\ws.mycompany.com we have the foolwing error: System.Net.WebException: The...
3
2320
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 Server (both SQL and IIS are on the 192.168.1.2 server). We have "Identity Impersonate=true", and "CustomErrors mode=On" and "defaultRedirect="ErrorHandler.aspx" in web.config.
0
6689
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 permissions 3. Look at Test ->Properties->Permissions activate "Domain\user" and click effective permissions and I get this error message
1
6895
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 out the User Name box...problem is, the server I need to connect to is in another domain...how on earth are you supposed to specify a different Windows user name to connect with other than the one currently logged into the machine? -Ben
4
12073
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 running on Windows 2003. If I use SQL authentication, all is fine and dandy. If I want to use windows authentication it gives the above error. My SQL server is set to allow both methods (first thing I checked) and is part of the domain (2nd...
0
8376
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8708
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.