bug fixes

This commit is contained in:
fram3d 2024-03-28 18:55:48 +01:00
parent 67f3fefae5
commit 6251e610e8
Signed by: fram3d
GPG Key ID: 938920E709EEA32A

View File

@ -2,6 +2,9 @@ import ldap3
from ldap3 import Server,Connection,ALL,MODIFY_REPLACE from ldap3 import Server,Connection,ALL,MODIFY_REPLACE
from datetime import datetime from datetime import datetime
OBJECTCLASSES = ['top', 'person', 'organizationalPerson', 'inetOrgPerson', 'posixAccount', 'shadowAccount']
USERATTRIBUTES = ['cn' , 'sn', 'givenName', 'uid', 'uidNumber' , 'gidNumber', 'homeDirectory', 'loginShell', 'gecos' , 'shadowLastChange', 'shadowMax', 'userPassword', 'mail', 'description']
class LUSER(): class LUSER():
''' '''
Class that represents secure connection to LDAP server Class that represents secure connection to LDAP server
@ -161,6 +164,7 @@ class LUSER():
# Add user to base # Add user to base
id = f"uid={user}" id = f"uid={user}"
lastlog = self.getlastlog() + 1
# Object classes of a user entry # Object classes of a user entry
objectClass = ['top', 'person', 'organizationalPerson', 'inetOrgPerson', 'posixAccount', 'shadowAccount'] objectClass = ['top', 'person', 'organizationalPerson', 'inetOrgPerson', 'posixAccount', 'shadowAccount']
@ -169,11 +173,10 @@ class LUSER():
attributes = {'cn' : user, 'sn' : user, 'givenName' : user, 'uid' : user, 'uidNumber' : self.lastuid, 'gidNumber' : self.lastgid, 'homeDirectory' : f'/home/{user}', 'loginShell' : '/usr/bin/git-shell', 'gecos' : 'SystemUser', 'shadowLastChange' : self.lastpwchangenow(), 'shadowMax' : '45', 'userPassword' : password, 'mail' : f'{user}@{self.domain}' } attributes = {'cn' : user, 'sn' : user, 'givenName' : user, 'uid' : user, 'uidNumber' : self.lastuid, 'gidNumber' : self.lastgid, 'homeDirectory' : f'/home/{user}', 'loginShell' : '/usr/bin/git-shell', 'gecos' : 'SystemUser', 'shadowLastChange' : self.lastpwchangenow(), 'shadowMax' : '45', 'userPassword' : password, 'mail' : f'{user}@{self.domain}' }
# Return boolean value of new user entry # Return boolean value of new user entry
rcode1 = self.ldapconnection.add(self.logbase, 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'
lastlog = self.getlastlog() + 1
rcode2 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', objectClass, attributes) rcode2 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', objectClass, attributes)