python-ldap

Timur Izhbulatov TimurIzhbulatov at oilspace.com
Wed Apr 12 14:29:25 CEST 2006


Michael,

Thanks for answering!

On Fri, Apr 07, 2006 at 11:31:40AM +0200, Michael Ströder wrote:
> Timur Izhbulatov wrote:

> > Also I would like to ask you to pay your attention to the issue I reported some
> > time ago:
> > http://sourceforge.net/tracker/index.php?func=detail&aid=1440151&group_id=2072&atid=102072.

> So if it's urgent for you to get your issue done I'd like to encourage
> you to submit a patch. Even if your patch is not perfect this makes it
> easier for me to start working on it.

My patch for HEAD is attached. And, yes, it's not perfect, just a quick fix. For
example the ldap.ldapobject.SimpleLDAPObject.passwd method still doesn't return
server generated password if the newpw argument is omitted.

> Maybe your requirement could be solved in the Python wrapper module
> ldap.ldapobject. Not sure about it though.

Not only in ldap.ldapobject. The problem is also in Modules/LDAPObject.c: l_ldap_passwd

> Please, stay tuned to the python-ldap-dev mailing list. I'm reading it
> and will answer there. Maybe someone else on the list feels like taking
> over the task.

For those who are interested. More details can be found in my previous report:
http://sourceforge.net/mailarchive/forum.php?thread_id=9546124&forum_id=4346

Cheers,

-- 
Timur Izhbulatov
OILspace, 26 Leninskaya sloboda, bld. 2, 2nd floor, 115280 Moscow, Russia
P:+7 495 105 7245 + ext.205 F:+7 495 105 7246 E:TimurIzhbulatov at oilspace.com
Building Successful Supply Chains - One Solution At A Time.
www.oilspace.com
-------------- next part --------------
diff -urN python-ldap.orig/Lib/ldap/ldapobject.py python-ldap/Lib/ldap/ldapobject.py
--- python-ldap.orig/Lib/ldap/ldapobject.py	2006-04-12 15:41:48.000000000 +0400
+++ python-ldap/Lib/ldap/ldapobject.py	2006-04-12 15:45:57.000000000 +0400
@@ -323,10 +323,10 @@
   def modrdn_s(self,dn,newrdn,delold=1):
     return self.rename_s(dn,newrdn,None,delold)
 
-  def passwd(self,user,oldpw,newpw,serverctrls=None,clientctrls=None):
+  def passwd(self,user=None,oldpw=None,newpw=None,serverctrls=None,clientctrls=None):
     return self._ldap_call(self._l.passwd,user,oldpw,newpw,EncodeControlTuples(serverctrls),EncodeControlTuples(clientctrls))
 
-  def passwd_s(self,user,oldpw,newpw,serverctrls=None,clientctrls=None):
+  def passwd_s(self,user=None,oldpw=None,newpw=None,serverctrls=None,clientctrls=None):
     msgid = self.passwd(user,oldpw,newpw,serverctrls,clientctrls)
     return self.result(msgid,all=1,timeout=self.timeout)
 
diff -urN python-ldap.orig/Modules/LDAPObject.c python-ldap/Modules/LDAPObject.c
--- python-ldap.orig/Modules/LDAPObject.c	2006-04-12 15:41:48.000000000 +0400
+++ python-ldap/Modules/LDAPObject.c	2006-04-12 15:43:22.000000000 +0400
@@ -1177,7 +1177,7 @@
     int msgid;
     int ldaperror;
 
-    if (!PyArg_ParseTuple( args, "s#s#s#|OO", &user.bv_val, &user_len, &oldpw.bv_val, &oldpw_len, &newpw.bv_val, &newpw_len, &serverctrls, &clientctrls ))
+    if (!PyArg_ParseTuple( args, "|z#z#z#OO", &user.bv_val, &user_len, &oldpw.bv_val, &oldpw_len, &newpw.bv_val, &newpw_len, &serverctrls, &clientctrls ))
     	return NULL;
 
     user.bv_len = (ber_len_t) user_len;
@@ -1199,7 +1199,13 @@
     }
 
     LDAP_BEGIN_ALLOW_THREADS( self );
-    ldaperror = ldap_passwd( self->ldap, &user, &oldpw, &newpw, server_ldcs, client_ldcs, &msgid );
+    ldaperror = ldap_passwd( self->ldap,
+            user.bv_val != NULL ? &user : NULL,
+            oldpw.bv_val != NULL ? &oldpw : NULL,
+            newpw.bv_val != NULL ? &newpw : NULL,
+            server_ldcs,
+            client_ldcs,
+            &msgid );
     LDAP_END_ALLOW_THREADS( self );
     
     LDAPControl_List_DEL( server_ldcs );


More information about the python-ldap mailing list