Skip to content

Commit 79f3912

Browse files
author
angeloudy
committedFeb 28, 2020
Escaping special characters
1 parent 0d81dbe commit 79f3912

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎ldap_api/ldap_service.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ldap3
22
from flask import g
33
from ldap3 import BASE, SUBTREE, ALL_ATTRIBUTES, MODIFY_ADD, MODIFY_REPLACE
4-
4+
from ldap3.utils.conv import escape_filter_chars as eb
55

66
class LdapService:
77
SEARCH_LIMIT = 20
@@ -124,7 +124,7 @@ def find_company_entry_by_name(name):
124124
ldap_connection = g.get('ldap_connection')
125125
ldap_connection.search(search_base=LdapService.LDAP_BASES['companies'],
126126
search_scope=SUBTREE,
127-
search_filter=f'(displayName={name})',
127+
search_filter=f'(displayName={eb(name)})',
128128
attributes=ALL_ATTRIBUTES)
129129
return get_first(ldap_connection.response)
130130

@@ -189,6 +189,7 @@ def add_entry(dn, ldap_attributes):
189189

190190
@staticmethod
191191
def search(name, base, get_disabled):
192+
name = eb(name)
192193
ldap_connection = g.get('ldap_connection')
193194
if base == 'companies':
194195
ldap_filter = f'displayName=*{name}*'

0 commit comments

Comments
 (0)
Please sign in to comment.