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

Help: how to modify ldap filter within handleBeforeForwardRequest #221

Open
resposit opened this issue Dec 3, 2020 · 3 comments
Open

Help: how to modify ldap filter within handleBeforeForwardRequest #221

resposit opened this issue Dec 3, 2020 · 3 comments

Comments

@resposit
Copy link

resposit commented Dec 3, 2020

Hello,
I'm trying to implement a custom LDAP proxy server that gets a searchRequest from a client, inspect the request and possibly modify the search flter before sending it to the proxied server.
For example, if the client sends a searchRequest with filter '(a=b)', the proxy should modify this filter to '(&(a=b)(c=d))' and send it to the proxied server.
When I override the handleBeforeForwardRequest (of the ProxyBase class), it seems the filter string has already been parsed and the request object contains a pureldap filter object which I don't quite understand how can be modified.
Having a string filter would be much easier.
Any suggestions ?

Thanks

@resposit resposit changed the title Modify ldap filter within handleBeforeForwardRequest Help: how to modify ldap filter within handleBeforeForwardRequest Dec 3, 2020
@resposit resposit closed this as completed Dec 3, 2020
@resposit
Copy link
Author

resposit commented Dec 3, 2020

I think I just found the answer myself, using the .asText() method.
Sorry about that.

@resposit resposit reopened this Dec 3, 2020
@resposit
Copy link
Author

resposit commented Dec 3, 2020

Apparently I'm not yet able to use the asText() method within handleBeforeForwardRequest()
due to bytes/string conversion:

The request filter I'm getting is:

x = LDAPFilter_equalityMatch(attributeDesc=BEROctetString(value=b'attribute'), assertionValue=BEROctetString(value=b'value'))

when I try x.asText() I get:

----> 1 x.asText()

/usr/local/lib/python3.6/site-packages/ldaptor/protocols/pureldap.py in asText(self)
590 + "="
591 + self.escaper(self.assertionValue.value)
--> 592 + ")"
593 )

Any ideas ?

@dagmoller
Copy link

Apparently I'm not yet able to use the asText() method within handleBeforeForwardRequest() due to bytes/string conversion:

The request filter I'm getting is:

x = LDAPFilter_equalityMatch(attributeDesc=BEROctetString(value=b'attribute'), assertionValue=BEROctetString(value=b'value'))

when I try x.asText() I get:

----> 1 x.asText()

/usr/local/lib/python3.6/site-packages/ldaptor/protocols/pureldap.py in asText(self) 590 + "=" 591 + self.escaper(self.assertionValue.value) --> 592 + ")" 593 )

Any ideas ?

Any solutions for that?

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