projects
/
mirror
/
userdir-ldap.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
GenDNS
[mirror/userdir-ldap.git]
/
UDLdap.py
diff --git
a/UDLdap.py
b/UDLdap.py
index
9f8a0fd
..
dcf0bb4
100644
(file)
--- a/
UDLdap.py
+++ b/
UDLdap.py
@@
-3,8
+3,8
@@
import time
import userdir_ldap
class Account:
import userdir_ldap
class Account:
- array_values = ['
keyFingerPrint
']
- int_values = ['shadowExpire']
+ array_values = ['
objectClass', 'keyFingerPrint', 'mailWhitelist', 'mailRBL', 'mailRHSBL', 'supplementaryGid', 'sshRSAAuthKey', 'sudoPassword', 'dnsZoneEntry
']
+ int_values = ['shadowExpire'
, 'gidNumber', 'uidNumber'
]
defaults = {
'accountStatus': 'active',
'keyFingerPrint': []
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]
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:
else:
return self.attributes[key][0]
elif key in self.defaults:
@@
-54,8
+55,17
@@
class Account:
def pw_active(self):
if self['userPassword'] == '{crypt}*LK*':
return False
def pw_active(self):
if self['userPassword'] == '{crypt}*LK*':
return False
+ if self['userPassword'].startswith("{crypt}!"):
+ return False
return True
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 \
# not expired
def shadow_active(self):
if 'shadowExpire' in self and \
@@
-66,6
+76,9
@@
class Account:
def numkeys(self):
return len(self['keyFingerPrint'])
def numkeys(self):
return len(self['keyFingerPrint'])
+ def is_active_user(self):
+ return self['accountStatus'] == 'active' and self.numkeys() != 0
+
def latitude_dec(self, anonymized=False):
return userdir_ldap.DecDegree(self['latitude'], anonymized)
def longitude_dec(self, anonymized=False):
def latitude_dec(self, anonymized=False):
return userdir_ldap.DecDegree(self['latitude'], anonymized)
def longitude_dec(self, anonymized=False):
@@
-84,6
+97,14
@@
class Account:
def get_dn(self):
return self.dn
def get_dn(self):
return self.dn
+ def email_address(self):
+ mailbox = "<%s@%s>" % (self['uid'], userdir_ldap.EmailAppend)
+ tokens = []
+ if 'cn' in self: tokens.append(self['cn'])
+ if 'sn' in self: tokens.append(self['sn'])
+ tokens.append(mailbox)
+ return ' '.join(tokens)
+
# vim:set et:
# vim:set ts=4:
# vim:set shiftwidth=4:
# vim:set et:
# vim:set ts=4:
# vim:set shiftwidth=4: