Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:56:06+00:00 2026-06-12T11:56:06+00:00

This filter works just fine in my LDAP browser by python ldap won’t pick

  • 0

This filter works just fine in my LDAP browser by python ldap won’t pick it up:

(&(!objectClass=computer)(sn=*%s*))

resulting in:

Request Method: GET Request
URL: http://localhost:8000/ldap_find/%D0%B1%D0%BE%D0%BB%D0%BE%D1%82/
Django Version: 1.4
Exception Type: FILTER_ERROR
Exception Value: {'desc': 'Bad search filter'}

here’s the code that does it:

try:
    LDAPClient.connect()
    base = AUTH_LDAP_SEARCH_BASE
    scope = ldap.SCOPE_SUBTREE
    filter = '(&(!objectClass=computer)(sn=*%s*))' % search_string
    result_set = list()
    result = LDAPClient.client.search(base.encode(encoding='utf-8'), scope, filter.encode(encoding='utf-8'),['cn','mail'])
    res_type, res_data = LDAPClient.client.result(result)
    for data in res_data:
        if data[0]:
            result_set.append(data)
    return json.dumps(result_set)
except Exception, e:
    raise e
finally:
    LDAPClient.unconnect()

it works fine with simple filters, like

filter = 'sn=*%s*' % search_string

so I’m guessing this is some kind of escaping of & or something inside ldap lib but can’t find the root yet.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:56:07+00:00Added an answer on June 12, 2026 at 11:56 am

    The search filter syntax is incorrect. Use (&(sn=*%s*)(!(objectClass=computer))). Search filters are well-documented in RFC4511 and RFC4515.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written search view. Which works just fine. Now I want to change
I've created your typical jQuery slider (code from here ). Everything works just fine
I have a criteria query that works just fine. Criteria criteria = getSession().createCriteria(getPersistentClass()); criteria.add(Restrictions.eq(employerId,employerId))
I am sharing objects between different sites using the Django-sites framework. This works fine
Sorry but why can't this work: function filter($var) { return($var['id'] < 4); } $t1
I'm trying to work on this website wherein I need to filter the data
In a few different guises I've asked about this filter on here and WPSE.
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I've this servlet filter servlet called everytime a file from Restricted folder is called.
I wrote this ISAPI filter to rewrite the URL because we had some sites

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.