Oops.. you're right, that worked.  I thought the Dn used to establish the 
connection object would be the entry changed on by the ModifyRequest. 
Works as advertised. Thanks!!


-----Original Message-----
From: Emmanuel Lécharny [mailto:[email protected]] 
Sent: Sunday, February 03, 2013 9:25 PM
To: [email protected]
Subject: Re: Trying to change password with Modify Request, 'Server will 
disconnect' LdapException thrown.

Le 2/4/13 3:05 AM, Emmanuel Lécharny a écrit :
> Le 2/3/13 11:28 PM, [email protected] a écrit :
>>                                 Entry entry = connection.lookup(dn);
>>               Attribute at = entry.get("userPassword");
>>               Modification mod = new DefaultModification( 
>> ModificationOperation.REPLACE_ATTRIBUTE, at);
>>
>>                      ModifyRequest modRequest = new ModifyRequestImpl();
>>                      PasswordPolicy ctrl = new PasswordPolicyImpl();
>>                      modRequest.addControl(ctrl);
>>                      modRequest.addModification(mod);
>>                      ModifyResponse modResponse = 
>> connection.modify(modRequest); // exception thrown here..
> I can reproduce the error. It seems that the request does not even get 
> to the server, it's likelly an error while encoding the request.
>
> I'm invstigating it, looks like a bug in the Client API. More to come later.
>
Ok, not really a bug, but still, the error message is clearly not helping...

You havent set the MeodifyRequest's DN, so the encoding fails (NPE when trying 
to encode the modifyRequest, because the DN is null).

Adding :

    modRequest.setName( dn );

solve the issue.


However, this is really not the right way to handle the NPE : we should 
generate a decent error. I'll modify the client API so that such a NPE can't 
occur.

--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 

Reply via email to