use new variables from expandbase in prepareldap function and rename it to prepare
This commit is contained in:
parent
533a9885d4
commit
92e2b393c8
@ -67,73 +67,21 @@ class LUSER():
|
|||||||
if basealt == '':
|
if basealt == '':
|
||||||
self.alt = False
|
self.alt = False
|
||||||
|
|
||||||
def prepareluser(self):
|
def prepare(self):
|
||||||
'''
|
'''
|
||||||
Create base on LDAP host
|
Create base on LDAP host
|
||||||
'''
|
'''
|
||||||
|
# Create dcObject on LDAP server and store boolean indicating it's success
|
||||||
|
|
||||||
# Split base string with commas to find values of organization and dc
|
rcode1 = self.ldapconnection.add(f'dc={self.dcfull}', ['dcObject', 'organization'], {'o' : self.dc, 'dc' : self.dc})
|
||||||
baselist = self.base.split(",")
|
|
||||||
basealtlist = self.basealt.split(",")
|
|
||||||
|
|
||||||
# Find ou in base and set it as organization variable
|
|
||||||
for i in baselist:
|
|
||||||
if i.split('=')[0] == 'ou':
|
|
||||||
organization = i.split('=')[1]
|
|
||||||
break
|
|
||||||
|
|
||||||
for i in basealtlist:
|
|
||||||
if i.split('=')[0] == 'ou':
|
|
||||||
organizationalt = i.split('=')[1]
|
|
||||||
break
|
|
||||||
|
|
||||||
# Find first dc and set it as dc variable
|
|
||||||
for i in baselist:
|
|
||||||
if i.split('=')[0] == 'dc':
|
|
||||||
dc = i.split('=')[1]
|
|
||||||
break
|
|
||||||
|
|
||||||
for i in basealtlist:
|
|
||||||
if i.split('=')[0] == 'dc':
|
|
||||||
dcalt = i.split('=')[1]
|
|
||||||
break
|
|
||||||
|
|
||||||
# Find full dc and set it as dcfull variable
|
|
||||||
dcfull = ''
|
|
||||||
for i in baselist:
|
|
||||||
if i.split('=')[0] == 'dc':
|
|
||||||
dcfull += ',dc=' + i.split('=')[1]
|
|
||||||
|
|
||||||
for i in basealtlist:
|
|
||||||
if i.split('=')[0] == 'dc':
|
|
||||||
dcfullalt += ',dc=' + i.split('=')[1]
|
|
||||||
|
|
||||||
# Remove first column character
|
|
||||||
dcfull = dcfull[1:]
|
|
||||||
dcfullalt = dcfull[1:]
|
|
||||||
|
|
||||||
# Create organization on LDAP server and store boolean indicating it's success
|
|
||||||
|
|
||||||
rcode1 = self.ldapconnection.add(f'dc={dcfull}', ['dcObject', 'organization'], {'o' : dc, 'dc' : dc})
|
|
||||||
|
|
||||||
if self.alt:
|
|
||||||
rcode2 = self.ldapconnection.add(f'dc={dcfullalt}', ['dcObject', 'organization'], {'o' : dcalt, 'dc' : dcalt})
|
|
||||||
else:
|
|
||||||
rcode2 = True
|
|
||||||
|
|
||||||
# Create organizational units on LDAP server and store boolean indicating it's success
|
# Create organizational units on LDAP server and store boolean indicating it's success
|
||||||
|
|
||||||
rcode3 = self.ldapconnection.add(self.base, ['top', 'organizationalUnit'], {'ou' : organization})
|
rcode2 = self.ldapconnection.add(self.base, ['top', 'organizationalUnit'], {'ou' : self.organization})
|
||||||
|
|
||||||
if self.alt :
|
|
||||||
rcode4 = self.ldapconnection.add(self.basealt, ['top', 'organizationalUnit'], {'ou' : organizationalt})
|
|
||||||
else:
|
|
||||||
rcode4 = True
|
|
||||||
|
|
||||||
|
|
||||||
# Return True only if all return values are true
|
# Return True only if all return values are true
|
||||||
|
|
||||||
return rcode1 and rcode2 and rcode3 and rcode4
|
return rcode1 and rcode2
|
||||||
|
|
||||||
def lastpwchangenow(self):
|
def lastpwchangenow(self):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user