def _search_ldap(self, ldap, con, username):
        """
            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
        """
        if self.auth_ldap_append_domain:
            username = username + "@" + self.auth_ldap_append_domain
        if self.auth_ldap_search_filter:
            filter_str = "(&%s(%s=%s))" % (
                self.auth_ldap_search_filter,
                self.auth_ldap_uid_field,
                username,
            )
        else:
            filter_str = "(%s=%s)" % (self.auth_ldap_uid_field, username)
        user = con.search_s(
            self.auth_ldap_search,
            ldap.SCOPE_SUBTREE,
            filter_str,
            [
                self.auth_ldap_firstname_field,
                self.auth_ldap_lastname_field,
                self.auth_ldap_email_field,
            ],
        )
        if user:
            if not user[0][0]:
                return None
        return user