directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SudheerKumar <>
Subject How to bind and search binary data in Apache DS?
Date Fri, 27 Feb 2009 12:02:19 GMT

Hi, I am new to LDAP and Apache DS.  Kindly help me solve my problem. 

I have an attribute with binary (m-syntax: as
its type.  This attribute is  added as an attribute to an Object class.  I
tried to bind a String value (xml) to it.  Using the following line of code.  

       String xml = getXml();

				new ModificationItem[] { new ModificationItem(
						DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(
								"myAttributeName", xml)) })

It throws an exception saying: "ERROR Ldap server exception: [LDAP: error
code 80 - OTHER: failed for     Modify Request
        Object :
                Operation :  replace
    myattributeName: '0x3C 0x3F 0x78 0x6D 0x6C 0x20 0x76 0x65 0x72 0x73 0x69
0x6F 0x6E 0x3D 0x22 0x31 ...'
                Operation :  replace
    myattributeNametimestamp: 1233046896765: java.lang.String]
ERROR Failed to save home pages in LDAP."

Converting the String to byte array ( byte[] contentInBytes =
xml.getBytes()) doesn't solve the problem.  Then just for verification I
read a jpeg file using BufferedInputStream and extracted the content to a
byte array. This time it successfully stored the byte array data.  However,
when retrieving the data back, what I am getting is a Char array. Why it
doesn't return a byte array?  How do I store String values in binary format?
Please help.
View this message in context:
Sent from the Apache Directory Project mailing list archive at

View raw message