Fix tests and add global option

This commit is contained in:
jorgectf
2021-09-12 20:35:57 +02:00
parent 54012eba23
commit 18b05bc56e
5 changed files with 35 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
import ldap
from flask import request, Flask
app = Flask(__name__)
# GOOD
# SSL through ldap global variable option
ldap.set_option(ldap.OPT_X_TLS_DEMAND)
@app.route("/one")
def one():
ldap_connection_5 = ldap.initialize("ldap://somethingon.theinternet.com")
ldap_connection_5.simple_bind_s('', '')
user = ldap_connection_5.search_s(
"dn", ldap.SCOPE_SUBTREE, "search_filter")
return user
# if __name__ == "__main__":
# app.run(debug=True)

View File

@@ -54,7 +54,7 @@ def one_bad():
@app.route("/one_bad_2")
def one_bad_2():
ldap_connection_4 = ldap.initialize(schema + remote_host)
ldap_connection_4.set_option(ldap.OPT_X_TLS_NEVER)
ldap_connection_4.set_option(ldap.OPT_X_TLS_NEVER, True)
ldap_connection_4.simple_bind_s('', '')
user = ldap_connection_4.search_s(
"dn", ldap.SCOPE_SUBTREE, "search_filter")

View File

@@ -54,7 +54,7 @@ def one_bad():
@app.route("/one_bad_2")
def one_bad_2():
ldap_connection_8 = ldap.initialize(schema + remote_host)
ldap_connection_8.set_option(ldap.OPT_X_TLS_NEVER)
ldap_connection_8.set_option(ldap.OPT_X_TLS_NEVER, True)
ldap_connection_8.simple_bind_s('', '')
user = ldap_connection_8.search_s(
"dn", ldap.SCOPE_SUBTREE, "search_filter")

View File

@@ -13,7 +13,7 @@ full_host = "ldap://somethingon.theinternet.com"
@app.route("/one")
def one():
srv = Server("ldap://somethingon.theinternet.com", port=1337, True)
srv = Server("ldap://somethingon.theinternet.com", 1337, True)
conn = Connection(srv, "dn", "password")
conn.search("dn", "search_filter")
return conn.response