add all functionality for basealt
This commit is contained in:
parent
ca91a5512b
commit
237e7bd14e
@ -13,12 +13,15 @@ class LUSER():
|
||||
'''
|
||||
|
||||
|
||||
def expandbase(self):
|
||||
def expandbase(self, basealt = ''):
|
||||
'''
|
||||
Extract orgnaization, name of dc object and full domain part with all dc values from base
|
||||
'''
|
||||
# Split base string with commas to find values of organization and dc
|
||||
baselist = self.base.split(",")
|
||||
if basealt == '':
|
||||
baselist = self.base.split(",")
|
||||
else:
|
||||
baselist = self.basealt.split(",")
|
||||
|
||||
organization = ''
|
||||
dc = ''
|
||||
@ -54,8 +57,9 @@ class LUSER():
|
||||
self.admin_user = admin_user
|
||||
self.admin_pass = admin_pass
|
||||
self.base = base
|
||||
self.organization, self.dc, self.dcfull, self.domain = self.expandbase()
|
||||
self.basealt = basealt
|
||||
self.organization, self.dc, self.dcfull, self.domain = self.expandbase()
|
||||
self.organizationalt, self.dcalt, self.dcfullalt, self.domainalt = self.expandbase(self.basealt)
|
||||
self.alt = True
|
||||
self.autoconnect = autoconnect
|
||||
ldapserver = Server(ldap_host, use_ssl=True)
|
||||
@ -82,9 +86,14 @@ class LUSER():
|
||||
|
||||
rcode2 = self.ldapconnection.add(self.base, ['top', 'organizationalUnit'], {'ou' : self.organization})
|
||||
|
||||
# Return True only if all return values are true
|
||||
# Add dcobject and organizational units as above for base alt
|
||||
rcode3 = True
|
||||
rcode4 = True
|
||||
if self.alt:
|
||||
rcode3 = self.ldapconnection.add(f'dc={self.dcfull}', ['dcObject', 'organization'], {'o' : self.dc, 'dc' : self.dc})
|
||||
rcode4 = self.ldapconnection.add(self.base, ['top', 'organizationalUnit'], {'ou' : self.organization})
|
||||
|
||||
return rcode1 and rcode2
|
||||
return rcode1 and rcode2 and rcode3 and rcode4
|
||||
|
||||
def lastpwchangenow(self):
|
||||
'''
|
||||
@ -116,7 +125,7 @@ class LUSER():
|
||||
# Attributes for a user entry
|
||||
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}' }
|
||||
|
||||
attributesalt = {'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' : althash, 'mail' : f'{user}@{self.domain}'}
|
||||
attributesalt = {'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' : althash, 'mail' : f'{user}@{self.domainalt}'}
|
||||
|
||||
# Return boolean value of new user entry
|
||||
rcode1 = self.ldapconnection.add(f'{id},{self.base}', objectClass, attributes)
|
||||
|
Loading…
Reference in New Issue
Block a user