def getDomainName(): ''' Will return the domain name if we belong a domain, else None (if part of a network group, will also return None) ''' # Status: # 0 = Unknown # 1 = Unjoined # 2 = Workgroup # 3 = Domain domain, status = win32net.NetGetJoinInformation() if status != 3: domain = None return domain
def get_join_info(): ''' Gets information about the domain/workgroup. This will tell you if the system is joined to a domain or a workgroup .. version-added:: 2018.3.4 Returns: dict: A dictionary containing the domain/workgroup and it's status ''' info = win32net.NetGetJoinInformation() status = {win32netcon.NetSetupUnknown: 'Unknown', win32netcon.NetSetupUnjoined: 'Unjoined', win32netcon.NetSetupWorkgroupName: 'Workgroup', win32netcon.NetSetupDomainName: 'Domain'} return {'Domain': info[0], 'DomainType': status[info[1]]}
def get_join_info(): """ Gets information about the domain/workgroup. This will tell you if the system is joined to a domain or a workgroup .. versionadded:: 2018.3.4 Returns: dict: A dictionary containing the domain/workgroup and its status """ info = win32net.NetGetJoinInformation() status = { win32netcon.NetSetupUnknown: "Unknown", win32netcon.NetSetupUnjoined: "Unjoined", win32netcon.NetSetupWorkgroupName: "Workgroup", win32netcon.NetSetupDomainName: "Domain", } return {"Domain": info[0], "DomainType": status[info[1]]}