2

I am following the instructions on https://www.openldap.org/doc/admin24/quickstart.html to install OpenLDAP on RedHat. Everything goes fine until step 9:

Import the configuration database You are now ready to import your configration database for use by slapd(8), by running the command:

su root -c /usr/local/sbin/slapadd -n 0 -F /usr/local/etc/slapd.d -l /usr 
/local/etc/openldap/slapd.ldif

Then I get the error: su: invalid option -- 'n' Then I tried only running /usr/local/sbin/slapadd -n 0 -F /usr/local/etc/slapd.d -l /usr/local/etc/openldap/slapd.ldif since I already logged in as the root user, then I get this error:

 5bcca422 invalid config directory /usr/local/etc/slapd.d, error 2
 slapadd: bad configuration directory! 

My installation prefix is the default /usr/local/

I find there is no slapd.d under /usr/local/etc directory. What's the problem? Thanks!

Additional Information: When I ranmake in step 5, I got an error: fatal error:ltdl.h: No such file or directory, then I installed it with yum install libtool-ltdl-devel, and repeated step 5. When I ran make test in step 6, there is no error. I don't know if this piece of additional information could help.

2
  • RHEL already includes OpenLDAP packages. Is there a reason you are rebuilding them from source code? Oct 21, 2018 at 16:34
  • @Michael Hampton Oh...I don't know that it is already in RHEL...I find slapd.d at /etc/openldap...
    – zero_yu
    Oct 21, 2018 at 19:13

3 Answers 3

1

The default location of configuration files is specified as build configuration option --sysconfdir. The default depends on value used for --prefix.

$ ./configure --help
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]

So what's actually used in your case depends on the build configuration.

When starting slapd you can also specify the configuration to be used with command-line options -f for static config or -F for directory holding the dynamic config. This is very handy for using a local test-bed config or to stay away completely from what OS packages mess around during package installation.

The man-page slapd(8) locally installed on your system will show you the actual default values of your build. Bear in mind that man-pages provided by OS packages are different from your local builds from source.

Also I'd recommend not to use the RHEL/CentOS packages. You should use pre-built RPMs provided by LDAP Toolbox project. They use build option --prefix=/usr/local/openldap and therefore dynamic config DB would be in default location /usr/local/openldap/etc/openldap/slapd.d/.

See also: slapd(8)

4
  • Thanks. My prefix is by default /usr/local/, but I did not see slapd.d there.
    – zero_yu
    Oct 22, 2018 at 20:20
  • configure --prefix=/usr/local would result in /usr/local/etc/openldap/slapd.d/ being used by default. As said in my answer: Consult the slapd(8) man-page of your local installation. Oct 22, 2018 at 20:22
  • I tried the command find usr/ -name "slapd.d", there is no slapd.d under usr/ or its subdirectories. However, I found sldap.d under /etc/openldap/. I doubt there is created by the installation of OpenLDAP I downloaded from the official site. Can I use this sldap.d in the command to import the configuration database?
    – zero_yu
    Oct 22, 2018 at 20:37
  • I don't know what happened on your system so far. So I can't tell which path is right. Please make sure to restart from a clean system using well-defined build options or install packages for your OS. Otherwise your results will be unpredictable. Oct 22, 2018 at 20:40
1

To avoid su: invalid option -- 'n' error, you can put quotes as the below:

su root -c '/usr/local/sbin/slapadd -n 0 -F /usr/local/etc/slapd.d -l /usr 
/local/etc/openldap/slapd.ldif'

Notice that I have put the part after -c inside the quotes.

As far as slapd.d is concerned, creating the directory helped me:

sudo mkdir /usr/local/etc/slapd.d

The cli will promptly ask for password. After that, this is what looks like on my console,

_#################### 100.00% eta   none elapsed            none fast!
0

Maybe you can try:mkdir /usr/local/etc/slapd.d

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.