示例#1
0
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
示例#2
0
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
示例#3
0
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()
示例#5
0
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
示例#6
0
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}
示例#8
0
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}
示例#9
0
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}
示例#10
0
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}
示例#11
0
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)}
示例#12
0
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}
示例#13
0
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}
示例#14
0
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}
示例#15
0
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}
示例#16
0
def get_domain_name():
    '''Return current domain name'''
    dns_config = SCDynamicStoreCopyValue(None, 'State:/Network/Global/DNS')
    return dns_config.get('DomainName')
示例#17
0
文件: autoconfig.py 项目: munki/munki
def get_domain_name():
    '''Return current domain name'''
    dns_config = SCDynamicStoreCopyValue(None, 'State:/Network/Global/DNS')
    return dns_config.get('DomainName')