fix log numbering
This commit is contained in:
parent
3818419cae
commit
2b8c5ea453
@ -181,7 +181,10 @@ class LUSER():
|
||||
# Add new user to log
|
||||
attributes['description'] = 'ADD'
|
||||
|
||||
if rcode1:
|
||||
rcode2 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', objectClass, attributes)
|
||||
else:
|
||||
return False
|
||||
|
||||
if rcode2:
|
||||
self.setlastlog(lastlog)
|
||||
@ -213,16 +216,19 @@ class LUSER():
|
||||
|
||||
lastlog = self.getlastlog() + 1
|
||||
|
||||
chpassbool = self.ldapconnection.modify(f'uid={user},{self.base}', {'userPassword': (MODIFY_REPLACE,[newpass])})
|
||||
chlastchangebool = self.ldapconnection.modify(f'uid={user},{self.base}', {'shadowLastChange' : (MODIFY_REPLACE,[self.lastpwchangenow()])})
|
||||
|
||||
if chpassbool and chlastchangebool:
|
||||
rcode1 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
|
||||
|
||||
if rcode1:
|
||||
self.setlastlog(lastlog)
|
||||
chpassbool = self.ldapconnection.modify(f'uid={user},{self.base}', {'userPassword': (MODIFY_REPLACE,[newpass])})
|
||||
|
||||
chlastchangebool = self.ldapconnection.modify(f'uid={user},{self.base}', {'shadowLastChange' : (MODIFY_REPLACE,[self.lastpwchangenow()])})
|
||||
|
||||
# Return True only if changing of both password and time of last password change was successful
|
||||
return chpassbool and chlastchangebool
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
def delete(self, user):
|
||||
'''
|
||||
@ -242,13 +248,19 @@ class LUSER():
|
||||
|
||||
lastlog = self.getlastlog() + 1
|
||||
|
||||
rcode1 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
|
||||
|
||||
rcode1 = self.ldapconnection.delete(f'uid={user},{self.base}')
|
||||
|
||||
if rcode1:
|
||||
self.setlastlog(lastlog)
|
||||
rcode2 = self.ldapconnection.delete(f'uid={user},{self.base}')
|
||||
rcode2 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
|
||||
|
||||
return rcode1 and rcode2
|
||||
if rcode2:
|
||||
self.setlastlog(lastlog)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
def getpassword(self, user):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user