I use asn1c to parse the LDAP messages.
For this purpose, after compiling the ASN.1 Definition defined in rfc4511, I use the ber_decode and xer_fprint functions for decoding and printing content in my program.
For example, the two outputs indicated below are related to two different LDAP messages:
<LDAPMessage>
<messageID>1</messageID>
<protocolOp>
<bindRequest>
<version>3</version>
<name>75 69 64 3D 61 2C 64 63 3D 63 6F 6D</name>
<authentication>
<simple>70 61 73 73 77 6F 72 64</simple>
</authentication>
</bindRequest>
</protocolOp>
</LDAPMessage>
<LDAPMessage>
<messageID>5</messageID>
<protocolOp>
<searchRequest>
<baseObject></baseObject>
<scope><baseObject/></scope>
<derefAliases><neverDerefAliases/></derefAliases>
<sizeLimit>0</sizeLimit>
<timeLimit>0</timeLimit>
<typesOnly><true/></typesOnly>
<filter>
<present>4F 62 6A 65 63 74 43 6C 61 73 73</present>
</filter>
<attributes>
<selector>31 2E 31</selector>
</attributes>
</searchRequest>
</protocolOp>
</LDAPMessage>
As you can see, the values for the name, simple, present and selector fields are displayed as hexadecimal. While I want them displayed as human readable values (similar to what wireshark does).
second message on the wireshark (present field have ObjectClass Value)
I know that the same question was asked in this link (decoding asn.1 compiler output as strings). Lev Walkin said that OCTET STRING should be replaced with IA5String or UTF8String. But in LDAP ASN.1 Definition, OCTET STRING has been used in many places.
Which one should I change? Is my perception of replacing OCTET STRING with IA5String or UTF8String correct? Should this be done in LDAP ASN.1 Definition or elsewhere? Is there any problem with changing the LDAP standard definition? for example I only changed LDAPDN :: = LDAPString
to LDAPDN :: = UTF8String
, but I encountered an error in the ber_decode function.
What is the general solution for displaying all values in human readable?
Thanks ...