OpenLDAP How To (Fedora)

This tutorial explains how you can set up centralised LDAP authentication for a network, covering both the setting up of the LDAP server and client. Whilst based on Fedora 13, it may also apply to other versions.

That’s right, Fedora 13, so I haven’t tested this on Fedora 19 or 20… many things have changed, but something might still be useful.

LDAP stands for Lightweight Directory Access Protocol, which is a computer protocol for querying and modifying a database backed directory service. While Fedora ships its own LDAP based server (389 Directory Server), we will be using the OpenLDAP implementation, with Berkley Database (bdb) as the database backend. Data is entered into the LDAP server via plain text LDIF (LDAP Data Interchange Format) files. We will use a set of perl scripts from the migrationtools package to create most of these for us, but we will also create a few manually for adding a new user and group.

Finally, there are probably better (and more Fedora-specific) ways to do some of these tasks. If so, please let me know!

Note: For the purposes of this how to, our domain is test.lan and our LDAP server is server.test.lan – replace this with your server details instead!


The outline of steps is as follows:

  • Install required packages.
  • Configure the LDAP server configuration file for our domain, test.lan (dc=test,dc=lan).
  • Configure the LDAP server to use TLS encryption, using a self-signed certificate.
  • Start the LDAP server and test.
  • Create LDIF files of our base domain, users and groups using migration tools.
  • Populate the LDAP server using LDIF files.
  • Configure clients to authenticate to LDAP server over secure channel.
  • Configuring password policy (contributed by Sunil Tumma).


This how to assumes you have performed a standard Fedora install, or a base install with relevant configuration tools installed.

  • Networking is configured (see below).
  • DNS is working, or at least you can resolve the LDAP server’s FQDN (fully qualified domain name), i.e. server.test.lan.
  • You have the (awesome) text editor vim installed (if not, substitute and edit as required).

Disable NetworkManager

First, you may wish to use standard network configuration rather than NetworkManager on the server.

If so, let’s become root, disable NetworkManager and tell it to not start automatically on boot.

 [user@server ~]$ su -
 [root@server ~]$ service NetworkManager stop
 [root@server ~]$ chkconfig NetworkManager off

Enable standard networking

Next we enable the standard networking daemon and tell it to start automatically on boot.

 [root@server ~]$ service network start
 [root@server ~]$ chkconfig network on

Now you’ll need to configure networking, which you can do via the graphical tool.

 [root@server ~]$ system-configure-network-gui

Set eth0 (or your network device) to be static/use DHCP, whatever is required by your network setup, by selecting it and clicking edit.

Finally, activate the device and close the tool.
[[Image:fedora-network-client-config.png|thumb|500px|none|Fedora – configure networking]]

Now that your network is configured, let’s get started with LDAP!

Let’s begin!

As we need to run lots of commands on the LDAP server, it’s easier to to this as root.

If you’re not yet root, become so.

 [user@server ~]$ su -

Install packages

We must install the required packages. The first is the LDAP server itself, the second is a set of perl scripts which help us create LDIF files for populating the LDAP server.

 [root@server ~]$ yum install openldap-servers migrationtools

Create admin password

There is an all-powerful root LDAP user which will populate our directory. Rather than publishing this password in cleartext with in the configuration file, we want to encrypt it.

To do so, we run the slappasswd command, which will encrypt our password and return the value.

 [root@server ~]$ slappasswd
 New password:
 Re-enter new password:

Copy the final encrypted output (i.e. {SSHA}MP0BeMJzmCoCi5olBhwcRDYJaGBFgN5K) for use in the next section.


Previously, OpenLDAP was previously managed via a single configuration file (/etc/openldap/slapd.conf), however these days the configuration for LDAP is stored inside the LDAP server itself! As such, the configuration is done by editing LDIF files under the /etc/openldap/slapd.d/ directory.

Fedora supports both methods. We can either delete the slapd.d directory and use a slapd.conf file, or go along with the new method and edit the LDIF files before starting up our LDAP server.

Config file

If you wish to use the config file (which some will find easier), then follow these instructions.

Remove the existing slapd.d directory (else Fedora will not read our configuration).

 [root@server ~]$ rm -Rf /etc/openldap/slapd.d/

