Novell Home

Search eDirectory using LDAP and Python

From Developer Community

This simple function shows how to search eDirectory for objects. A list of tuples representing each object in the search is returned. Parameters: handle - LDAP connection handle as returned from __connect() (see the related snippet) basedn - string representation of DN where searching should begin filter - string representation for filtering search results (i.e. "objectclass=posixAccount") scope - scope of search to perform, must be one of ldap.SCOPE_SUBTREE, ldap.SCOPE_BASE, or ldap.SCOPE_ONE

Function

import ldap

def __search( handle, basedn, filter, scope=ldap.SCOPE_SUBTREE):
    if not handle:
        return False
    return handle.search_s( basedn, scope, filter )

--Matt Ryan

Novell® Making IT Work As One

© 2008 Novell, Inc. All Rights Reserved.