Totally stumped on how to use async.

Ryan Parrish RyanP at foxracing.com
Thu Jan 13 18:39:17 CET 2005


Let me preface by saying that I am kind of a newbie with LDAP.  
Here is my problem, I would like to use python-ldap to query the proxyAddresses on my AD domain controller, and eventually write it out to a file.  But since this is AD I have to limit my queries to under 1000 results.  
I am trying to mimic the functionality of this Perl script http://www-personal.umich.edu/~malth/gaptuning/postfix/getadsmtp.pl

1.) When I use the example on the site for asynchronies queries, I don't get all the results - I get 2000 (which I don't understand why, but there is actually 3106)http://homepage.mac.com/mengelhart/python-ldap-samples.html#search
2.) The way I understand 'retrieveAttribuites' to work would be that I only retrieve one particular attribute for each 'cn', and that is how it appears to work in the 'directoyassist' 3rd party script off the site.  So I figured that I could put ['proxyAddresses'] in there and only receive the proxyAddresses, but when I use anything except None I get no results back.

Here is what I have, it is almost a verbatim copy of the example, if you could just give me some pointers on how to use the async queries I will be on my way. Thanks. 
PS I have tried on both my Linux and win box and get the exact same results.


#!/usr/bin/env python
import ldap
from string import split

try:
    l = ldap.open("10.11.2.33")
    l.simple_bind_s('A user name','*****') 
except ldap.LDAPError, e:
    print e

baseDN = "dc=foxracing,dc=com"
searchScope = ldap.SCOPE_SUBTREE
retrieveAttributes = None
#sizelimit = 990

searchFilter = "(& (mailnickname=*) (| (&(objectCategory=person) \
(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*))) \
(&(objectCategory=person)(objectClass=user)(|(homeMDB=*) \
(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact)) \
(objectCategory=group)(objectCategory=publicFolder) ))"

try:
    ldap_result_id = l.search(baseDN, searchScope, searchFilter, retrieveAttributes)
    while 1:
	result_type, result_data = l.result(ldap_result_id, 0)
	if (result_data == []):
            break
        else:
	    if result_type == ldap.RES_SEARCH_ENTRY:
		for entry in result_data[0][1]['proxyAddresses']:
		    if 'SMTP' in entry:
			email = "%s OK" % (split(entry, ':')[1])
			print email
except ldap.LDAPError, e:
    print e

_-`-_-`-_-`-_-`-_-`-_-`-_-`-_-`-_-`-_

Ryan Parrish
ryanp at foxracing.com
IT Dept.
408-776-8633 extension 1229
Please direct all support questions to -
(¯`·.¸¸.-> itsupport at foxracing.com

_-`-_-`-_-`-_-`-_-`-_-`-_-`-_-`-_-`-_ 





More information about the python-ldap mailing list