Add registration code
This commit is contained in:
parent
9df4ff1af6
commit
a4820fae58
4
adduser
4
adduser
|
@ -33,9 +33,9 @@ else:
|
|||
if interactive:
|
||||
password = os.popen('tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo ""').read()[:-1]
|
||||
print('Password:', password)
|
||||
hashedpassword = os.popen('slappasswd -s ' + password).read()[:-1]
|
||||
else:
|
||||
password = sys.argv[5]
|
||||
hashedpassword = os.popen('slappasswd -s ' + password).read()[:-1]
|
||||
hashedpassword = sys.argv[5]
|
||||
|
||||
|
||||
# Construct LDIF
|
||||
|
|
6
register
6
register
|
@ -9,7 +9,10 @@ class S(BaseHTTPRequestHandler):
|
|||
content_length = int(self.headers['Content-Length'])
|
||||
data = loads(self.rfile.read(content_length).decode('utf-8'))
|
||||
print(data)
|
||||
os.system('adduser ' + data['username'] + ' ' + data['firstname'] + ' ' + data['lastname'] + ' ' + data['email'] + ' ' + data['password'] + ' "' + ldap_pass + '"')
|
||||
if data['code'] != code:
|
||||
return
|
||||
hashedpassword = os.popen('slappasswd -s ' + data['password']).read()[:-1]
|
||||
os.system('adduser ' + data['username'] + ' ' + data['firstname'] + ' ' + data['lastname'] + ' ' + data['email'] + ' ' + hashedpassword + ' "' + ldap_pass + '"')
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/html')
|
||||
|
@ -21,4 +24,5 @@ def run(server_class=HTTPServer, handler_class=S):
|
|||
httpd.serve_forever()
|
||||
|
||||
ldap_pass = input('LDAP password: ')
|
||||
code = input('Registration code: ')
|
||||
run()
|
||||
|
|
Loading…
Reference in a new issue