3

I am new to LDAP and OpenLDAP

When running very basic ldapsearch

ldapsearch -H ldap:// -x -s base -b “” -LLL “+”

It returns

ldapsearch: invalid option -- 'H'

in CentOS 7

but if I run

sudo ldapsearch -H ldap:// -x -s base -b “” -LLL “+”

the invalid option error is gone but then it returns

Invalid DN syntax (34)
Additional information: invalid DN

I think it looks like I messed up some of the configuration, all I did was following instruction from this tutorial

Please let me know any extra information i should provide here and how can I resolve the problem. I am really newbie in (Open)LDAP.

UPDATE

Content of /etc/openldap/slapd.d/db.ldif

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=myname,dc=local

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=ldapadm,dc=myname,dc=local

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: {SSHA}123123123123123123123
Dreamer
  • 7,333
  • 24
  • 99
  • 179
  • 1
    It seems you are using left/right double quotation mark to quote your arguments but it's not supported by unix shell quoting mechanism, try using simple or double quotes : `sudo ldapsearch -H ldap:// -x -s base -b '' -LLL '+'` – EricLavault Aug 02 '17 at 16:09
  • @EricLavault awesome, really appreciate your comments and that's exactly the problem! Please make your comment as an answer so I will close this thread. Thanks again ! – Dreamer Aug 02 '17 at 18:19
  • use -h hostname instead, it always works (without ldap:// and a lowercase h) – olivierg Aug 02 '17 at 20:35
  • Note the `-h` option is deprecated in favor of `-H` – EricLavault Aug 02 '17 at 21:16

1 Answers1

3

Left/right double quotation mark “ ” are not supported by unix shell quoting mechanism, you have to use simple or double quotes '' or "" to enclose your arguments.

This should work :

sudo ldapsearch -H ldap:// -x -s base -b '' -LLL '+'

See also the difference between single and double quotes.

EricLavault
  • 12,130
  • 3
  • 23
  • 45