6

In short - How do I translate a NETBIOS domain to a FQDN ?

Details: Assuming I'm in domain A and I have user credentials for domain B which has a trust relationship with domain A (I can authenticate the credentials). How do I get domain B's FQDN when all I have are the credentials of some authenticated user from that domain, including the netbios domain name?

I'm coding in C# but a COM/WMI/Win32 solution would be welcomed as well.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
LiorE
  • 111
  • 4
  • 9

4 Answers4

4

This probably isn't optimal, but it look like you could do a NetBIOS name query to get an IP address, and then do a reverse DNS lookup to get an FQDN from that...

http://www.protocolbase.net/protocols/protocol_NBNS.php

(The reverse DNS step is easy to look up)

Mike G.
  • 1,670
  • 11
  • 17
  • WINS is the exact same thing as DNS but for NetBIOS names instead of domain names. So, you have to translate from one name scheme to the other. The only info they share is IP, so this is the only good process that I know of too. – Jon Adams Jan 28 '09 at 02:15
1

What kind of access do you have to the other domain? What server/service in the other domain are you authenticating against?

Do you have ip-access to a domain server in the other domain? If so then you could do a call like this:

DirectoryEntry rootDSE = new DirectoryEntry("LDAP://10.11.12.13/rootDSE", @"DOMAIN\Username", "Password");
Console.WriteLine(rootDSE.Properties["defaultNamingContext"].Value);

(Replace 10.11.12.13 with the domain server address).

You will get a reply in form "DC=company,DC=org" that represents the FQDN (just rebuild it by removing the DC-part and insert dots)

Per
  • 559
  • 5
  • 11
0

Bind to the domain using the WinNT provider and filter for all user accounts. Start enumerating the user accounts.

If the user account sAMAccount name does not contain the string "duplicate" then exit from the loop and use the NameTranslate object to look up the LDAP name of the account.

Part of the LDAP name is the domain FQDN.

Hey, it's a fudge but it works like a charm.

0

The vanara collection of win32 libraries can be used for that. The translation from NetBIOS domain names to dns domain names is provided (as a side effect) by the DsGetDcName API in the NetApi32.dll.

Go in VS to the nuget package manager and get the Vanara.PInvoke.NetApi32 package.

This two methods convert NetBIOS name to dns name and vice versa.

public static string ResolveNetBIOSDomainNameToDnsName(string netBIOSName)
{
    Vanara.PInvoke.NetApi32.DOMAIN_CONTROLLER_INFO domainDcInfo = 
            Vanara.PInvoke.NetApi32.DsGetDcName(Vanara.PInvoke.NetApi32.DsGetDcNameFlags.DS_RETURN_DNS_NAME | Vanara.PInvoke.NetApi32.DsGetDcNameFlags.DS_IS_FLAT_NAME, null, netBIOSName);
    return domainDcInfo.DomainName;
}

public static string ResolveDNSDomainNameToNetBIOSName(string dnsName)
{
    Vanara.PInvoke.NetApi32.DOMAIN_CONTROLLER_INFO domainDcInfo = 
            Vanara.PInvoke.NetApi32.DsGetDcName(Vanara.PInvoke.NetApi32.DsGetDcNameFlags.DS_RETURN_FLAT_NAME | Vanara.PInvoke.NetApi32.DsGetDcNameFlags.DS_IS_DNS_NAME, null, dnsName);
    return domainDcInfo.DomainName;
}
marsh-wiggle
  • 2,508
  • 3
  • 35
  • 52