finding workgroup name

  • Thread starter Thread starter Ewart MacLucas
  • Start date Start date
E

Ewart MacLucas

Does anybody know how to find the workgroup name (or domainname) of the
local PC. Is there a framework class for it?

(preferably a solution not involving active directory calls)

Thanks,
Ewart.
 
Ewart,

To find the domain name --
MessageBox.Show(Environment.UserDomainName.ToString)
To find the machine name --
MessageBox.Show(Environment.MachineName.ToString)

Let me know if this works.

Cheers,
Gary
 
Thanks Gary but unfortunately both functions just return the computer name
of the current machine, not the domain to which I'am attached. Any other
ideas? (ps, preferably not a WMI solution either! :-))

Regards,
Ewart.
 
Gary said:
To find the domain name --
MessageBox.Show(Environment.UserDomainName.ToString)
To find the machine name --
MessageBox.Show(Environment.MachineName.ToString)

Both properties are string's, hence ToString() ist not necessary.

Best regards,

Michael
 
Michael,
This works for me
\\\\
Dim environmentVariables As IDictionary =
Environment.GetEnvironmentVariables()
Dim de As DictionaryEntry
For Each de In environmentVariables
If de.Key.ToString = "USERDOMAIN" Then
MessageBox.Show(de.Value.ToString)
Next de
////
I hope for you too?
Cor
 
Gary,
This works for me
\\\\
Dim environmentVariables As IDictionary =
Environment.GetEnvironmentVariables()
Dim de As DictionaryEntry
For Each de In environmentVariables
If de.Key.ToString = "USERDOMAIN" Then
MessageBox.Show(de.Value.ToString)
Next de
////
I hope for you too?
Cor
 
Ewart,

This line of code works certainly works for me :
MessageBox.Show(Environment.UserDomainName)

Are you sure you are trying to get the Domain name ?

- Gary
 
Back
Top