Esempio n. 1
0
def get_user(user, auto_create=None):
    """
    user can be int(treated as id) or string(treated as username)
    auto_create = True or False or None
        when set to None,will use the value of settings.LDAP.user_auto_create
    """

    if isinstance(user, int):
        User = get_model('user')
        return User.get(user)
    elif isinstance(user, (str, unicode)):
        attr_dict = ldapauth_handler.get_user(username=user)

        if attr_dict:
            try:
                return _sync_ldap_user(user, attr_dict, auto_create)
            except UserNotFoundError as err:
                log.error("user '%s' not found" % (user))
Esempio n. 2
0
def get_user(user,auto_create=None):
    """
    user can be int(treated as id) or string(treated as username)
    auto_create = True or False or None
        when set to None,will use the value of settings.LDAP.user_auto_create
    """

    if isinstance(user,int):
        User = get_model('user')
        return User.get(user)
    elif isinstance(user,(str,unicode)):
        attr_dict = ldapauth_handler.get_user(username=user)

        if attr_dict:
            try:
                return _sync_ldap_user(user,attr_dict,auto_create)
            except UserNotFoundError as err:
                log.error("user '%s' not found"%(user))
Esempio n. 3
0
def ldap_get_user(username):
    return ldapauth_handler.get_user(username=username)
Esempio n. 4
0
def ldap_get_user(username):
    return ldapauth_handler.get_user(username=username)