Sudheer Kumar wrote:
Hi, I am new to LDAP and Apache DS. Kindly help me solve my problem.
I have an attribute with binary (m-syntax: 1.3.6.1.4.1.1466.115.121.1.5) as
its type. This attribute is added as an attribute to an Object class. I
tried to bind a String value (xml) to it.
It can't work. Your attribute is binary, there are no conversion done on
the client side.
Converting the String to byte array ( byte[] contentInBytes =
xml.getBytes()) doesn't solve the problem.
Can you post the code where you do this transformation ? Here is a test
we use to check that we can inject binary attributes :
/**
* Add a new attribute to a person entry.
*/
@Test
public void testAddNewBinaryAttributeValue() throws Exception
{
DirContext ctx = ( DirContext ) getWiredContext( ldapService
).lookup( BASE );
// Add a binary attribute
byte[] newValue = new byte[]{0x00, 0x01, 0x02, 0x03};
Attributes attrs = new BasicAttributes(
"userCertificate;binary", newValue, true );
ctx.modifyAttributes( RDN_TORI_AMOS, DirContext.ADD_ATTRIBUTE,
attrs );
// Verify, that attribute value is added
attrs = ctx.getAttributes( RDN_TORI_AMOS );
Attribute attr = attrs.get( "userCertificate" );
assertNotNull( attr );
assertTrue( attr.contains( newValue ) );
byte[] certificate = (byte[])attr.get();
assertTrue( Arrays.equals( newValue, certificate ) );
assertEquals( 1, attr.size() );
}
}
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org