tags:

views:

45

answers:

1

Hello, maybe I will not correct explain a problem, maybe somebody help me explain this problem. So, I have next task: create instance of URI with name of PC, like this:

baseAddress = new Uri(string.Format("http://{0}:{1}", Dns.GetHostName() ,port ));

But if PC in domain I need to use extended PC name like this: pcname.company.com

For this case I used next code

baseAddress = new Uri(string.Format("http://{0}:{1}", Dns.GetHostName() + "." + Environment.UserDomainName ,port ));

And here I found problem :(

Name of domain can be company.com but can be company_system. I use this syntax for different cases for example : If I wont to login on my PC I can write [email protected] and I can write company_system\myname.

And question:

How to find domain name in format like this company.com because by default Environment.UserDomainName returns domain name like company_system?

Thank you!

Regards,

Jitm

A: 

Hi, I found solution

System.Net.Dns.GetHostEntry(Dns.GetHostName()).HostName

GetHostEntry returns name of PC with domain and domain in correct format like this:

pcname.company.com

jitm