diff --git a/pupy/packages/windows/all/pupwinutils/getdomain.py b/pupy/packages/windows/all/pupwinutils/getdomain.py new file mode 100644 index 00000000..bbfedfb1 --- /dev/null +++ b/pupy/packages/windows/all/pupwinutils/getdomain.py @@ -0,0 +1,14 @@ +from _winreg import * + +def get_domain_controller(): + + aReg = ConnectRegistry(None, HKEY_LOCAL_MACHINE) + keypath = r"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History\\" + subkey_name = 'DCName' + try: + aKey = OpenKey(aReg, keypath) + val, _ = QueryValueEx(aKey, subkey_name) + CloseKey(aKey) + return val + except: + return False