[python-ldap] syncrepl.py demo not picking up changes that happened while disconnected

Petr Spacek pspacek at redhat.com
Thu Apr 23 11:47:01 CEST 2015


On 22.4.2015 21:53, Thomas Cort wrote:
> Hello,
> 
> The syncrepl feature is really compelling; I can write a python program
> that can react to changes in the LDAP directory.
> 
> I'm working on a prototype using the demo (Demo/pyasn1/syncrepl.py), and
> I'm running into a bit of a problem (maybe it's a problem with my
> understanding?). I do an initial sync, kill the python script, make a
> modification in ldap, restart the python script, and I expect it to get
> the change that happened while it was disconnect. Unfortunately, I don't
> see any indication that it discovers/gets the change. Is it a bug or am
> I missing something?
> 
> The server is running OpenLDAP 2.4.33. Here's exactly what I'm doing....
> 
> $ sudo pip install python-ldap pyasn1
> 
> $ curl
> https://pypi.python.org/packages/source/p/python-ldap/python-ldap-2.4.19.tar.gz
> | tar zvxf -
> 
> $ cd python-ldap-2.4.19/Demo/pyasn1/
> 
> $ python syncrepl.py
> 'ldap://server.example.com/dc=2,dc=foobar?*?sub?(objectClass=*)?bindname=cn=thomasc%2cdc=2%2cdc=foobar,X-BINDPW=topSecret'
> db.shelve
> 
> Connecting to LDAP server now...
> Commencing sync process
> Detected add of entry: dc=2,dc=foobar
> ...
> Detected add of entry: cn=test01,dc=2,dc=foobar
> ...
> Initial synchronization is now done, persist phase begins
> Detected modify of entry: cn=test01,dc=2,dc=foobar                 # I
> made a change in LDAP
> ...
> ^CShutting down!                      # I killed the script with Ctrl+C
> 
>   # Once killed, I made more changes in LDAP and then restarted the script.
> 
> $ python syncrepl.py
> 'ldap://server.example.com/dc=2,dc=foobar?*?sub?(objectClass=*)?bindname=cn=thomasc%2cdc=2%2cdc=foobar,X-BINDPW=topSecret'
> db.shelve
> 
> Connecting to LDAP server now...
> Commencing sync process
>              # I expect to see "Detected modify of entry" come up somewhere
> Initial synchronization is now done, persist phase begins

Interesting, it works for me just fine on Fedora 21 against LDAP server
389-ds-base-1.3.3.8-1.fc21.x86_64.

Technically the 'cookie' value needs to be stored somewhere and used after
re-connecting to LDAP.

I can see that you are calling the demo script but not using the python-ldap
version from tarball, I'm not sure if it could cause the problem or not.

Try this:
$ export PYTHONPATH=/tmp/python-ldap-2.4.19/Lib
$ cd /tmp/python-ldap-2.4.19/Demo/pyasn1/
...

Also, check ACL on LDAP server. Maybe syncrepl is not allowed for the BIND DN
you are using or something like that.

I hope this helps.

-- 
Petr Spacek  @  Red Hat


More information about the python-ldap mailing list