<p>Is there a way in .net 2.0 to discover the network alias for the machine that my code is running on? Specifically, if my workgroup sees my machine as //jekkedev01, how do I retrieve that name programmatically?</p>

[{'answer_id': 59738, 'author': 'Dale Ragan', 'author_id': 1117, 'author_profile': 'https://Stackoverflow.com/users/1117', 'pm_score': 0, 'selected': False, 'text': '<p>Use the <a href="http://msdn.microsoft.com/en-us/library/system.environment.aspx" rel="nofollow noreferrer">System.Environment</a> class.  It has a property for retrieving the machine name, which is retrieved from the NetBios.  Unless I am misunderstanding your question.</p>\n'}, {'answer_id': 59781, 'author': 'chrissie1', 'author_id': 2936, 'author_profile': 'https://Stackoverflow.com/users/2936', 'pm_score': 0, 'selected': False, 'text': '<p>or My.Computer.Name</p>\n'}, {'answer_id': 229049, 'author': 'alexandrul', 'author_id': 19756, 'author_profile': 'https://Stackoverflow.com/users/19756', 'pm_score': 1, 'selected': False, 'text': '<p>If you need the computer description, it is stored in registry:</p>\n\n<ul>\n<li>key: <code>HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\lanmanserver\\parameters</code></li>\n<li>value name: <code>srvcomment</code></li>\n<li>data type: <code>REG_SZ (string)</code></li>\n</ul>\n\n<p>AFAIK it has nothing to do with any domain server, or with the network the PC is attached to.</p>\n\n<p>For anything related to the network, I am using the following:</p>\n\n<ul>\n<li>NETBIOS name: <code>System.Environment.MachineName</code></li>\n<li>host name: <code>System.Net.Dns.GetHostName()</code></li>\n<li>DNS name: <code>System.Net.Dns.GetHostEntry("LocalHost").HostName</code></li>\n</ul>\n\n<p>If the PC has multiple NETBIOS names, I do not know any other method but to group the names based on the IP address they resolve to, and even this is not reliable if the PC has multiple network interfaces.</p>\n'}, {'answer_id': 231431, 'author': 'Murali Suriar', 'author_id': 6306, 'author_profile': 'https://Stackoverflow.com/users/6306', 'pm_score': 1, 'selected': False, 'text': '<p>I\'m not a .NET programmer, but the <a href="http://msdn.microsoft.com/en-us/library/system.net.dns.gethostentry.aspx" rel="nofollow noreferrer">System.Net.DNS.GetHostEntry</a> method looks like what you need. It returns an instance of the <a href="http://msdn.microsoft.com/en-us/library/system.net.iphostentry_members.aspx" rel="nofollow noreferrer">IPHostEntry</a> class which contains the <a href="http://msdn.microsoft.com/en-us/library/system.net.iphostentry.aliases.aspx" rel="nofollow noreferrer">Aliases</a> property.</p>\n'}, {'answer_id': 239489, 'author': 'msulis', 'author_id': 9317, 'author_profile': 'https://Stackoverflow.com/users/9317', 'pm_score': 3, 'selected': True, 'text': '<p>Since you can have multiple network interfaces, each of which can have multiple IPs, and any single IP can have multiple names that can resolve to it, there may be more than one.</p>\n\n<p>If you want to know all the names by which your DNS server knows your machine, you can loop through them all like this:</p>\n\n<pre><code>public ArrayList GetAllDnsNames() {\n  ArrayList names = new ArrayList();\n  IPHostEntry host;\n  //check each Network Interface\n  foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) {\n    //check each IP address claimed by this Network Interface\n    foreach (UnicastIPAddressInformation i in nic.GetIPProperties().UnicastAddresses) {\n      //get the DNS host entry for this IP address\n      host = System.Net.Dns.GetHostEntry(i.Address.ToString());\n      if (!names.Contains(host.HostName)) {\n        names.Add(host.HostName);\n      }\n      //check each alias, adding each to the list\n      foreach (string s in host.Aliases) {\n        if (!names.Contains(s)) {\n          names.Add(s);\n        }\n      }\n    }\n  }\n  //add "simple" host name - above loop returns fully qualified domain names (FQDNs)\n  //but this method returns just the machine name without domain information\n  names.Add(System.Net.Dns.GetHostName());\n\n  return names;\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/59726', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5287/']