How do you get the current Domain name without '.com'

  • Thread starter Thread starter Billy
  • Start date Start date
B

Billy

My domain is all Windows 2003 with AD and I can get the domain name of
'domain.com' using 'system.management' but I need the domain name
without the .com and I do not want to rip strings to achieve it. Can
anyone tell me how to get the current domain name without the .com at
the end?

Regards

Billy

P.S. The reason I need it like this is because when you perform the
call IPrincipal.IsInRole (ASP.NET C#) you have to supply the group name
in the format of '<domain\group>' and the domain should not have .com
on it!
 
Hi Billy

You can try using the environment variable called "USERDOMAIN", this may be
what you are looking for

Environment.GetEnvironmentVariable("USERDOMAIN")
hope this helps

henk
 
Billy said:
My domain is all Windows 2003 with AD and I can get the domain name of
'domain.com' using 'system.management' but I need the domain name
without the .com and I do not want to rip strings to achieve it. Can
anyone tell me how to get the current domain name without the .com at
the end?

Regards

Billy

P.S. The reason I need it like this is because when you perform the
call IPrincipal.IsInRole (ASP.NET C#) you have to supply the group name
in the format of '<domain\group>' and the domain should not have .com
on it!

use: myPrincipal.IsInRole("(e-mail address removed)") when running in a w2K or
higher domain realm.

Willy.
 
Henk - I think that only gets the machine name.

Willy - I will try that, thanks.

Regards

Billy
 
Willy - I have tried this '(e-mail address removed)' and it fails to work ...
only the old way of 'GROUP\DOMAIN' works :-(

Isn't there a way of getting the domain name (without the .com) by
using the system.management objects and if so do you have any code?

Regards

Billy
 
Back
Top