Focus on creating a VPN as a first test case
This commit is contained in:
parent
13292db39e
commit
315aaded41
3 changed files with 106 additions and 7 deletions
25
ldaptest.py
25
ldaptest.py
|
|
@ -1,8 +1,27 @@
|
|||
import ldap3
|
||||
from ldap3 import Server, Connection, ObjectDef, Reader, ALL
|
||||
import os
|
||||
import sys
|
||||
|
||||
server = Server("ldaps://ldap1.ungleich.ch")
|
||||
conn = Connection(server, 'cn=Nico Schottelius,ou=users,dc=ungleich,dc=ch', os.environ['PW'], auto_bind=True)
|
||||
def is_valid_ldap_user(username, password):
|
||||
server = Server("ldaps://ldap1.ungleich.ch")
|
||||
is_valid = False
|
||||
|
||||
print(conn)
|
||||
try:
|
||||
conn = Connection(server, 'cn={},ou=users,dc=ungleich,dc=ch'.format(username), password, auto_bind=True)
|
||||
is_valid = True
|
||||
except Exception as e:
|
||||
print("user: {}".format(e))
|
||||
|
||||
try:
|
||||
conn = Connection(server, 'uid={},ou=customer,dc=ungleich,dc=ch'.format(username), password, auto_bind=True)
|
||||
is_valid = True
|
||||
except Exception as e:
|
||||
print("customer: {}".format(e))
|
||||
|
||||
|
||||
return is_valid
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(is_valid_ldap_user(sys.argv[1], sys.argv[2]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue