Project

General

Profile

« Previous | Next » 

Revision 2750dbae

Added by Thomas Noël over 12 years ago

[ezldap] raise a KeyError exception if user don't exist in ldap

View differences:

extra/modules/ezldap.py
172 172
class EzMagicUser(User):
173 173
    def get(cls, id, ignore_errors=False, ignore_migration=False):
174 174
        if '=' in str(id):
175
            try:
176
                # FIXME : do a ldap search on each get is not very efficient,
177
                # perhaps add a little cache ? (ttl 5 min ?)
178
                get_ldap_conn().search_s(str(id), ldap.SCOPE_BASE)
179
            except ldap.NO_SUCH_OBJECT:
180
                raise KeyError
175 181
            return EzLdapUser(id)
176 182
        else:
177 183
            return User.get(id, ignore_errors, ignore_migration)

Also available in: Unified diff