LDAP Password Modify Extended Operation - Data Decoding Error
I'm trying to use LDAPs Password Modify Extended Operation, but I'm having difficulty. I'm hoping someone here can assist. I'm not very familiar with ASN.1 BER encoding, I'm struggling with it. I'm using the JNDI booster pack to handle ASN.1 BER encoding / decoding
http://docs.sun.com/source/816-5618-10/netscape/ldap/ber/stream/package-summary.html
I basically have to send the following request to LDAP:
ExtendedRequest ::= [APPLICATION 23] SEQUENCE{
requestName[0] LDAPOID,
requestValue[1] OCTET STRING OPTIONAL}
The requestName is a dotted-decimal representation of the OBJECT IDENTIFIER corresponding to the request. The requestValue is information in a form defined by that request, encapsulated inside an OCTET STRING.
passwdModifyOID OBJECT IDENTIFIER ::= 1.3.6.1.4.1.4203.1.11.1
The request value is:
PasswdModifyRequestValue ::= SEQUENCE{
userIdentity[0] OCTET STRING OPTIONAL
oldPasswd[1] OCTET STRING OPTIONAL
newPasswd[2] OCTET STRING OPTIONAL}
encapsulated inside an OCTET STRING
This is the code that doesn't work..
publicbyte[] getEncodedValue ()
{
final BERSequence vSeq =new BERSequence();
vSeq.addElement(new BERTag( BERTag.CONTEXT | 0,new BEROctetString( username ),true ) );
vSeq.addElement(new BERTag( BERTag.CONTEXT | 1,new BEROctetString( oldPassword ),true ) );
vSeq.addElement(new BERTag( BERTag.CONTEXT | 2,new BEROctetString( newPassword ),true ) );
final BERSequence seq =new BERSequence();
seq.addElement(new BERTag( BERTag.CONTEXT | 0,new BERObjectId( OID ),true ) );
seq.addElement(new BERTag( BERTag.CONTEXT | 1,new BEROctetString( vSeq.toString() ),true ) );
// ExtendedRequest ::== [APPLICATION 23] SEQUENCE
BERTag extendedRequest =new BERTag( BERTag.APPLICATION | BERTag.CONSTRUCTED | 23, seq,true );
return extendedRequest.toString().getBytes();
}
Any help appreciated,
Thanks
Tony

