fix all new ldapsync issues
This commit is contained in:
parent
6251e610e8
commit
09c22b23a7
@ -21,7 +21,7 @@ class LUSER():
|
|||||||
if response == []:
|
if response == []:
|
||||||
response = 0
|
response = 0
|
||||||
else:
|
else:
|
||||||
response = int(response['attributes']['uidNumber'])
|
response = int(response[0]['attributes']['uidNumber'])
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def setlastlog(self, newvalue: int):
|
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'])
|
self.ldapconnection.search(search_base=f'uid=total,{self.logbase}',search_filter='(objectClass=person)', attributes=['uidNumber'])
|
||||||
response = self.ldapconnection.response
|
response = self.ldapconnection.response
|
||||||
|
|
||||||
if response == []:
|
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}' }
|
||||||
self.ldapconnection.add(f'uid=total,{self.logbase}', OBJECTCLASSES, { 'uid' : 'total', 'uidNumber' : 0 })
|
|
||||||
|
|
||||||
|
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])})
|
self.ldapconnection.modify(f'uid=total,{self.logbase}', {'uidNumber' : (ldap3.MODIFY_REPLACE, [newvalue])})
|
||||||
|
|
||||||
return self.ldapconnection.response
|
return self.ldapconnection.response
|
||||||
@ -175,6 +177,7 @@ class LUSER():
|
|||||||
# Return boolean value of new user entry
|
# Return boolean value of new user entry
|
||||||
rcode1 = self.ldapconnection.add(f'uid={user},{self.base}', objectClass, attributes)
|
rcode1 = self.ldapconnection.add(f'uid={user},{self.base}', objectClass, attributes)
|
||||||
|
|
||||||
|
|
||||||
# Add new user to log
|
# Add new user to log
|
||||||
attributes['description'] = 'ADD'
|
attributes['description'] = 'ADD'
|
||||||
|
|
||||||
@ -186,7 +189,7 @@ class LUSER():
|
|||||||
# Return True only if both entries was successful
|
# Return True only if both entries was successful
|
||||||
return rcode1 and rcode2
|
return rcode1 and rcode2
|
||||||
|
|
||||||
def changepassword(self, user, newpass, althash=''):
|
def changepassword(self, user, newpass):
|
||||||
'''
|
'''
|
||||||
Change password of user to newpass
|
Change password of user to newpass
|
||||||
|
|
||||||
@ -203,7 +206,7 @@ class LUSER():
|
|||||||
|
|
||||||
OBJECTCLASSES = ['top', 'person', 'organizationalPerson', 'inetOrgPerson', 'posixAccount', 'shadowAccount']
|
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 = self.ldapconnection.response[0]
|
||||||
userdata['attributes']['description'] = 'CHANGEPASS'
|
userdata['attributes']['description'] = 'CHANGEPASS'
|
||||||
|
Loading…
Reference in New Issue
Block a user