escape_dn_chars

Michael Ströder michael at stroeder.com
Thu Dec 2 21:38:36 CET 2004


Bertrand Croq wrote:
>   I wasn't able to find a function to escape chars in DN strings, so I
> wrote this one (based on escape_filter_chars):
> 
> def escape_dn_chars(s):
> 	s = s.replace('\\', r'\5C')
> 	s = s.replace(',', r'\2C')
> 	s = s.replace('=', r'\3D')
> 	s = s.replace('+', r'\2B')
> 	return s
> 
> Feel free to use/modify it in python-ldap (license: PSFL, as
> python-ldap)

Thanks for contributing it. I've added a new function 
ldap.dn.escape_dn_chars() in a new sub-module ldap.dn to CVS. It was 
taken from web2ldap which also handles two special cases with # as first 
char and a trailing space.

Please test!

Ciao, Michael.



More information about the python-ldap mailing list