slapd.conf openldap error 21

If you see error 21 in openldap ldapadd, ldapmodify, etc commands, first ensure that you don’t have trailing and leading spaces.
I was thinking that it concerns only your .ldif files, f.ex. configuration of your groups, etc. But still I had 21 error and could not understood why it is occurs.
Later I find out that I had trailing whitespace in slapd.conf. What was strange for me is how slapd service starts if it experience problem with configuration file.

BTW – if you don’t have any editor on your linux server, but “vi” or “vim” you can look for whitespaces with next commands:

– to highlight all tabs

– to highlight spaces

To make “vi” editor highlight your search strings, use “:set hlsearch” command