File: pickle_ldapobject.py

package info (click to toggle)
python-ldap-doc 2.3-2.1
  • links: PTS
  • area: contrib
  • in suites: squeeze
  • size: 200 kB
  • ctags: 121
  • sloc: python: 661; makefile: 44
file content (12 lines) | stat: -rw-r--r-- 409 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
import os,ldap,pickle

temp_file_name = os.path.join(os.environ.get('TMP','/tmp'),'pickle_ldap-%d' % (os.getpid()))

l1 = ldap.ldapobject.ReconnectLDAPObject('ldap://localhost:1390',trace_level=1)
l1.protocol_version = 3
l1.search_s('',ldap.SCOPE_BASE,'(objectClass=*)')

pickle.dump(l1,open(temp_file_name,'wb'))

l2 = pickle.load(open(temp_file_name,'rb'))
l2.search_s('',ldap.SCOPE_BASE,'(objectClass=*)')