ldapsearch does not display non-ASCII characters

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

Issue

ldapsearch does not show the expected values for strings that contain non-ASCII characters.

Example:

Set the following name with ldapmodify:

sn: Tünnerhoff

The ldapsearch will list the following result:

sn:: VMO8bm5lcmhvZmY=

Resolution

Decode the string as base64. For example use a command like this:

$ echo "VMO8bm5lcmhvZmY=" | base64 -d ; echo
Tünnerhoff

If you want to display the string in BASE64 encoding, please use the command below:

ldapsearch -x -LLL  | perl -MMIME::Base64 -MEncode=decode -n -00 -e 's/\n 
+//g;s/(?<=:: )(\S+)/decode("UTF-8",decode_base64($1))/eg;print'

Root Cause

There is no option for ldapsearch to decode the string automatically. ldapsearch would need to know how to display the decoded data, which could be a characterset not supported by the terminal or libraries.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments