LDIF Generation using Python-LDAP

Guruprasad lgp171188 at gmail.com
Sat May 16 14:47:27 CEST 2009


Hi,

2009/5/16 Michael Ströder <michael at stroeder.com>:
> Guruprasad wrote:
>> Hi,
>> I tried generating a LDIF file from a dictionary using 'ldif' module
>> as illustrated in http://www.python-ldap.org/doc/html/ldif.html. But
>> at the end of the LDIF data, I get a newline and a 'None', whereas
>> there is no such thing in the result shown in that example. How to get
>> rid of those unwanted characters. I am using Python-LDAP 2.3.5-1 on
>> Debian Lenny.
>
> Could you please post your code (in a short form) demonstrating the
> issue? Note that there is a new-line after each entry record. But was
> 'None' is in your case is not clear to me.
>

Basically what I am trying to do with this code is that, I manipulate
the result returned by ldapsearch to remove some attributes and
generate a LDIF output for the modified entry.

<code>
        res_type, result_data=l.result(res_id,0)
        if (result_data==[]):
            break
        dn=result_data[0][0]
	resd=result_data[0][1]
        resd["objectClass"].remove("inetLocalMailRecipient")
	    resd["objectClass"].remove("organizationalPerson")
	    resd["objectClass"].remove("inetOrgPerson")
        resd["objectClass"].remove("posixAccount")
        lw=ldif.LDIFWriter(sys.stdout)
	guru=lw.unparse(dn,resd)
	print guru
</code>

Is it some issue or am I making some mistakes with general usage of Python?

Thank you.

Regards,
L.Guruprasad



More information about the python-ldap mailing list