A class shouldn't write to stderr on error, it should throw an exception
[mirror/userdir-ldap.git] / ud-lock
diff --git a/ud-lock b/ud-lock
index a274274..7e8725d 100755 (executable)
--- a/ud-lock
+++ b/ud-lock
@@ -48,7 +48,11 @@ def connect(user):
     return l
 
 def do_one_user(lc, user, ticket):
-    u = UDLdap.Account.from_search(lc, BaseDn, user)
+    try:
+        u = UDLdap.Account.from_search(lc, BaseDn, user)
+    except IndexError, e:
+        sys.stderr.write("Cannot instantiate account from LDAP: %s"%(str(e)))
+        return
     if not u['accountStatus'] == 'active':
         sys.stderr.write('%s: Account is not active, skipping.  (details: %s)\n'%(user, u.verbose_status()))
         return