Does anyone know how to get a list of DNS search suffixes on a client - both ones that have been manually added and ones assigned by DHCP. I'd prefer to have a cross-platform solution, but a Windows only solution will work. I couldn't find anything in pywin32 or other modules...
After a bit of investigation, it doesn't look like there is a cross-platform way since the OS stores this information differently. On Windows, I ended up querying the information via the registry:
def getLocalDomainSuffix():
domainSuffixSet = set()
netKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters')
for keyName in ("DhcpDomain", "SearchList"):
value, type = _winreg.QueryValueEx(netKey, keyName)
if value:
for item in value.split(','):
domainSuffixSet.add(item)
return domainSuffixSet