FreeIPAServer.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:ipa_check_consistency 作者: peterpakos 项目源码 文件源码
def __init__(self, fqdn, binddn, bindpw):
        self._log = logging.getLogger()
        self._log.debug('Initialising FreeIPA server %s' % fqdn)
        self.fqdn = fqdn
        self.hostname_short = fqdn.partition('.')[0]
        self._domain = fqdn.partition('.')[2]
        self._binddn = binddn
        self._bindpw = bindpw
        self._url = 'ldaps://' + fqdn
        self._base_dn = 'dc=' + fqdn.partition('.')[2].replace('.', ',dc=')
        self._active_user_base = 'cn=users,cn=accounts,' + self._base_dn
        self._stage_user_base = 'cn=staged users,cn=accounts,cn=provisioning,' + self._base_dn
        self._preserved_user_base = 'cn=deleted users,cn=accounts,cn=provisioning,' + self._base_dn
        self._groups_base = 'cn=groups,cn=accounts,' + self._base_dn

        try:
            self._conn = ldap.initialize(self._url)
            self._conn.set_option(ldap.OPT_NETWORK_TIMEOUT, 3)
            self._conn.simple_bind_s(self._binddn, self._bindpw)
        except (
            ldap.SERVER_DOWN,
            ldap.NO_SUCH_OBJECT,
            ldap.INVALID_CREDENTIALS
        ) as err:
            self._log.critical('Bind error: %s (%s)' % (err.message['desc'], self.fqdn))
            exit(1)

        self.users = self._count_users(user_base='active')
        self.ustage = self._count_users(user_base='stage')
        self.upres = self._count_users(user_base='preserved')
        self.ugroups = self._count_groups()
        self.hosts = self._count_hosts()
        self.hgroups = self._count_hostgroups()
        self.hbac = self._count_hbac_rules()
        self.sudo = self._count_sudo_rules()
        self.zones = self._count_dns_zones()
        self.certs = self._count_certificates()
        self.ldap = self._ldap_conflicts()
        self.ghosts = self._ghost_replicas()
        self.bind = self._anon_bind()
        self.msdcs = self._ms_adtrust()
        self.replica, self.healthy_agreements = self._replication_agreements()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号