This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Summary

ldap_paged_search is a python library to easily perform LDAP queries with more than 1000 results, or to break down queries into smaller result sets to reduce server loads.

Many LDAP servers, such as active directory, will not return more than 1000 results unless paged requests are used. The existing python ldap library does support pageing, but requires some not very intuitive coding to perform it. This library is simply a wrapper to make paged searches easy.

Its interface is also slightly easier to perform queries than the LDAP library it wraps.

Requirements

  • Tested on python 2.8
  • Default python library includes ldap library

Installation

Via pip or easy_install

$ sudo pip install ldap_paged_search   # If you prefer PIP

$ sudo easy_install ldap_paged_search  # If you prefer easy_install

Manual installation

$ git clone https://github.com/neoCrimeLabs/python-ldap_paged_search.git
$ cd python-ldap_paged_search
$ sudo python setup.py install

Usage

Initial setup

from ldap_paged_search import LdapPagedSearch

# Required values
url             = 'ldap://your.ldap.server'
username        = 'username'      # for anything but active directory
username        = 'domain\\user'  # for active directory
password        = 'yourPassword'

baseDN          = 'dc=company,dc=com'
searchFilter    = '(&(objectCategory=user))'

# Optional values
maxPages        = 0     # 0 = everything
maxPages        = 10    # Return first 10 pages only

attributes      = ['*']                         # Return all fields
attributes      = ['FieldName', 'AnotherField'] # Return specific fields only


pageSize        = 1000  # How many records per page
                        # Usual max is 1000; check your LDAP server docs

Defining a callback method

# Using a callback method to process results uses less memory on large queries
# Not using a callback search() will return all results as a single list

def myCallback(dn,record):
    print dn, record

Query using ‘with’

# maxPages, pageSize, attributes, and callback are all OPTIONAL

with LdapPagedSearch(url, username, password, maxPages=2, pageSize=2 ) as l:
    results = l.search(baseDN, searchFilter, attributes = attributes, callback = myCallback)

Alternative query method

# maxPages, pageSize, attributes, and callback are all OPTIONAL

l = LdapPagedSearch(url, username, password, maxPages=2, pageSize=2 )
results = l.search(baseDN, searchFilter, attributes = attributes, callback = myCallback)

Results format

# If you don't set a callback, your results will be returned as follows

[
    ('DistinctName1',
        {  'FieldName':    ['value1', 'value2'],
           'AnotherField': ['value'], }),
    ('DistinctName2',
        {  'FieldName':    ['value1', 'value2'],
           'AnotherField': ['value'], }),
    ...
]

Conditions of Use

I wrote this library for my own use, but realized others may find it useful as there were many forum topics describing this problem.

Unfortunately I cannot guarentee any active support, but will do my best as time permits. That said, I’ll happily accept push requests with suitable changes that address the general audience of this library.

Put simply, use this at your own risk. If it works, great! If not, I may not be able to help you. If you fix anything, however, please push it back and I’ll likely accept it. :-)

Also, if you use this library in your package, tool, or comercial software, let me know, and I’ll list it here!

Release History

Release History

0.4.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ldap_paged_search-0.4.2.tar.gz (14.2 kB) Copy SHA256 Checksum SHA256 Source Oct 3, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting