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'
|
||||||
|
|
||||||
rcode2 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', objectClass, attributes)
|
if rcode1:
|
||||||
|
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
|
||||||
|
|
||||||
rcode1 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
|
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 rcode1:
|
if chpassbool and chlastchangebool:
|
||||||
self.setlastlog(lastlog)
|
rcode1 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
|
||||||
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 rcode1:
|
||||||
|
self.setlastlog(lastlog)
|
||||||
# Return True only if changing of both password and time of last password change was successful
|
return True
|
||||||
return chpassbool and chlastchangebool
|
else:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
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