3 def __init__(self, user):
4 searchresult = lc.search_s(BaseDn,ldap.SCOPE_SUBTREE, 'uid=%s'%(user))
5 if len(searchresult) < 1:
6 sys.stderr.write("No such user: %s\n"%(user))
8 elif len(searchresult) > 1:
9 sys.stderr.write("More than one hit when getting %s\n"%(user))
12 self.dn, self.attributes = searchresult[0]
16 if 'mailDisableMessage' in self.attributes:
20 # not locked locked, just reset to something invalid like {crypt}*SSLRESET* is still active
22 if self.attributes['userPassword'][0] == '{crypt}*LK*':
27 def shadow_active(self):
28 if 'shadowExpire' in self.attributes and \
29 int(self.attributes['shadowExpire'][0]) < (time.time() / 3600 / 24):
34 if 'keyFingerPrint' in self.attributes:
35 return len(self.attributes['keyFingerPrint'])
38 def account_status(self):
39 if 'accountStatus' in self.attributes:
40 return self.attributes['accountStatus'][0]
44 def verbose_status(self):
46 status.append('mail: %s' %(['disabled', 'active'][ self.has_mail() ]))
47 status.append('pw: %s' %(['locked', 'active'][ self.pw_active() ]))
48 status.append('shadow: %s'%(['expired', 'active'][ self.shadow_active() ]))
49 status.append('keys: %d' %( self.numkeys() ))
50 status.append('status: %s'%( self.account_status() ))
52 return '(%s)'%(', '.join(status))
59 # vim:set shiftwidth=4: