X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=blobdiff_plain;f=UDLdap.py;fp=UDLdap.py;h=01553459bcac7d769faca1a08d9fb600d3d85157;hp=2e4509258e9301947b38334676df1bd0d1a5a242;hb=b6f36909f626ad4c95ae63996583e34f23d77ff1;hpb=57fc92ff4c4cb910338dc3806edb4c80252ac3fb diff --git a/UDLdap.py b/UDLdap.py index 2e45092..0155345 100644 --- a/UDLdap.py +++ b/UDLdap.py @@ -16,11 +16,9 @@ class Account: def from_search(ldap_connection, base, user): searchresult = ldap_connection.search_s(base, ldap.SCOPE_SUBTREE, 'uid=%s'%(user)) if len(searchresult) < 1: - sys.stderr.write("No such user: %s\n"%(user)) - return + raise IndexError, "No such user: %s\n"%(user) elif len(searchresult) > 1: - sys.stderr.write("More than one hit when getting %s\n"%(user)) - return + raise IndexError, "More than one hit when getting %s\n"%(user) else: return Account(searchresult[0][0], searchresult[0][1])