X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=UDLdap.py;h=5b0caa7c4fb44243e62595a5650ec6e02de931a1;hb=d1ad8523f8e88bf96d9c515da8c8c451a3089bea;hp=9e2d2ee7e3b24408f10a588c77464860fddf03f5;hpb=059c1ab2073bf678019edafff8c515ed1d2c341a;p=mirror%2Fuserdir-ldap.git diff --git a/UDLdap.py b/UDLdap.py index 9e2d2ee..5b0caa7 100644 --- a/UDLdap.py +++ b/UDLdap.py @@ -3,8 +3,8 @@ import time import userdir_ldap class Account: - array_values = ['keyFingerPrint'] - int_values = ['shadowExpire'] + array_values = ['keyFingerPrint', 'mailWhitelist', 'mailRBL', 'mailRHSBL', 'supplementaryGid', 'sshRSAAuthKey', 'sudoPassword'] + int_values = ['shadowExpire', 'gidNumber'] defaults = { 'accountStatus': 'active', 'keyFingerPrint': [] @@ -30,11 +30,12 @@ class Account: if key in self.attributes: if key in self.array_values: return self.attributes[key] - elif key in self.int_values: - if len(self.attributes[key]) == 1: - return int(self.attributes[key][0]) - else: - raise ValueError, 'non-array value has not exactly one value' + + if not len(self.attributes[key]) == 1: + raise ValueError, 'non-array value has not exactly one value' + + if key in self.int_values: + return int(self.attributes[key][0]) else: return self.attributes[key][0] elif key in self.defaults: @@ -54,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 \