Users and groups defined in the LDAP directory will be integrated into the operating system, so as they appear as locally defined.
- Requirement: LDAP
- Reference: nss-pam-ldapd
Don’t use nss_ldap
/ pam_ldap
packages they generate
too much request to the LDAP server.
Build information
Ensure the following options:
LDAP
The configuration file ldap.conf
is located in
/usr/local/etc/openldap/
(on system other than FreeBSD,
it can usually be found in /etc/
).
Setting up the protocol version to use, the default branch and the server to connect to:
NSS & PAM
The nslcd
doesn’t required to be run as root
so we switch to its dedicated user/group (nslcd
):
The minimum requirement is to provide the URI to the LDAP server as well as the branch that will serve as base for the requests, from there if conforming to RFC 2307 no customization of the ldap requests are needed.
Lookup into the LDAP directory can be customized to select the appropriates branches, apply filters to the search or remap LDAP attributes.
Here we will specify the branch as well as a filter to use when
looking up for users (passwd
, shadow
) or groups (group
):
Even if in nsswitch
, the local database (files
) will be looked up
before performing an ldap query (ldap
), it is advised to ensure that
local system account (usually with an uid
below 1000) can never be
imported.
We don’t allow PAM to change the user password, but prefer to redirect the user to a dedicated webpage where he would be able to do so. This allows us to perform addition checks on the selected password and to convert it so it can be used with ldap, samba, or kerberos.
To avoid a chicken and egg problem during the boot process, which can lead to a deadlock, it is possible to ignore some users from the ldap name resolution:
This is normally not necessary if the order used in the nsswitch.conf
file is files ldap
.
Start the nslcd
at boot-time:
Caching
In FreeBSD < 12.2, the nscd
daemon is broken.
As request over the network are costly, you generally want nsswitch
to be able to cache the retrieved data. This is done by using the
nscd
to perform the caching.
In our example, we only use LDAP lookup to retrieve information
about users and groups, so only the passwd
and group
entry
need to be cached (enabled in /etc/nscd.conf
).
And of course the nscd
daemon should be started at boot-time:
nsswitch
A typical configuration for nsswitch.conf
is to first query
the cache provided by nscd
(keyword: cache
), next if
necessary the local database (keyword: files
) and if unsuccessful to
query the ldap directory (keyword: ldap
):