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

Get Domain/Workgroup name of PC Registration

How do I get the name of the Workgroup or Domain that the computer has
been registered in.

Thank you
Mark Hollander

Thank you
Mark Hollander
Nov 20 '05 #1
11 5568
On Wed, 14 Jul 2004 16:44:12 +0200, Mark Hollander <ma**@atcom.co.za> wrote:

¤ How do I get the name of the Workgroup or Domain that the computer has
¤ been registered in.
¤

The following uses ADSI:

Dim SystemInfo As Object

SystemInfo = CreateObject("ADSystemInfo")
Console.WriteLine(SystemInfo.DomainShortName)
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #2
You can use WMI as well...

Dim computer as New WMISample.ROOT.CIMV2.ComputerSystem

computer.path =
System.Management.ManagementPath("MyComp\root\CIMV 2:Win32_ComputerSystem.Nam
e=""MyComp""")

Messagebox.Show(computer.Domain) //Shows Domain name or Workgroup name)

Telmo Sampaio

"Mark Hollander" <ma**@atcom.co.za> wrote in message
news:si********************************@4ax.com...
How do I get the name of the Workgroup or Domain that the computer has
been registered in.

Thank you
Mark Hollander

Thank you
Mark Hollander

Nov 20 '05 #3
The problem is that I cannot use these 2 examples on a
Windows98/WindowsME machine.

Is there any other way I can get the Workgroup/Domain name

Thank You
Mark Hollander

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4
I can't seem to get the WMI to work in VD.NET, what am i supposed to
include in the references to access the WMI.

Thank You
Mark Hollander

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5
On Thu, 15 Jul 2004 01:10:09 -0700, Mark Hollander <ma**@atcom.co.za> wrote:

¤ The problem is that I cannot use these 2 examples on a
¤ Windows98/WindowsME machine.
¤
¤ Is there any other way I can get the Workgroup/Domain name
¤

How about the following:

Environment.UserDomainName()
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #6
Paul,

Sometimes I am blinded by the simplicity of things... I have to agree that
using the Environment class is a lot easier than dealing with WMI.

Thanks,

Telmo
"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:rp********************************@4ax.com...
On Thu, 15 Jul 2004 01:10:09 -0700, Mark Hollander <ma**@atcom.co.za> wrote:
¤ The problem is that I cannot use these 2 examples on a
¤ Windows98/WindowsME machine.
¤
¤ Is there any other way I can get the Workgroup/Domain name
¤

How about the following:

Environment.UserDomainName()
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 20 '05 #7
Imports System.Management - add a reference to this too.

(VD.NET??? Is that next version of AIDS?? :D)
_____________________________
The Grim Reaper

"Mark Hollander" <ma**@atcom.co.za> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I can't seem to get the WMI to work in VD.NET, what am i supposed to
include in the references to access the WMI.

Thank You
Mark Hollander

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #8
The problem with this function is that it returns the domain name that
the user logged onto.

Scenario

Computer is registered in DomainA
User is registered in DomainB

I want the DomainA name but I get DomainB as the domain name when I use
System.Environment.UserDomainName.

It is important that I get DomainA
Thank You
Mark Hollander

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #9
Did that but I cannot seem to access the following:
Dim computer as New WMISample.ROOT.CIMV2.ComputerSystem

The MSDN is vague on how to access this as I cannot seem to find
anything relating to it.

Thank You
Mark Hollander

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #10
Mark,

It took me a while to get the hang of the WMI stuff - and I still can't get
"complex" queries to work properly. See how you get on with this example;

Dim vQuery As New ManagementObjectSearcher("SELECT * FROM
Win32_ComputerSystem")
For Each vComputer As ManagementObject In vQuery.Get ' In case there's more
than one computer :))
' List all properties of Win32_ComputerSystem
For Each vProperty As PropertyData In vComputer.Properties
Console.WriteLine(vProperty.Name)
Next
' Print a random property
Console.WriteLine("Domain is: " & vComputer("Domain").ToString)
Next
________________________
The Grim Reaper

"Mark Hollander" <ma**@atcom.co.za> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Did that but I cannot seem to access the following:
Dim computer as New WMISample.ROOT.CIMV2.ComputerSystem

The MSDN is vague on how to access this as I cannot seem to find
anything relating to it.

Thank You
Mark Hollander

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #11
On Thu, 15 Jul 2004 23:30:15 -0700, Mark Hollander <ma**@atcom.co.za> wrote:

¤ The problem with this function is that it returns the domain name that
¤ the user logged onto.
¤
¤ Scenario
¤
¤ Computer is registered in DomainA
¤ User is registered in DomainB
¤
¤ I want the DomainA name but I get DomainB as the domain name when I use
¤ System.Environment.UserDomainName.
¤
¤ It is important that I get DomainA

I can't test this in a multiple domain environment but see if the following works for you:

Dim WMIComputerSystem As New System.Management.ManagementObjectSearcher("select * from
Win32_ComputerSystem")

Dim WMIInfo As System.Management.ManagementObject

For Each WMIInfo In WMIComputerSystem.Get
Console.WriteLine(WMIInfo("Domain").ToString)
Next WMIInfo
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #12

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

Similar topics

1
by: Manoj | last post by:
Hi, How can we get info as to if a terminal is on a workgroup or a domain and the name of the domain\workgroup in windows 2000 professional through code thanks in advance Manoj
2
by: Jordan | last post by:
Suppose I register a domain name, MyDomain.com, through register.com (or any other of the many domain name registrars). I own the domain name. The domain name goes into the global DNS database. ...
1
by: Bilge TUTAK | last post by:
Hi, I want to find the list of the computer names in a workgroup or in a domain. Is there a way to do this in VB.NET? Thanx
2
by: Richard L Rosenheim | last post by:
On my development machine, it works -- SystemInformation.UserDomainName and System.Environment.UserDomainName both returns the domain name. But, on my test machine, these methods are returning the...
6
by: Spyder | last post by:
When you go to "MyComputer" and get properties and select "Computer Name", you get the Domain or Workgroup a computer belongs to. I have looked thru MSDN library, the Internet, the Registry and in...
6
by: MLH | last post by:
I'm tired of reading the fine print! Too many registrars out there. So I'm asking this group for a little help. I'm looking for a Registrar who will do an honest day's work for a fair price. I'm...
8
by: None | last post by:
Hi, If anybody knows how to get the domain name(only domain name) of the system pls let me know. Thanks and Regards, Vinothkumar B bvinoth@tvsinfotech.com
9
by: =?Utf-8?B?RGVubmlz?= | last post by:
I am trying to get all the user info in my home network domain using WMI but the below code returns nothing. I know the domain name I pass is correct, i.e., "mshome". I cut and pasted this code...
0
by: conniezhang | last post by:
Dear Valued Businessman/BusinessLady, Todaynic.com is one of the first ICANN Accredited Registrars and CNNIC Accredited Domestic Registrars in China. Great amount of domain extensions with low...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.