V
V
vlarkanov2019-07-23 15:16:32
linux
vlarkanov, 2019-07-23 15:16:32

Base64 and Active Directory: Why is the Title field not always decoded correctly?

Hello.
I'm using ldapsearch to generate my email signature, it has a Title field.
The request is like this:

title=$(ldapsearch -x -D [email protected] -w <password>"(SAMAccountName=${SAM})" title | grep "title::" | cut -d " " -f2 | base64 -d);

As a result, either post reads correctly:
title:: 0KHQuNGB0YLQtdC80L3Ri9C5INCw0LTQvNC40L3QuNGB0YLRgNCw0YLQvtGA
-------
title = Системный администратор

or wrong:
title:: 0KDRg9C60L7QstC+0LTQuNGC0LXQu9GMINGG0LXQvdGC0YDQsCDRgNCw0LHQvtGC0Ysg0Y
-------
base64: invalid input
title = Руководитель центра работы �

I don't understand what it depends on and how to fix it

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2019-07-23
@vlarkanov

Everything is very simple. The rest is on the next line of ldapsearch's response.

S
Saboteur, 2019-07-23
@saboteur_kiev

Try adding -o ldif-wrap=no

title=$(ldapsearch -o ldif-wrap=no -x -D [email protected] -w "(SAMAccountName=${SAM})" title | grep "title::" | cut -d " " -f2 | base64 -d);

E
Ezhyg, 2019-07-23
@Ezhyg


Doesn't push anything?
Too short, lengthen it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question