CyberNerd Posted December 14, 2006 Posted December 14, 2006 Ages ago I wrote a python program on v2.3 - it works fine. I was re-writing the original program to do something else and I noticed it failed using a newer version of python/python-ldap. I'm not sure why, but would rather update the program than downgrade python module. Any pointers please. :? this works: python-ldap.i386 0:2.0.1-2 python Python 2.3.4 (#1, Oct 11 2006, 06:18:43) [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ldap >>> domain = "example.com" >>> l=ldap.initialize("ldap://server."+domain+":389") >>> l.simple_bind_s("domain\\username","password") >>> this fails: Python-ldap version: 2.0.4-1ubuntu4 Python 2.4.3 (#2, Oct 6 2006, 07:49:22) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ldap >>> domain = "example.com" >>> l=ldap.initialize("ldap://server."+domain+":389") Traceback (most recent call last): File "", line 1, in ? AttributeError: 'module' object has no attribute 'initialize'
Geoff Posted December 14, 2006 Posted December 14, 2006 The ldap.initalise function doesn't exist anymore in the python-ldap module in ubuntu. The function has been renamed to ldap.open().
CyberNerd Posted December 14, 2006 Author Posted December 14, 2006 thanks, but I'm gettign the other errors with ldap.open(). I've got something half working, but how much do these things change in python? is there any way of achieving backwards comatibility other than keeping another install of older versons?
Geoff Posted December 14, 2006 Posted December 14, 2006 No, go read the api documentation for ldap-python and fix your script.
CyberNerd Posted December 14, 2006 Author Posted December 14, 2006 now I'm really confused. "current" documentation is 2004 for v2.03 and states: The following example demonstrates how to open an LDAP server using the ldap module. >>> import ldap >>> l = ldap.initialize("ldap://my-ldap-server.my-domain:389") >>> l.simple_bind_s("","") >>> l.search_s("o=My Organisation, c=AU", ldap.SCOPE_SUBTREE, "objectclass=*") The example (no docs I could find) in the latest python-ldap v2.2.1 also uses ldap.initialize: # Create LDAPObject instance l = ldap.initialize('ldaps://localhost:1636',trace_level=ldapmodule_trace_level,trace_file=ldapmodule_trace_file) # Set LDAP protocol version used l.protocol_version=ldap.VERSION3 # Try a bind to provoke failure if protocol version is not supported l.bind_s('','',ldap.AUTH_SIMPLE) # Close connection l.unbind_s() So is this ldap.initialize problem specific to Ubuntu's implementation?
CyberNerd Posted December 14, 2006 Author Posted December 14, 2006 I just tried the original script on Zenwalk with python 2.4 and python-ldap 2.2.1 and it worked fine. I think this must be a problem with (my) ubuntu 6,06amd64. or the 2.04 version of python-ldap.
Geoff Posted December 14, 2006 Posted December 14, 2006 The LDAP Python homepage is here. http://python-ldap.sourceforge.net/ current docs are here. http://python-ldap.sourceforge.net/docs.shtml
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now