def get_domain_name(): '''Return current domain name''' dns_config = SCDynamicStoreCopyValue(None, 'State:/Network/Global/DNS') try: return dns_config.get('DomainName') except AttributeError: return None
def get_domain_dns(): net_config = SCDynamicStoreCreate(None, 'active-directory', None, None) ad_info = SCDynamicStoreCopyValue(net_config, 'com.apple.opendirectoryd.ActiveDirectory') if ad_info is not None: return ad_info.get('DomainNameDns') else: raise NotBound
def get_machine_name(net_config, nametype): """Return the ComputerName of this Mac.""" sys_info = SCDynamicStoreCopyValue(net_config, "Setup:/System") if sys_info: return sys_info.get(nametype) return subprocess.check_output( ['/usr/sbin/scutil', '--get', 'ComputerName'])
def get_machine_name(net_config, nametype): """Return the ComputerName of this Mac.""" sys_info = SCDynamicStoreCopyValue(net_config, "Setup:/System") if sys_info: return sys_info.get(nametype) return subprocess.check_output( ["/usr/sbin/scutil", "--get", "ComputerName"], text=True).strip()
def get_domain_dns(): net_config = SCDynamicStoreCreate(None, 'active-directory', None, None) ad_info = SCDynamicStoreCopyValue( net_config, 'com.apple.opendirectoryd.ActiveDirectory') if ad_info is not None: return ad_info.get('DomainNameDns') else: raise NotBound
def domain(): if not bound(): raise NotBound net_config = SCDynamicStoreCreate(None, "active-directory", None, None) ad_info = SCDynamicStoreCopyValue(net_config, "com.apple.opendirectoryd.ActiveDirectory") if ad_info: return ad_info.get("DomainNameDns") else: return None
def fact(): """Returns Active Directory forest""" result = "None" net_config = SCDynamicStoreCreate(None, "net", None, None) d = SCDynamicStoreCopyValue(net_config, "com.apple.opendirectoryd.ActiveDirectory") if d: result = d.get("DomainForestName", None) return {factoid: result}
def fact(): '''Returns Active Directory forest''' result = 'None' net_config = SCDynamicStoreCreate(None, 'net', None, None) d = SCDynamicStoreCopyValue(net_config, 'com.apple.opendirectoryd.ActiveDirectory') if d: result = d.get('DomainForestName', None) return {factoid: result}
def fact(): """Returns Active Directory trust account""" result = "None" net_config = SCDynamicStoreCreate(None, "net", None, None) d = SCDynamicStoreCopyValue(net_config, "com.apple.opendirectoryd.ActiveDirectory") if d: result = d.get("TrustAccount", None) return {factoid: result}
def fact(): '''Returns Active Directory trust account''' result = 'None' net_config = SCDynamicStoreCreate(None, 'net', None, None) d = SCDynamicStoreCopyValue(net_config, 'com.apple.opendirectoryd.ActiveDirectory') if d: result = d.get('TrustAccount', None) return {factoid: result}
def fact(): """Returns the current dns domain""" result = "None" net_config = SCDynamicStoreCreate(None, "net", None, None) dns_info = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/DNS") if dns_info: try: result = dns_info.get("DomainName", None) except KeyError: pass return {factoid: str(result)}
def fact(): '''Returns the current dns servers''' proxies = 'None' net_config = SCDynamicStoreCreate(None, "net", None, None) proxy_info = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/Proxies") if proxy_info and proxy_info.get('ProxyAutoConfigURLString'): try: proxies = proxy_info['ProxyAutoConfigURLString'] except KeyError as err: pass return {factoid: proxies}
def fact(): '''Returns the current dns servers''' result = [] net_config = SCDynamicStoreCreate(None, "net", None, None) dns_info = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/DNS") if dns_info and dns_info.get('ServerAddresses'): try: for i in dns_info['ServerAddresses']: result.append(i) except KeyError as err: pass return {factoid: result}
def fact(): """Returns the current dns servers""" proxies = "None" net_config = SCDynamicStoreCreate(None, "net", None, None) proxy_info = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/Proxies") if proxy_info and proxy_info.get("ProxyAutoConfigURLString"): try: proxies = proxy_info["ProxyAutoConfigURLString"] except KeyError: pass return {factoid: proxies}
def fact(): """Returns the current search domains""" search_domains = None net_config = SCDynamicStoreCreate(None, "net", None, None) search_domains = [] dns_info = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/DNS") if dns_info and dns_info.get("SearchDomains"): try: for i in dns_info["SearchDomains"]: search_domains.append(i) except KeyError: pass return {factoid: search_domains}
def get_domain_name(): '''Return current domain name''' dns_config = SCDynamicStoreCopyValue(None, 'State:/Network/Global/DNS') return dns_config.get('DomainName')