Create a new config file from the existing template.

 [root@server ~]$ cp -a /etc/openldap/slapd.conf.bak /etc/openldap/slapd.conf

Now that we have the base files in place, we need to begin configuring the file. We need to set several options, most importantly the domain (dc=test,dc=lan), and the admin password.

First, open it.

 [root@server ~]$ vim /etc/openldap/slapd.conf

If you’re using Vim, just run the following command.


If not, find and set the following domain values

suffix	"dc=test,dc=lan"
 rootdn	"cn=Manager,dc=test,dc=lan"
 # allow only rootdn to read the monitor
 access to *
      by dn.exact="cn=Manager,dc=test,dc=lan" red
      by * none

Next, we need to set the admin user’s password (which we generated earlier) and tell LDAP where to find the certificate and key for encryption (which we will create in a later step).

rootpw {SSHA}MP0BeMJzmCoCi5olBhwcRDYJaGBFgN5K
TLSCertificateFile: /etc/openldap/ssl/slapdcert.pem
TLSCertificateKeyFile: /etc/openldap/ssl/slapdkey.pem

Finally, save and quit the file.


Non-config file

Here’s now to edit the LDIF files under slapd.d to store the LDAP server configuration within LDAP (cn=config) itself.

The first of two LDIF files is the base database file.

[root@server ~]$ vim /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{1\}bdb.ldif

If you’re using Vim, then just run the following.


Else, find and replace the following entry.

olcRootDN: dc=test,dc=lan

Now we must set the admin password and specify the location of our encryption certificate and key.

olcRootPW: {SSHA}ccFKiy8ska8IhNwwlaNYxiBNbilWe5M1
olcTLSCertificateFile /etc/openldap/ssl/slapdcert.pem
olcTLSCertificateKeyFile /etc/openldap/ssl/slapdkey.pem

Open the second file, which specifies monitoring privileges.

[root@server ~]$ vim /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{2\}monitor.ldif

Once again, use Vim to replace the required entry.


Or replace it yourself.

That’s it! Now you can continue with the how to.

Database cache

You should now have configured LDAP using either the single config file, or by specifying LDIF files. If not, see above.

Back at the terminal, copy a default DB_CONFIG file which sets cache and tuning options for the Berkley database backend (this also needs to be writeable by the ldap user).

 [root@server ~]$ cp /usr/share/doc/openldap-servers-*/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
 [root@server ~]$ chown -Rf ldap:ldap /var/lib/ldap/

Test configuration

Lastly, test your configuration by running the command, and check return:

 [root@server ~]$ slaptest -u 
 config file testing succeeded

That’s all the initial base configuration we should need to do! Next we will configure encryption.

Encryption (LDAPS) using TLS

Because we are using LDAP for authentication across a network, we want to encrypt the traffic. This means we can either run LDAP (on default port of 389) with TLS, or the LDAPS (on port 636) with TLS. We will do the latter.

We need to tell Fedora how to start the secure LDAP daemon, which is done by editing the sysconfig entry for ldap.

 [root@server ~]$ vim /etc/sysconfig/ldap

Set the following:


When the service is started, it will also run LDAP Secure (LDAPS).

Generate and configure keys

Now that we have told LDAP to run on secure port 636 we need to generate SSL keys and configure the LDAP service to use them!

