Preventing LDAP injection

Posted by Matias on Stack Overflow See other posts from Stack Overflow or by Matias
Published on 2010-06-12T13:10:43Z Indexed on 2010/06/12 13:12 UTC
Read the original article Hit count: 551

Filed under:
|
|

I am working on my first desktop app that queries LDAP. I'm working in C under unix and using opends, and I'm new to LDAP. After woking a while on that I noticed that the user could be able to alter the LDAP query by injecting malicious code.
I'd like to know which sanitizing techniques are known, not only for C/unix development but in more general terms, i.e., web development etc.
I thought that escaping equals and semicolons would be enough, but not sure.

Here is a little piece of code so I can make clearer the question:

 String ldapSearchQuery = "(cn=" + $userName + ")";
 System.out.println(ldapSearchQuery); 

Obviously I do need to sanitize $userName, as stated in this OWASP ARTICLE

© Stack Overflow or respective owner

Related posts about security

Related posts about ldap