Very strange problem with module ldapurl

Jens Vagelpohl jens at zope.com
Fri Sep 6 21:54:11 CEST 2002


i just got confirmation from someone here at zope corp who knows these  
things better that...

- in general, it is better to avoid mutable default values in an  
argument list for a method

- the fact that the LDAPUrlExtensions-constructor was part of the  
arguemnt list would actually give you the very same object every single  
time.

jens


On Friday, Sep 6, 2002, at 14:27 US/Eastern, Michael Ströder wrote:

> HI!
>
> I have a very strange problem with ldapurl (my own source, sigh!)  
> which can also be a security problem in case of passwords stored in  
> LDAPUrlExtension instances. It drives me crazy!
>
> See this simple source:
>
> ------------------------ snip ------------------------
> from ldapurl import LDAPUrl,LDAPUrlExtension
>
> l1=LDAPUrl()
> l1.hostport='host1'
> l1.who='cn=User1'
> l1.cred='passwd1'
> l1.extensions['dummyext1']=LDAPUrlExtension(
>   extype='dummyext1',exvalue='dummyvalue1'
> )
>
> print 'l1 before creation of l2:\n',str(l1)
>
> l2=LDAPUrl()
> l2.hostport='host2'
> l2.who='cn=User2'
> l2.cred='passwd2'
> l2.extensions['dummyext2']=LDAPUrlExtension(
>   extype='dummyext2',exvalue='dummyvalue2'
> )
>
> print 'l1 after creation of l2:\n',str(l1)
> print 'l2 itself:\n',str(l2)
> ------------------------ snip ------------------------
>
> In theory l1 and l2 should be completely independent LDAPUrl  
> instances. But it seems the LDAPUrl.extensions class attributes are  
> tied by some means.
>
> The problem is the output (with Python 2.2.1):
>
> $ python Tests/ldapurl_instance_error.py
> ldap://host1/ 
> ????dummyext2=dummyvalue2,dummyext1=dummyvalue1,bindname=cn=User2,X- 
> BINDPW=passwd2
> ldap://host2/ 
> ????dummyext2=dummyvalue2,dummyext1=dummyvalue1,bindname=cn=User2,X- 
> BINDPW=passwd2
>
> Anybody here having a clue?
>
> Ciao, Michael.






More information about the python-ldap mailing list