+ Post New Thread
Results 1 to 7 of 7
Coding Thread, Python LDAP module version problem in Coding and Web Development; Ages ago I wrote a python program on v2.3 - it works fine. I was re-writing the original program to ...
  1. #1


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Python LDAP module version problem

    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

    Code:
    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

    Code:
    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 "<stdin>", line 1, in ?
    AttributeError: 'module' object has no attribute 'initialize'

  2. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Python LDAP module version problem

    The ldap.initalise function doesn't exist anymore in the python-ldap module in ubuntu. The function has been renamed to ldap.open().

  3. #3


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Re: Python LDAP module version problem

    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?

  4. #4

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Python LDAP module version problem

    No, go read the api documentation for ldap-python and fix your script.

  5. #5


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Re: Python LDAP module version problem

    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?

  6. #6


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Re: Python LDAP module version problem

    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.

  7. #7

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Python LDAP module version problem

    The LDAP Python homepage is here.

    http://python-ldap.sourceforge.net/

    current docs are here.

    http://python-ldap.sourceforge.net/docs.shtml

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 13th August 2009, 12:56 PM
  2. Module raid 456 error
    By TechMonkey in forum *nix
    Replies: 1
    Last Post: 26th November 2007, 04:32 PM
  3. IE 7.0 ROK Slideshow Module in Joomla. CSS / IE Problem
    By bensewell in forum Web Development
    Replies: 0
    Last Post: 6th September 2007, 01:47 PM
  4. Replies: 9
    Last Post: 22nd February 2007, 05:49 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •