I know this is old. I just wanted to dump this here for anyone that was looking for an answer to getting a domain name. This is in coordination with Peter's answer. There "is" a bug as stated by Rich. But, you can always make a simple workaround for that. The way I can tell if they are still on the domain or not is by pinging the domain name. If it responds, continue on with whatever it was that I needed the domain for. If it fails, I drop out and go into "offline" mode. Simple string method.
string GetDomainName()
{
string _domain = IPGlobalProperties.GetIPGlobalProperties().DomainName;
Ping ping = new Ping();
try
{
PingReply reply = ping.Send(_domain);
if (reply.Status == IPStatus.Success)
{
return _domain;
}
else
{
return reply.Status.ToString();
}
}
catch (PingException pExp)
{
if (pExp.InnerException.ToString() == "No such host is known")
{
return "Network not detected!";
}
return "Ping Exception";
}
}