Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question LDAP - Base64 encoded name - Problem


    I am trying to build a expired password notification script that alerts users thru mails. For this, i am scanning the ldap with ldapsearch.

    I store the results in a file. I have a problem with the punctuation (accents ) in the name of some user.

    dn: cn=johnval,ou=DOE,ou=DOE,o=COM
    passwordExpirationTime: 20130115191742Z
    loginGraceRemaining: 6

    So instead of having a regular name in the fullName field... I have a base64 encoded name.

    So if i use the fullName field to generate my email the user actually gets garbage instead of his real name...

    I found how to decode the fullName field :

    echo fullName | base64 -d

    With this command i would get this result:
    John Vallières

    My interrogation is how to validate if the fullName is encoded in base64 or not ? I can't pass everything in base64 decode since some fullName already show correctly...

    I would require some method like

    so i could do

    if ( isBase64encoded($fullName) )then
    fullName=`echo $fullname | decode -d`

    Any ideas ???

    Thank you guyrs

  2. #2
    Found a solution !

    i had to install base64 command to SuSE linux since it is not part of coreutils like some other distros.

    Found a place to download it :

    ps : remove the - - between w... i did this because i can't add links here

    When you have the file, you need to extract it:
    tar -zxvf base64-1.5.tar.gz

    You will need to have gcc compiler and his dependencies in order to compile base64 for your distros.
    when you have the compiler....

    do : ./configure
    make install

    then you have the base64 command

    Now to determine if a string was base64, i had to execute the command one time and send the result to dev//null

    echo $name| base64 -d >/dev/null 2>&1;
    if [ $? == 0 ]; then
    name=`echo $name | base64 -d`
    echo "This name has punctuation (accents): $name";

    So basically you run the command one time and check the last code from $? to know if the command was executed properly or not !

  3. #3
    I encountered a few problem with the base64-1.5 version...

    Since base64 is now part of coreutils bundle you can get it on, i had to find a way to install only one app out of coreutils.

    so to build only the base64 out of coreutil
    you need to do :
    cd ./lib
    cd ../src
    make version.h
    make base64

    Then move your base64 compiled apps into your apps location.
    Last edited by Anto28; 01-18-2013 at 04:40 PM.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts