Skip to content

Commit

Permalink
Catch ldap.INSUFFICIENT_ACCESS exception for adding/removing key from…
Browse files Browse the repository at this point in the history
… LDAP
  • Loading branch information
basvandervlies authored and jirutka committed Oct 8, 2015
1 parent d4b2e47 commit 9f882c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bin/ssh-ldap-pubkey
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class LdapSSH(object):
raise ConfigError(
"LDAP server doesn't define schema for attribute: %s" % LDAP_PUBKEY_ATTR, 1)

except ldap.INSUFFICIENT_ACCESS:
raise InsufficientAccessError("No rights to add key for %s " % dn, 2)

def find_and_remove_pubkeys(self, login, password, pattern):
dn = self.find_dn_by_login(login)
if password:
Expand Down Expand Up @@ -173,6 +176,9 @@ class LdapSSH(object):
except ldap.NO_SUCH_ATTRIBUTE:
raise NoPubKeyFoundError("No such public key exists: %s." % keyname(pubkey), 1)

except ldap.INSUFFICIENT_ACCESS:
raise InsufficientAccessError("No rights to remove key for %s " % dn, 2)


class LdapConfig(object):

Expand Down Expand Up @@ -230,6 +236,7 @@ class Error(Exception):


class ConfigError(Error): pass
class InsufficientAccessError(Error): pass
class InvalidCredentialsError(Error): pass
class InvalidPubKeyError(Error): pass
class LDAPConnectionError(Error): pass
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='ssh-ldap-pubkey',
version='0.4.0',
version='0.4.1',
url='https://github.com/jirutka/ssh-ldap-pubkey',
description='Utility to manage SSH public keys stored in LDAP.',
long_description=read_md('README.md'),
Expand Down

0 comments on commit 9f882c7

Please sign in to comment.