fix all new ldapsync issues
This commit is contained in:
parent
6251e610e8
commit
09c22b23a7
@ -21,7 +21,7 @@ class LUSER():
|
||||
if response == []:
|
||||
response = 0
|
||||
else:
|
||||
response = int(response['attributes']['uidNumber'])
|
||||
response = int(response[0]['attributes']['uidNumber'])
|
||||
return response
|
||||
|
||||
def setlastlog(self, newvalue: int):
|
||||
@ -31,9 +31,11 @@ class LUSER():
|
||||
self.ldapconnection.search(search_base=f'uid=total,{self.logbase}',search_filter='(objectClass=person)', attributes=['uidNumber'])
|
||||
response = self.ldapconnection.response
|
||||
|
||||
if response == []:
|
||||
self.ldapconnection.add(f'uid=total,{self.logbase}', OBJECTCLASSES, { 'uid' : 'total', 'uidNumber' : 0 })
|
||||
attributes = {'cn' : 'total', 'sn' : 'total', 'givenName' : 'total', 'uid' : 'total', 'uidNumber' : newvalue, 'gidNumber' : newvalue, 'homeDirectory' : f'/home/total', 'loginShell' : '/usr/bin/git-shell', 'gecos' : 'SystemUser', 'shadowLastChange' : self.lastpwchangenow(), 'shadowMax' : '45', 'userPassword' : 'total', 'mail' : f'total@{self.domain}' }
|
||||
|
||||
if response == []:
|
||||
self.ldapconnection.add(f'uid=total,{self.logbase}', OBJECTCLASSES, attributes)
|
||||
else:
|
||||
self.ldapconnection.modify(f'uid=total,{self.logbase}', {'uidNumber' : (ldap3.MODIFY_REPLACE, [newvalue])})
|
||||
|
||||
return self.ldapconnection.response
|
||||
@ -175,6 +177,7 @@ class LUSER():
|
||||
# Return boolean value of new user entry
|
||||
rcode1 = self.ldapconnection.add(f'uid={user},{self.base}', objectClass, attributes)
|
||||
|
||||
|
||||
# Add new user to log
|
||||
attributes['description'] = 'ADD'
|
||||
|
||||
@ -186,7 +189,7 @@ class LUSER():
|
||||
# Return True only if both entries was successful
|
||||
return rcode1 and rcode2
|
||||
|
||||
def changepassword(self, user, newpass, althash=''):
|
||||
def changepassword(self, user, newpass):
|
||||
'''
|
||||
Change password of user to newpass
|
||||
|
||||
@ -203,7 +206,7 @@ class LUSER():
|
||||
|
||||
OBJECTCLASSES = ['top', 'person', 'organizationalPerson', 'inetOrgPerson', 'posixAccount', 'shadowAccount']
|
||||
|
||||
self.ldapconnection.search(search_base=f'uid=username,{self.base}',search_filter='(objectClass=person)', attributes=USERATTRIBUTES)
|
||||
self.ldapconnection.search(search_base=f'uid={user},{self.base}',search_filter='(objectClass=person)', attributes=USERATTRIBUTES)
|
||||
|
||||
userdata = self.ldapconnection.response[0]
|
||||
userdata['attributes']['description'] = 'CHANGEPASS'
|
||||
|
Loading…
Reference in New Issue
Block a user