[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Fwd: Re: ldapsearch utf-8 results



Nicolas Cauchie wrote:
> Here's the piece of code I've wrote. It's not complex, but have to think about
> those ":" and "::".
> 
> USER_CITY2="$(ldapsearch -LLL -C -x \
>                 -h $VAR_DC \
>                 -b $VAR_SEARCHBASE \
>                 -D $VAR_BINDER \
>                 -w $VAR_PWBINDER \
>                 '(mail='$USER')' \
>                 l)"
> if [[ $USER_CITY2== *l::* ]]
> then
>     USER_CITY="$(echo "$USER_CITY2" | sed -n -e 's/^.*l:: //p' | base64
> --decode)";
> else
>     USER_CITY="$(echo "$USER_CITY2" | sed -n -e 's/^.*l: //p')";
> fi
> 
> This way, the first command will search the AD the $USER's city and store it
> in $CITY2. If the result contains "::", then I have to decode and if the
> result contains ":", I don't have to decode.
> The final result is stored in $USER_CITY.

Hmm, I think this is the right time again to recommend to use a decent
scripting language with a LDAP module to do searches and convert data. It's
far more efficient and readable.

Ciao, Michael.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature