ldap_passwd.diff
Michael Ströder
michael at stroeder.com
Tue Apr 18 13:18:08 CEST 2006
Timur Izhbulatov wrote:
> On Sun, Apr 16, 2006 at 12:46:44PM +0200, Michael Ströder wrote:
>
>>Timur Izhbulatov wrote:
>>
>>>On Thu, Apr 13, 2006 at 07:47:05PM +0200, Michael Ströder wrote:
>>>
>>>>2. Personally I'd like avoid to turn arguments user,oldpw,newpw of
>>>>passwd() into optional key-word arguments (and we can't do that for only
>>>>user and oldpw, see 1.). I'd rather prefer the application developer to
>>>>really know what he's doing. But I'm open to other opinions.
>>>
>>>In this case the application developer won't be able to do some important
>>>things. For example, changing other users's passwords will be impossible even if
>>>tha application is bound with root DN.
>>
>>The developer could simply pass value None to passwd() for user and oldpw.
>
> Passing None is OK as long as l_ldap_passwd() allows this. So I suggest applying
> my changes only to Modules/LDAPObject.c.
Ok, I've committed the patch below. Please test.
Ciao, Michael
Index: Modules/LDAPObject.c
===================================================================
RCS file: /cvsroot/python-ldap/python-ldap/Modules/LDAPObject.c,v
retrieving revision 1.74
diff -u -r1.74 LDAPObject.c
--- Modules/LDAPObject.c 5 Apr 2006 22:40:14 -0000 1.74
+++ Modules/LDAPObject.c 18 Apr 2006 11:12:24 -0000
@@ -1179,7 +1179,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;
@@ -1201,7 +1201,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