Is there a .NET equivalent to the winsock function GetNameInfoW()
with the NI_NOFQDN
flag set? As the MSDN docs for GetNameInfoW
explain:
Setting the NI_NOFQDN flag results in local hosts having only their Relative Distinguished Name (RDN) returned in the pNodeBuffer parameter.
The closest thing I can find is System.Net.Dns.GetHostEntry()
, which returns an IPHostEntry
but whose HostName
is the fully-qualified domain name of the host. I just want the unqualified host name.
For example, if IP address "x.x.x.x" resolves to the FQDN "foohost.company.domain.com", I can get "foohost" from GetNameInfoW()
by supplying NI_NOFQDN
, but there doesn't seem to be an equivalent in .NET. I'm not sure if GetNameInfoW()
is doing NetBIOS or LDAP or something else under the covers. Any thoughts on how to do the same in .NET?