GenPasswd
[mirror/userdir-ldap.git] / UDLdap.py
index 096f117..90c942d 100644 (file)
--- a/UDLdap.py
+++ b/UDLdap.py
@@ -4,7 +4,7 @@ import userdir_ldap
 
 class Account:
     array_values = ['keyFingerPrint', 'mailWhitelist', 'mailRBL', 'mailRHSBL', 'supplementaryGid', 'sshRSAAuthKey', 'sudoPassword']
-    int_values = ['shadowExpire', 'gidNumber']
+    int_values = ['shadowExpire', 'gidNumber', 'uidNumber']
     defaults = {
                  'accountStatus': 'active',
                  'keyFingerPrint': []
@@ -55,10 +55,17 @@ class Account:
     def pw_active(self):
         if self['userPassword'] == '{crypt}*LK*':
             return False
-        if self['userPassword'].startswith("!"):
+        if self['userPassword'].startswith("{crypt}!"):
             return False
         return True
 
+    def get_password(self):
+        p = self['userPassword']
+        if not p.startswith('{crypt}') or len(p) > 50:
+            return p
+        else:
+            return p[7:]
+
     # not expired
     def shadow_active(self):
         if 'shadowExpire' in self and \