diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2011-12-12 22:53:10 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2011-12-12 22:53:10 +0100 |
commit | 330a28040095fff67e9cb105019f3b4cb7cb5f0e (patch) | |
tree | 802d2a763f9210a3a1f581a9f758bdde301b96df /pynslcd/shadow.py | |
parent | f4b3ad848987eb6ac2cf50d7ea99d1a7b579c70c (diff) |
move check of required attributes and other common tests to the Request.handle_entry() method
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1570 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'pynslcd/shadow.py')
-rw-r--r-- | pynslcd/shadow.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/pynslcd/shadow.py b/pynslcd/shadow.py index 34119b0..73b8fea 100644 --- a/pynslcd/shadow.py +++ b/pynslcd/shadow.py @@ -39,16 +39,13 @@ bases = ( 'ou=people,dc=test,dc=tld', ) class ShadowRequest(common.Request): + case_sensitive = ('uid', ) + limit_attributes = ('uid', ) + required = ('uid', ) + def write(self, dn, attributes, parameters): # get name and check against requested name names = attributes['uid'] - if not names: - print 'Error: entry %s does not contain %s value' % ( dn, attmap['uid'] ) - return - if 'uid' in parameters: - if parameters['uid'] not in names: - return - names = ( parameters['uid'], ) # get password (passwd, ) = attributes['userPassword'] if not passwd or self.calleruid != 0: @@ -56,11 +53,11 @@ class ShadowRequest(common.Request): # function for making an int def mk_int(attr): try: - return + return int(attr) except TypeError: return None # get lastchange date - lastchangedate = int(attributes.get('shadowLastChange', [0])[0]) + lastchangedate = mk_int(attributes.get('shadowLastChange', [0])[0]) # we expect an AD 64-bit datetime value; # we should do date=date/864000000000-134774 # but that causes problems on 32-bit platforms, @@ -69,12 +66,12 @@ class ShadowRequest(common.Request): if attmap['shadowLastChange'] == 'pwdLastSet': lastchangedate = ( lastchangedate / 864000000000 ) - 134774 # get longs - mindays = int(attributes.get('shadowMin', [-1])[0]) - maxdays = int(attributes.get('shadowMax', [-1])[0]) - warndays = int(attributes.get('shadowWarning', [-1])[0]) - inactdays = int(attributes.get('shadowInactive', [-1])[0]) - expiredate = int(attributes.get('shadowExpire', [-1])[0]) - flag = int(attributes.get('shadowFlag', [0])[0]) + mindays = mk_int(attributes.get('shadowMin', [-1])[0]) + maxdays = mk_int(attributes.get('shadowMax', [-1])[0]) + warndays = mk_int(attributes.get('shadowWarning', [-1])[0]) + inactdays = mk_int(attributes.get('shadowInactive', [-1])[0]) + expiredate = mk_int(attributes.get('shadowExpire', [-1])[0]) + flag = mk_int(attributes.get('shadowFlag', [0])[0]) if attmap['shadowFlag'] == 'pwdLastSet': if flag & 0x10000: maxdays = -1 |