Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attributes with no escaped characters cause LDAPInvalidFilterError #61

Open
Mr-Reca opened this issue Sep 12, 2023 · 1 comment
Open
Assignees

Comments

@Mr-Reca
Copy link

Mr-Reca commented Sep 12, 2023

Hello,

First of all, thank you so much for the repo. It's really helpful.

I've been trying to use it and I detect that if I run the following code, it will throw ldap3.core.exceptions.LDAPInvalidFilterError

from ms_active_directory import ADDomain
import os

domain = ADDomain(
   "my.domain", ldap_servers_or_uris=["my.domain"]
)
computer_name = os.environ["COMPUTERNAME"]
session = domain.create_session_as_computer(computer_name)
group = session.find_group_by_sam_name('group name (has this)', ["objectSid"])

I figure it out that it throws the exception because of special characters for the LDAP Query Syntax ( and )

I've fixed in my code it using ldap3.utils.conv.escape_filter_chars but I think it should be added in some other functions of your library.

Thank you

@zorn96
Copy link
Owner

zorn96 commented Dec 5, 2023

hi @Mr-Reca !
this seems reasonable - I can add it in. I'll also add a keyword argument to skip escaping in order to facilitate scenarios where people do their own escaping. the LDAP protocol is a little weird/loose on escaping (e.g. commas sometimes need to be escaped but sometimes don't) so I was hesitant to force it

@zorn96 zorn96 self-assigned this Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants