How get domain of machine in lan

  • Thread starter Alhambra Eidos Desarrollo
  • Start date
A

Alhambra Eidos Desarrollo

Hi all,

How get domain or workgroup of machine in lan ??

1. If machine has workgroup and in the network no domain controller, I get
workgroup value

2. If machine has user-domain and in the network has domain controller, I
get domain value

Thanks in advance, kind regards
 
K

Kerem Gümrükcü

Hi,

what about looking at google first,...?

e.g. this could help:

Environment.UserDomainName

read this:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName

or do MI Query:

SelectQuery query = new SelectQuery("Win32_ComputerSystem");
using(ManagementObjectSearcher searcher = new
ManagementObjectSearcher(query))
{
foreach (ManagementObject mo in searcher.Get()) {
if((bool)mo["partofdomain"] != true)
Console.WriteLine("Workgroup: {0} ",mo["workgroup"]);
else
Console.WriteLine("Domain: {0} ",mo["domain"]);
}
}


There are numerous ways to do this,...

http://www.google.de/search?num=30&hl=de&newwindow=1&safe=off&q=get+domain+name+C#&meta=

Here is original article:
http://bytes.com/groups/net-c/490964-how-get-domain-name
http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=61951
http://www.c-sharpcorner.com/UploadFile/aaghany/SystemInfo12032005002119AM/SystemInfo.aspx

I just copy code here for the case the article is no longer
available in future,...

And please shorten your signature, its really too long!

Regards

Kerem
 
K

Kerem Gümrükcü

You are right, i see,...my apologizes!

--
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Mark Rae said:
[top-posting corrected]
And please shorten your signature, its really too long!

Nearly as long as yours, in fact...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top