With a little side of applesauce...

Sunday, January 28, 2007

python-ldap: Debugging help

The online docs are incomplete for python-ldap, so I am going to gather some information here, and then submit an additional patch for the documention:

1. ldap.initialize takes not only the URI, but:

Parameters:
uri
LDAP URL containing at least connection scheme and hostport,
e.g. ldap://localhost:389
trace_level
If non-zero a trace output of LDAP calls is generated.
trace_file
File object where to write the trace output to.
Default is to use stdout.
trace_stack_limit
Limit the size of the trace_stack…?


def initialize(uri,trace_level=0,trace_file=sys.stdout,trace_stack_limit=None):
"""
Return LDAPObject instance by opening LDAP connection to
LDAP host specified by LDAP URL

Parameters:
uri
LDAP URL containing at least connection scheme and hostport,
e.g. ldap://localhost:389
trace_level
If non-zero a trace output of LDAP calls is generated.
trace_file
File object where to write the trace output to.
Default is to use stdout.
"""

At this point, I don’t think that OPT_DEBUG_LEVEL has any effect. I have tried the two values that I find specifically related to python-ldap:

l.set_option(ldap.OPT_DEBUG_LEVEL,0)

l.set_option(ldap.OPT_DEBUG_LEVEL,255)

Plus, debugging levels defined within the LDAP C library, (on Ubuntu), and nothing is ever output. It appears that setting the trace_level to a non-zero value gives us the most debugging information. Of course, if I understood C a little better, and could figure out where python-ldap is getting its debugging values, (I assume(d) the LDAP C Library), I might get more satisfactory debugging information about the LDAP session and calls… :-\

No comments: