def get_user(self, user_id): with self.connection as c: result = c.search(self.app.config['SYNC_LDAP_MEMBERDN'], '(uid={})'.format(user_id), SEARCH_SCOPE_WHOLE_SUBTREE, attributes=['*']) if result: if len(c.response) > 1: raise Exception('Found more than one result for uid {}'.format(user_id)) resource = c.response[0] print(resource) return LDAPUser.from_ldap(resource)
def insert_user(self, model): ldap_user = LDAPUser.from_sql(model) self.save_user(ldap_user)