From: Andrew T. <ajt...@op...> - 2003-05-26 01:09:22
|
It's great to be able to crank out the ldiff data from a running tree using async.LDIFWriter When we do this, s = ldap.async.LDIFWriter( ldap.initialize('ldap://localhost:389'), is it possible to incorporate bind details?? ie, so I can log in as the directory manager and not be restricted by the SIZELIMIT_EXCEEDED cheers, ajt. |
From: <mi...@st...> - 2003-05-26 05:51:09
|
Andrew Thomson wrote: > It's great to be able to crank out the ldiff data from a running tree > using async.LDIFWriter > > When we do this, > > s = ldap.async.LDIFWriter( > ldap.initialize('ldap://localhost:389'), > > is it possible to incorporate bind details?? import ldap,ldap.async f = open('results.ldif','w') l = ldap.initialize('ldap://localhost:389') l.protocol_version = ldap.VERSION3 l.simple_bind_s('cn=Directory Manager','top secret') s = ldap.async.LDIFWriter(l,f) s.startSearch('dc=example,dc=com',ldap.SCOPE_SUBTREE,'(objectClass=*)') s.processResults() Note that this will write the entries in the order they are returned from the server. This is not necessarily the right tree order. > ie, so I can log in as the > directory manager and not be restricted by the SIZELIMIT_EXCEEDED This is a matter of the LDAP server implementation. If the server does not impose any search limits for 'cn=Directory Manager' in the example above you will be able to retrieve all results. Ciao, Michael. |
From: Andrew T. <ajt...@op...> - 2003-05-26 07:40:03
|
Thanks, that's perfect.. one other question if I may.. how can I modify the following, __init__(self, output_file, base64_attrs=None, cols=76, line_sep='\n') output_file file object for output base64_attrs list of attribute types to be base64-encoded in any case cols Specifies how many columns a line may have before it's folded into many lines. line_sep String used as line separator to increase the column length.. some of my entries are wrapping. Regards, ajt. On Mon, May 26, 2003 at 07:50:55AM +0200, Michael Str?der wrote: > Andrew Thomson wrote: > > It's great to be able to crank out the ldiff data from a running tree > > using async.LDIFWriter > > > > When we do this, > > > > s = ldap.async.LDIFWriter( > > ldap.initialize('ldap://localhost:389'), > > > > is it possible to incorporate bind details?? > > import ldap,ldap.async > > f = open('results.ldif','w') > l = ldap.initialize('ldap://localhost:389') > l.protocol_version = ldap.VERSION3 > l.simple_bind_s('cn=Directory Manager','top secret') > s = ldap.async.LDIFWriter(l,f) > s.startSearch('dc=example,dc=com',ldap.SCOPE_SUBTREE,'(objectClass=*)') > s.processResults() > > Note that this will write the entries in the order they are returned from > the server. This is not necessarily the right tree order. > > > ie, so I can log in as the > > directory manager and not be restricted by the SIZELIMIT_EXCEEDED > > This is a matter of the LDAP server implementation. If the server does not > impose any search limits for 'cn=Directory Manager' in the example above > you will be able to retrieve all results. > > Ciao, Michael. > > |
From: <mi...@st...> - 2003-05-26 07:58:42
|
Andrew Thomson wrote: > Thanks, that's perfect.. > > one other question if I may.. how can I modify the following, > > __init__(self, output_file, base64_attrs=None, cols=76, line_sep='\n') Funny you ask for that. In this minute I've checked in a new version which lets you pass in either a ldif.LDIFWriter instance instead or a file-like object. Give it a try: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python-ldap/python-ldap/Lib/ldap/async.py > cols > Specifies how many columns a line may have before it's > folded into many lines. > > to increase the column length.. some of my entries are wrapping. You really should use a LDIF consumer which correctly processes folded lines (see RFC 2849). Ciao, Michael. |
From: Andrew T. <ajt...@op...> - 2003-05-26 07:47:06
|
Michael, You'll hate me, but any updates on this? ;) "The following example demonstrates how to parse an LDIF file with ldif module. To do... " (http://python-ldap.sourceforge.net/doc/python-ldap/ldif-example.html) regards, ajt. On Mon, May 26, 2003 at 07:50:55AM +0200, Michael Str?der wrote: > Andrew Thomson wrote: > > It's great to be able to crank out the ldiff data from a running tree > > using async.LDIFWriter > > > > When we do this, > > > > s = ldap.async.LDIFWriter( > > ldap.initialize('ldap://localhost:389'), > > > > is it possible to incorporate bind details?? > > import ldap,ldap.async > > f = open('results.ldif','w') > l = ldap.initialize('ldap://localhost:389') > l.protocol_version = ldap.VERSION3 > l.simple_bind_s('cn=Directory Manager','top secret') > s = ldap.async.LDIFWriter(l,f) > s.startSearch('dc=example,dc=com',ldap.SCOPE_SUBTREE,'(objectClass=*)') > s.processResults() > > Note that this will write the entries in the order they are returned from > the server. This is not necessarily the right tree order. > > > ie, so I can log in as the > > directory manager and not be restricted by the SIZELIMIT_EXCEEDED > > This is a matter of the LDAP server implementation. If the server does not > impose any search limits for 'cn=Directory Manager' in the example above > you will be able to retrieve all results. > > Ciao, Michael. > > |
From: <mi...@st...> - 2003-05-26 08:03:19
|
Andrew Thomson wrote: > > You'll hate me, but any updates on this? ;) > > "The following example demonstrates how to parse an LDIF file with ldif > module. > > To do... Unfortunately no. Feel free to submit a patch for the docs... Actually it's quite simple though. Ciao, Michael. |
From: Andrew T. <ajt...@op...> - 2003-05-27 03:04:33
|
any tips today? ;) --- import ldif f = open('data.ldiff','r') records = ldif.LDIFRecordList(f) data = records.parse() --- thanks, ajt. |
From: <mi...@st...> - 2003-05-27 08:34:05
|
Andrew Thomson wrote: > any tips today? ;) Let's see... ;-) > --- > import ldif > > f = open('data.ldiff','r') > > records = ldif.LDIFRecordList(f) > data = records.parse() > --- This parses the whole input file and stores the data into a list in memory which might not be suitable for very large LDIF files. For stream-processing large LDIF files you simply have to sub-class ldif.LDIFParser and implement the method handle(self,dn,entry). Ciao, Michael. |