def aggregate_user_in_ldap_group(): ''' 从下往上聚合组成员并逐节点保存 ''' conn = Connection( Server(settings.LDAP_SERVER), user=settings.LDAP_USER, password=settings.LDAP_PASSWORD, auto_bind=True, raise_exceptions=True, ) ldap_aggregate_user.aggregate_user_in_group(conn, settings.LDAP_GROUP_BASE)
def flush_user_perm_in_ldap(): ''' 刷新LDAP中用户的权限 必须周期性执行 ''' conn = Connection( Server(settings.LDAP_SERVER), user=settings.LDAP_USER, password=settings.LDAP_PASSWORD, auto_bind=True, raise_exceptions=True, ) ldap_user_perm.flush_user_perm(conn)
def __init__(self, server='', base='', user='', password=''): self.base = base if base else settings.LDAP_BASE self.dept_base = 'ou=dept,{}'.format(self.base) self.group_base = 'ou=group,{}'.format(self.base) self.people_base = 'ou=people,{}'.format(self.base) self.server = Server(server if server else settings.LDAP_SERVER) self.conn = Connection( self.server, user=user if user else settings.LDAP_USER, password=password if password else settings.LDAP_PASSWORD, auto_bind=True, raise_exceptions=True, ) self.group_placeholder = '' self.dept_placeholder = ''
def __init__(self, *args, **kwargs): self.server = Server(settings.LDAP_SERVER) self.base = settings.LDAP_BASE self.conn = Connection(self.server, user=settings.LDAP_USER, password=settings.LDAP_PASSWORD, auto_bind=True, raise_exceptions=False) self.ldap_executer = LDAPExecuter(base='dc=example,dc=org') self.rdb_executer = RDBExecuter() self.cli = cli_factory([ 'executer.RDB.RDBExecuter', 'executer.LDAP.LDAPExecuter', ])(User.objects.first()) settings.LDAP_BASE = 'dc=example,dc=org' super(LDAPBaseTestCase, self).__init__(*args, **kwargs)