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