Results 1 to 3 of 3
Hi,
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-16-2013 #1Just Joined!
- Join Date
- Nov 2012
- Posts
- 8
LDAP - Base64 encoded name - Problem
Hi,
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.
ex:
dn: cn=johnval,ou=DOE,ou=DOE,o=COM
passwordExpirationTime: 20130115191742Z
mail: John.Vallieres-somemail.com
loginGraceRemaining: 6
fullName::Sm9obiBWYWxsacOocmVzCg==
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
isBase64encoded()
so i could do
if ( isBase64encoded($fullName) )then
fullName=`echo $fullname | decode -d`
fi
Any ideas ???
Thank you guyrs
- 01-16-2013 #2Just Joined!
- Join Date
- Nov 2012
- Posts
- 8
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 : w-w-w.fourmilab.ch/webtools/base64/#Download
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
and
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";
fi
So basically you run the command one time and check the last code from $? to know if the command was executed properly or not !
- 01-17-2013 #3Just Joined!
- Join Date
- Nov 2012
- Posts
- 8
I encountered a few problem with the base64-1.5 version...
Since base64 is now part of coreutils bundle you can get it on gnu.org, 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 :
./configure
cd ./lib
make
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.


Reply With Quote