Fedora has a script to automate this process, but it’s easy enough to generate the keys manually (when prompted, fill in the information as below, but replace the hostname with the FQDN of the LDAP server!).

 [root@server ~]$ mkdir /etc/openldap/ssl/
 [root@server ~]$ openssl req -new -x509 -nodes -out /etc/openldap/ssl/slapdcert.pem -keyout /etc/openldap/ssl/slapdkey.pem -days 365
 Generating a 2048 bit RSA private key
 writing new private key to '/etc/openldap/ssl/slapdkey.pem'
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 There are quite a few fields but you can leave some blank
 For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 Country Name (2 letter code) [XX]: AU
 State or Province Name (full name) []: ACT
 Locality Name (eg, city) [Default City]: Canberra
 Organization Name (eg, company) [Default Company Ltd]: Company
 Organizational Unit Name (eg, section) []: Section
 Common Name (eg, your name or your server's hostname) []: server.test.lan
 Email Address []: user@test.lan

This will create the two required keys in the /etc/openldap/ssl/ directory, but we need to make sure that the ldap user can read them.

 [root@server ~]$ chown -Rf root:ldap /etc/openldap/ssl
 [root@server ~]$ chmod -Rf 750 /etc/openldap/ssl

We have already told the LDAP server to use them, so once we start the server it should be good to go!

Start LDAP service

It’s time to start the LDAP service, and tell it to start on bootup.

 [root@server ~]$ service slapd start
 Starting slapd:                                            [  OK  ]

Test that the server came up properly and is listening on the LDAPS port

 [root@server ~]$ netstat -lt |grep ldap
 tcp  0  0 *:ldap   *:*  LISTEN
 tcp  0  0 *:ldaps  *:*  LISTEN

If so, tell Fedora to start the LDAP server on bootup.

 [root@server ~]$ chkconfig slapd on

Test configuration

 [root@server ~]$ ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
 # extended LDIF
 # LDAPv3
 # base <> with scope baseObject
 # filter: (objectclass=*)
 # requesting: namingContexts 
 namingContexts: dc=test,dc=lan
 # search result
 search: 2
 result: 0 Success
 # numResponses: 2
 # numEntries: 1

This should returns a success, as above.

If all that went as planned, congratulations, you have a basic LDAP server configured! Next we need to populate this with our users and groups.

Configure base domain

We should now have a base LDAP server running, configured for our domain. However we do not have any users (People) or groups (Group) configured! We do that in the next step Now we need to set up our base, authentication and group files.

This is done via a migration of your existing local unix accounts already configured on the system, which are converted into an LDIF file for loading into LDAP. First however, we need to create a template base.ldif file which creates the base structure of our directory (test.lan), which we will import into LDAP database first.

 [root@server ~]$ vim base.ldif

Add the following to the base.ldif file:

 dn: dc=test,dc=lan
 dc: test
 objectClass: top
 objectClass: domain
 dn: ou=People,dc=test,dc=lan
 ou: People
 objectClass: top
 objectClass: organizationalUnit
 dn: ou=Group,dc=test,dc=lan
 ou: Group
 objectClass: top
 objectClass: organizationalUnit

Now that we have the base information for our LDAP structure, we can (hopefully!) import that information into our LDAP database (use the password you created above):

  [root@server ~]$ ldapadd -x -W -D "cn=Manager,dc=test,dc=lan" -f ./base.ldif
 Enter LDAP Password:
 adding new entry "dc=test,dc=lan"
 adding new entry "ou=People,dc=test,dc=lan"
 adding new entry "ou=Group,dc=test,dc=lan"

If you saw the above, then it worked! If you get an error about authentication issues connecting to then it’s not reading your configuration properly, and is using the default. Stop the service and start again.

Migrate users and groups

We are now going to use the migration tools to create ldif files for our existing users and groups, which we will import into LDAP like in the previous step.

First, tell the migration scripts which domain to use by default (we want to use test.lan instead of the default

 [root@server ~]$ vim /usr/share/migrationtools/

Set the following:

 # Default DNS domain
 $DEFAULT_MAIL_DOMAIN = "test.lan";

 # Default base 
 $DEFAULT_BASE = "dc=test,dc=lan";

Users (People)

Now, we will use the migration script to create an ldif which we will use to populate LDAP with all our existing users (note, this will pull in the user account).

 [root@server ~]$ /usr/share/migrationtools/ /etc/passwd people.ldif

Once you have the file, we can import the entries into LDAP:

 [root@server ~]$ ldapadd -x -W -D "cn=Manager,dc=test,dc=lan" -f people.ldif

Groups (Group)

Now, we will use the migration script to create an ldif which we will use to populate LDAP with all our existing groups (note, this will pull in the user group).

 [root@server ~]$ /usr/share/migrationtools/ /etc/group group.ldif

Once you have the file, we can import the entries into LDAP:

 [root@server ~]$  ldapadd -x -W -D "cn=Manager,dc=test,dc=lan" -f group.ldif

Test contents of LDAP database

Now, we have our database populated with info. It’s time to test our work. First, you can use the ldapsearch command to look for your username. You should get a successful response back, as below.

 [root@server ~]$ ldapsearch -xWD “cn=Manager,dc=test,dc=lan” -b “dc=test,dc=lan” “cn=user”
 # extended LDIF
 # user, Group, test.lan
 dn: cn=user,ou=Group,dc=test,dc=lan
 objectClass: posixGroup
 objectClass: top
 cn: user
 userPassword:: E2NyeXB0fXG=
 gidNumber: 500
 # search result
 search: 2
 result: 0 Success

Adding a new user and group

To add a new user, we create an ldif for the user account, and the group. Then we import these into the LDAP server, like we did with the base, people and groups previously.


To add a user, simply create an ldif file (like chris.ldif) with contents like so:

 dn: uid=chris,ou=People,dc=test,dc=lan
 uid: chris
 cn: Chris Smart
 objectClass: account
 objectClass: posixAccount
 objectClass: top
 objectClass: shadowAccount
 userPassword: {crypt}$6$XemGNmMU9f3FRFo/vt7Uld/gUcP/2N7/R.uw5SK.
 shadowLastChange: 14846
 shadowMax: 99999
 shadowWarning: 7
 loginShell: /bin/bash
 uidNumber: 501
 gidNumber: 501
 homeDirectory: /home/chris
 gecos: Chris Smart


Then, add the group information for this user (like chris-group.ldif):

 dn: cn=chris,ou=Group,dc=test,dc=lan
 objectClass: posixGroup
 objectClass: top
 cn: chris
 userPassword: {crypt}x
 gidNumber: 501

Add to LDAP

Then add these into LDAP!

 [root@server ~]$ ldapadd -x -W -D "cn=Manager,dc=test,dc=lan" -f chris.ldif
 Enter LDAP Password:
 adding new entry "uid=chris,ou=People,dc=test,dc=lan"
 [root@server ~]$ ldapadd -x -W -D "cn=Manager,dc=test,dc=lan" -f chris-group.ldif
 Enter LDAP Password:
 adding new entry "cn=chris,ou=Group,dc=test,dc=lan"

Now you have a new user called chris!

Client Configuration

Now that we have a server which is responding correctly, we can configure our clients to authenticate to the LDAP server.

For Fedora machines, authconfig-gtk or authconfig-tui:

 [root@server ~]$ authconfig-gtk

In the tool, select and fill in the details below.
User Account Configuration

User Account Database: LDAP
LDAP Search Base DN: dc=test,dc=lan
LDAP Server: ldaps://server.test.lan

Authentication Configuration

Authentication Method: LDAP Password

[[File:fedora-client-ldap-config.png|thumb|500px|none|LDAP Client Authentication]]

Now, we need to tell Fedora the location of the encryption certificate. Click on Download CA Certificate and pass the location of the file.
Note: If this is a local machine, you can use file://, however if it’s a remote machine, you’ll need to put the certificate on an NFS, FTP or HTTP share.

[[File:fedora-client-ldap-cacert.png|thumb|500px|none|LDAP Client Authentication – location of certificate]]

On the Advanced Options tab, tick Create home directories on the first login – else although users can authenticate, they won’t have a home directory when they log in!

[[File:fedora-client-ldap-config-2.png|thumb|500px|none|LDAP Client Authentication – create home directories]]

Hit Apply and we should now be able to log in as our users!


Of course, to test this you can just log out and back in, but a quicker way (in case something’s not right) is to open a non-root terminal and switch to the new user you created (i.e. chris as above).

 [user@server ~]$ su - chris

This should ask for chris’ password and if everything’s working correctly, you should be able to switch to this user.

If it fails, check your /var/log/messages to see if there are some helpful errors.

The following has been contributed by Sunil Tumma:

OpenLDAP with ppolicy

Overlays are dynamically configurable modules that provide additional functionality to OpenLDAP. The ppolicy overlay provides some useful functionalities for enforcing a password policy for the domain.

Requirement was the following

  • Account should be locked out after 5 failed authentication attempts
  • Password expiration on 90 days
  • Minimum password length of 8

All of our desktops were authenticating to the OpenLDAP server (test.lan) which was setup on a CentOS box. We were able to achieve the 99999 days password expiration using the default shadowAccount objectClass as given below.

# test, People, test.lan
dn: uid=test,ou=People,dc=test,dc=lan
uid: test
cn: test
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSQxJEMzOxxxxxxxxxx
shadowLastChange: 15140
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 1000
gidNumber: 1000
homeDirectory: /home/test

But we couldn’t find any way to implement the password expirartion and password length polcies using the default OpenLDAP configuration. So I started my experiments with password policy (ppolicy) overlays. The ppolicy overlay provides enhanced password management capabilities that are applied to non-rootdn bind attempts in OpenLDAP.


The ppolicy and other overlays are included in the package openldap-servers-overlays for Redhat/CentOS servers. So we need first install this package assuming OpenLDAP server and dependencies are already installed.
yum install openldap-servers-overlays

The ppolicy module file should get installed at /usr/lib64/openldap/ and schema file at /etc/openldap/schema/ppolicy.schema on a 64 bit CentOS/Redhat server and in the /usr/lib/openldap/ directory on a 32bit i686 server.

Server Configuration

We need to configure the ppolicy overlays now. Add the following lines to /etc/openldap/slapd.conf in the respective sections.
include /etc/openldap/schema/ppolicy.schema
modulepath /usr/lib64/openldap

This is assuming that ppolicy overlay files are in respective locations. The ACL’s should be set such that clients bind to OpenLDAP server by self-authentication. We should not allow anonymous or rootdn binds to the server although the default configuration is to allow anonymous binds to server. So I added ACL as given below in the ACL section of slapd.conf.

access to attrs=userPassword
by self =xw
by anonymous auth
by * none
access to *
by self write
by * read

Next we need to add default password policy we are going to enforce on the domain. Add the following after the DB section in slapd.conf.

overlay ppolicy
ppolicy_default "cn=default,ou=policies,dc=test,dc=lan"

This should complete the configuration of slapd.conf. You should be able to restart the LDAP server without any issues now.

Importing the password policy

Create a LDIF file called password-policy.ldif with following content:

dn: ou=policies,dc=test,dc=lan
ou: policies
objectClass: top
objectClass: organizationalUnit
# default, policies, test.lan
dn: cn=default,ou=policies,dc=test,dc=lan
objectClass: top
objectClass: device
objectClass: pwdPolicy
cn: default
pwdAttribute: userPassword
pwdMaxAge: 7776002
pwdExpireWarning: 432000
pwdInHistory: 3
pwdCheckQuality: 1
pwdMinLength: 8
pwdMaxFailure: 5
pwdLockout: TRUE
pwdLockoutDuration: 900
pwdGraceAuthNLimit: 0
pwdFailureCountInterval: 0
pwdMustChange: TRUE
pwdAllowUserChange: TRUE
pwdSafeModify: FALSE

This sets the following policies

  • password expiration at 90 days
  • password lockout on 5 failures and lockout duration of 15 mintues
  • minimum password length of 8
  • 3 earlier password in history

To import the policy run the following command:

ldapadd -D "cn=Manager,dc=test,dc=lan" -W -x -f password-policy.ldif

This ldapadd command should add to policy on authentication as LDAP administrator and we should be able to see the newly imported policy now when we do an ldapsearch.

ldapsearch -x -D "cn=Manager,dc=test,dc=lan" -W -b "dc=test,dc=lan"

This completes the server configuration.

Client Side Configuartion

On the LDAP clients we need make the following change in LDAP client configuration file /etc/ldap.conf assuming the client was configured to authenticate to our LDAP server before. Uncomment the pam_lookup_policy line which should be already there in /etc/ldap.conf, to enable it:

pam_lookup_policy yes

Now the password policy should be enforced for all non-rootdn authentication attempts.

Licensed under Creative Commons 3.0 non-ported license.

162 thoughts on “OpenLDAP How To (Fedora)

  1. Fantastic guide!

    BTW, in Fedora 13, the template slapd.conf file is now installed to: /usr/share/openldap-servers/slapd.conf.obsolete

  2. Yeah, I noticed that it was removed after an update! Yikes.. I need to get my head around configuration within slapd..

  3. Hello,

    A little question. How do I put de mail address into the People database? So I can make a connection with a mailer (Postfix)


  4. Hi Dani,

    I’m not sure, but I think that’s a standard part of the POSIX account. Use phpldapadmin to take a look at your users and see?


  5. I had to add more syntax to get results when doing a search:

    ldapsearch -xWD “cn=Manager,dc=test,dc=lan” -b “dc=test,dc=lan” “cn=bobsmith”

    Of course, slapcat always shows what’s in the DB.

  6. Very helpful guide.
    However, one typo/error:
    for the lines:
    TLSCertificateFile: /etc/openldap/ssl/slapdcert.pem
    TLSCertificateKeyFile: /etc/openldap/ssl/slapdkey.pem
    The colon(:) after the TLSCertificateFile and the TLSCertificateKeyFile’s will raise an error. The syntax for the slapd.conf file doesn’t require this.
    Same with the non-config file approach.

  7. In the “non-config file”, you are saying to edit LDIF files directly. However, the OpenLDAP Administrator’s guide explicitly states:

    “Although the slapd-config(5) system stores its configuration as (text-based) LDIF files, you should never edit any of the LDIF files directly. Configuration changes should be performed via LDAP operations, e.g. ldapadd(1), ldapdelete(1), or ldapmodify(1).”

    Otherwise, great tutorial, keep it up!

  8. Ahh, thanks.. I admit it was a quick hack at the time 🙂 I’ll look into it some more when I get a chance. If you know how to do configure it without editing the files, please let me know 😉


  9. the amount of times i have read this page, it is soooo well done – i need to start writing howtos like this 🙂

    i <3 this article heaps! 🙂

    works on centos6 too 😉

  10. Anyone knows a good howto connect a ubuntu-client with my fedora-slapd-server? Why do i get this error message:

    ldapsearch -xWD “cn=Manager,dc=home,dc=lan” -b “dc=home,dc=lan” “cn=user”
    Enter LDAP Password:
    ldap_bind: Invalid DN syntax (34)
    additional info: invalid DN

  11. when I type ldapadd command I’m getting following error..please help me..

    ldapadd -x -W -D “cn=Manager,dc=test,dc=lan” -f ./base.ldif
    Enter LDAP Password:
    ldap_bind: Invalid credentials (49)

    my base.ldif file is as follow..

    dn: dc=example,dc=com
    dc: example
    objectClass: top
    objectClass: domain

    dn: ou=People,dc=example,dc=com
    ou: People
    objectClass: top
    objectClass: organizationalUnit

    dn: ou=Group,dc=example,dc=com
    ou: Group
    objectClass: top
    objectClass: organizationalUnit

    please help me.

  12. Looks like your base.ldif is using, not test.lan. So try:
    ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f ./base.ldif


  13. ya..i’m using that only….just did mistake in typing here..

    still getting same error…help me please..

  14. OK, are you running that command from the server, or from another machine? If from another machine, then you might need to specify the host to connect to in that command.


  15. That’s brilliant! Thanks for such great article, this should be attached to chapter about LDAP in official documentation 😉

    Cheers 😀

  16. Glad it helped.. 🙂 There are a few things I need to update, like we don’t use LDAPS any more but rather TLS over LDAP, and I need to learn how to configure the LDAP server properly by altering the LDAP server itself, instead of using the config file which his now deprecated.


  17. Really this “How To” is very useful for me … Thanks a lot chris for this fantastic post!! but I got some problem.

    After following all the steps ..
    now I am getting this error msg at “slaptest -u”

    str2entry: str2ad(TLSCertificateFile): attribute type undefined
    slaptest: bad configuration file!

    Pls help me, give me some way to come out from this problem.

  18. Hi Mukesh,
    Double check that your config file is correct – looks like TLSCertificateFile or something around it might not be correctly specified. Might be missing an equals, or something.


  19. sorted out last problem … I was using TLSCertificateFile instead of olcTLSCertificateFile 🙂 thanks for your guidance.

    But now i am getting different problem …

    when i use “ldaps://localhost.localdomain” for “LDAP server” field in “User Account Configuration” section, i get

    “ldap_sasl_bind(SIMPLE): Can’t contact LDAP server (-1)” error on

    “ldapsearch -x -b ” -s base ‘(objectclass=*)’ namingContexts”.

    if i change the ldaps to ldap(ldap://localhost.localdomain) then it works smoothly without any complain. I don’t know what is going wrong here.

    and on “su – chris” command it always returns ..
    “su: user chris does not exist” .. in both the cases.

    “ldapsearch -D “cn=Manager, dc=my-domain,dc=com” uid=chris -W”
    (when i am using ldap not ldaps) command returns me a positive result … any idea??


  20. one more thing … whenever i do “su – chris” in the /var/log/messages file

    Nov 26 12:52:48 localhost sssd[be[default]]: Could not start TLS encryption. (null)
    Nov 26 12:52:48 localhost sssd[be[default]]: Could not start TLS encryption. (null)
    Nov 26 12:52:48 localhost sssd[be[default]]: Could not start TLS encryption. (null)

    shows these errors ….


  21. Sounds like an issue with your SSL certificates – your client might not have the right cacert and or certificate for your server. Double check that they all exist in the right places, as per howto.

    I don’t think that I posted anything about testing SSL with openssl command, so I’ll update that at some point.


  22. Hi chris … finally i m able to see a successful login of “chris” user in my system. Thanks a lot for being with me … 🙂

    But still one doubt do exist … when i do a “getent passwd” why its not listing “chris” user there … ??

    any idea?


  23. and it shows some details on following cmd.

    “getent passwd chris”
    chris:*:501:501:Chris Smart:/home/chris:/bin/bash


  24. Hi Mukesh,
    I’m not sure, but I think sometimes getent is cached? Maybe that’s it? Try getent group and see if that works? If not, check your logs, and see if there are any errors there, like can’t contact LDAP or something. If you can log in as chris, I’d have thought you could see that user in getent..


  25. Hello

    First of all, very nice tutorial!
    But I’m getting errors when I do

    ldapsearch -xWD “cn=Manager,dc=vlemincx,dc=be” -b “dc=vlemincx,dc=be” “cn=user”

    ldap_bind: Invalid DN syntax (34)
    additional info: invalid DN

    The cn=user, user does it have to be specified somewhere?
    Chris said, specifying the host? What do you mean by that?

  26. Hi Nick,

    Just a quick thought, did you copy that from the website or type it? Are the quotes really quotes, or are they HTML characters? It’s saying your DN syntax is wrong, which I’m guessing means either it’s not typed correctly, or it doesn’t exactly match what you’ve set up in LDAP.


  27. Hi chris,

    “getent group” is also not listing “chris” user. I checked the /var/log/messages file also, but no hint available.

    hey chris .. where can i check my ldap server log? I have a doubt that “getent passwd” doesn’t query the ldap server at all because when I stop the ldap server and do “getent passwd” it display the output immediatly. I guess it should complain/wait about/for ldap server .. just a blind guess.


  28. Do you have nsss service installed and running? If so, try disabling that. The log should be on the server, /var/log/messages I guess.


  29. nsss? its saying unrecognized service. nscd service is there, which is not running.

    /var/log/messages doesn’t logged ldap related info always. Like I gave an ldapsearch but no activity reported in the “messages” file.


  30. yohooooooooooo …. its done!!

    secret was in sssd.conf file. It has one “enumerate” field which was disabled by default so that running getent on a large directory doesn’t take much time. Changing this field to true has done the trick. I am happy now!!

    Thank you so much chris for all your support.


  31. Thanks a lot for this how-to!
    It’s the only one on the web that actually works i think!

    But i have a problem with config the client.
    Which file need you to load in “Download CA Certificate”?
    I always get a error :'(

  32. I got help from a friend.

    It was: file:/// (3 slaches, not 2, i was wrong)

    Me and my friend both config the client with CA but it doesn’t work 🙁
    We cant switch to a ldap user 🙁

    Is there a way to config the ldapserver with a GUI? Maybe there is something wrong with the userdata :s

  33. Hi Kevin,

    Yes, it’s in the form of protocol://location, so if its local it will be file:///path/to/somewhere. Web would be http://server/path/to/somewhere.

    Are you on the LDAP server, or on another machine trying to connect to it that way? Did any of the ldapsearch commands work?


Leave a Reply

Your email address will not be published. Required fields are marked *