How to get workgroup of the computer?

hello

i want to get workgroup of the computer without using unmanaged code

i try this

System.Environment.UserDomainName

but its giving me the COMPUTER NAME not the workgroup ... is there any way to find out using System.NET or WMI

 

thanx any way ..

 



Answer this question

How to get workgroup of the computer?

  • ScottRogersGBR

    I do not beleive there is a way to get this information using System.Net.

  • Kevin Rodgers

    You are sure you are not joined to a domain

  • ddani

    Both examples don't want to work in my application. Result is null.Maybe there is another way to get workgroup
  • ewjonker

    If that doesn't work, you should be able to use the WMI tools in the System.Management namespace (located in system.management.dll).

    sample code.


    SelectQuery query = new SelectQuery("Win32_ComputerSystem");
    ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

    foreach (ManagementObject mo in searcher.Get())
    {
         workGroupName = mo[
    "Workgroup"] as string;
    }


     



  • Shadamus

    Try this, or something like it:

    My.Computer.Registry.LocalMachine.OpenSubKey("System\CurrentControlSet\Services\Tcpip\Parameters\", False).GetValue("Domain")


  • How to get workgroup of the computer?