0

I'm trying to work out how to escape characters in an ldapsearch password.

With the password set as test!1234 the following works:

ldapsearch -h 127.0.0.1 -x -S 'ou' -D 'administrator' -w 'test!1234'

If I change the password test!'1234 then this doesn't work:

ldapsearch -h 127.0.0.1 -x -S 'ou' -D 'administrator' -w 'test!\'1234'

I get Invalid credentials even though the username and password are correct.

How do escape the ' and any other characters?

Thanks

Tom
  • 1,436
  • 24
  • 50
  • 3
    Does this answer your question? [How to escape single quotes within single quoted strings](https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings) – Gabriel Luci Mar 16 '23 at 16:23

1 Answers1

0

why don't use the variable substitution?

export mypass="test!1234"

ldapsearch -h 127.0.0.1 -x -S 'ou' -D 'administrator' -w $mypass
Ozgur G
  • 26
  • 4