Skip to content

Ldap user

LdapUser

Bases: DomainObject

Represents an entry mapping a ldap id to a CKAN user.

Source code in ckanext/ldap/model/ldap_user.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class LdapUser(model.domain_object.DomainObject):
    """
    Represents an entry mapping a ldap id to a CKAN user.
    """

    @classmethod
    def by_ldap_id(cls, ldap_id, autoflush=True):
        """
        Return the LdapUser object mapping the given ldap id.

        :param ldap_id: ldap id, as returned by the LDAP server
        :param autoflush: (Default value = True)
        :returns: LdapUser object or None
        """
        obj = (
            model.meta.Session.query(cls)
            .autoflush(autoflush)
            .filter_by(ldap_id=ldap_id)
            .first()
        )
        return obj

    @classmethod
    def by_user_id(cls, user_id, autoflush=True):
        """
        Return the LdapUser object mapping the given user id.

        :param user_id: CKAN user id (actual id, not name)
        :param autoflush: (Default value = True)
        :returns: LdapUser object or None
        """
        obj = (
            model.meta.Session.query(cls)
            .autoflush(autoflush)
            .filter_by(user_id=user_id)
            .first()
        )
        return obj

by_ldap_id(ldap_id, autoflush=True) classmethod

Return the LdapUser object mapping the given ldap id.

Parameters:

Name Type Description Default
ldap_id

ldap id, as returned by the LDAP server

required
autoflush

(Default value = True)

True

Returns:

Type Description

LdapUser object or None

Source code in ckanext/ldap/model/ldap_user.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@classmethod
def by_ldap_id(cls, ldap_id, autoflush=True):
    """
    Return the LdapUser object mapping the given ldap id.

    :param ldap_id: ldap id, as returned by the LDAP server
    :param autoflush: (Default value = True)
    :returns: LdapUser object or None
    """
    obj = (
        model.meta.Session.query(cls)
        .autoflush(autoflush)
        .filter_by(ldap_id=ldap_id)
        .first()
    )
    return obj

by_user_id(user_id, autoflush=True) classmethod

Return the LdapUser object mapping the given user id.

Parameters:

Name Type Description Default
user_id

CKAN user id (actual id, not name)

required
autoflush

(Default value = True)

True

Returns:

Type Description

LdapUser object or None

Source code in ckanext/ldap/model/ldap_user.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@classmethod
def by_user_id(cls, user_id, autoflush=True):
    """
    Return the LdapUser object mapping the given user id.

    :param user_id: CKAN user id (actual id, not name)
    :param autoflush: (Default value = True)
    :returns: LdapUser object or None
    """
    obj = (
        model.meta.Session.query(cls)
        .autoflush(autoflush)
        .filter_by(user_id=user_id)
        .first()
    )
    return obj