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 myname@company.com 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
System.Net.Dns.GetHostEntry(Dns.GetHostName()).HostName
GetHostEntry returns name of PC with domain and domain in correct format like this:
pcname.company.com
精彩评论