def _search_ldap(self, ldap, con, username):
if self.auth_ldap_append_domain:<EOL><INDENT>username = username + "<STR_LIT:@>" + self.auth_ldap_append_domain<EOL><DEDENT>if self.auth_ldap_search_filter:<EOL><INDENT>filter_str = "<STR_LIT>" % (<EOL>self.auth_ldap_search_filter,<EOL>self.auth_ldap_uid_field,<EOL>username,<EOL>)<EOL><DEDENT>else:<EOL><INDENT>filter_str = "<STR_LIT>" % (self.auth_ldap_uid_field, username)<EOL><DEDENT>user = con.search_s(<EOL>self.auth_ldap_search,<EOL>ldap.SCOPE_SUBTREE,<EOL>filter_str,<EOL>[<EOL>self.auth_ldap_firstname_field,<EOL>self.auth_ldap_lastname_field,<EOL>self.auth_ldap_email_field,<EOL>],<EOL>)<EOL>if user:<EOL><INDENT>if not user[<NUM_LIT:0>][<NUM_LIT:0>]:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>return user<EOL>
Searches LDAP for user, assumes ldap_search is set.

:param ldap: The ldap module reference
:param con: The ldap connection
:param username: username to match with auth_ldap_uid_field
:return: ldap object array