Added ldapsss vef

This commit is contained in:
Charles d'Hondt 2017-04-28 17:00:21 +02:00
parent 6d3837fd54
commit 65202f5f1c
2 changed files with 10 additions and 2 deletions

View File

@ -112,7 +112,7 @@ class ProxyAuth:
password,
auto_bind=True)
if conn:
conn.search(parts[1][1:], '('+parts[0]+username+')', attributes=['objectclass'])
conn.search(parts[1][1:], '(' + parts[0] + username + ')', attributes=['objectclass'])
if ctx.options.proxyauth.split(":")[3] in conn.entries[0]['objectclass']:
return username, password
@ -156,6 +156,10 @@ class ProxyAuth:
server = ldap3.Server(parts[1], use_ssl=True)
elif parts[0] == "ldap":
server = ldap3.Server(parts[1])
else:
raise exceptions.OptionsError(
"Invalid ldap specfication on the first part"
)
self.ldapserver = server
else:
parts = ctx.options.proxyauth.split(':')

View File

@ -46,8 +46,12 @@ def test_configure():
assert up.ldapserver
ctx.configure(up, proxyauth="ldaps:ldap.forumsys.com:uid=?,dc=example,dc=com:person")
assert up.ldapserver
with pytest.raises(exceptions.OptionsError):
ctx.configure(up, proxyauth="ldapldap.forumsys.com:uid=?dc=example,dc=com:person")
ctx.configure(up, proxyauth="ldap:ldap.forumsys.comuid=?dc=example,dc=com:person")
with pytest.raises(exceptions.OptionsError):
ctx.configure(up, proxyauth="ldapssssssss:ldap.forumsys.com:uid=?,dc=example,dc=com:person")
with pytest.raises(exceptions.OptionsError):
ctx.configure(