Contents
Abstract
The Lightweight Directory Access Protocol (LDAP) is a set of protocols designed to access and maintain information directories. LDAP can be used for numerous purposes, such as user and group management, system configuration management, or address management. This chapter provides a basic understanding of how OpenLDAP works and how to manage LDAP data with YaST. While there are several implementations of the LDAP protocol, this chapter focuses entirely on the OpenLDAP implementation.
It is crucial within a networked environment to keep important information structured and quickly available. This can be done with a directory service that, like the common yellow pages, keeps information available in a well-structured, quickly searchable form.
In the ideal case, a central server keeps the data in a directory and distributes it to all clients using a certain protocol. The data is structured in a way that allows a wide range of applications to access it. That way, it is not necessary for every single calendar tool and e-mail client to keep its own database—a central repository can be accessed instead. This notably reduces the administration effort for the information. The use of an open and standardized protocol like LDAP ensures that as many different client applications as possible can access such information.
A directory in this context is a type of database optimized for quick and effective reading and searching:
To make numerous concurrent reading accesses possible, write access is limited to a small number of updates by the administrator. Conventional databases are optimized for accepting the largest possible data volume in a short time.
Because write accesses can only be executed in a restricted fashion, a directory service is used to administer mostly unchanging, static information. Data in a conventional database typically changes very often (dynamic data). Phone numbers in a company directory do not change nearly as often as, for example, the figures administered in accounting.
When static data is administered, updates of the existing data sets are very rare. When working with dynamic data, especially when data sets like bank accounts or accounting are concerned, the consistency of the data is of primary importance. If an amount should be subtracted from one place to be added to another, both operations must happen concurrently, within a transaction, to ensure balance over the data stock. Databases support such transactions. Directories do not. Short-term inconsistencies of the data are quite acceptable in directories.
The design of a directory service like LDAP is not laid out to support complex update or query mechanisms. All applications accessing this service should gain access quickly and easily.
The Unix system administrator traditionally uses the NIS service for name
resolution and data distribution in a network. The configuration data
contained in the files in /etc and the directories
group, hosts,
mail, netgroup,
networks, passwd,
printcap, protocols,
rpc, and services are distributed
by clients all over the network. These files can be maintained without major
effort because they are simple text files. The handling of larger amounts of
data, however, becomes increasingly difficult due to nonexistent
structuring. NIS is only designed for Unix platforms. This means it is not
suitable
as a centralized data administration tool in heterogeneous networks.
Unlike NIS, the LDAP service is not restricted to pure Unix networks. Windows servers (from 2000) support LDAP as a directory service. Application tasks mentioned above are additionally supported in non-Unix systems.
The LDAP principle can be applied to any data structure that should be centrally administered. A few application examples are:
Employment as a replacement for the NIS service
Mail routing (postfix, sendmail)
Address books for mail clients, like Mozilla, Evolution, and Outlook
Administration of zone descriptions for a BIND9 name server
User authentication with Samba in heterogeneous networks
This list can be extended because LDAP is extensible, unlike NIS. The clearly-defined hierarchical structure of the data eases the administration of large amounts of data, because it can be searched more easily.
To get a deep background knowledge on how an LDAP server works and how the data are stored, it is vital to understand the way the data are organized on the server and how this structure enables LDAP to provide fast access to the data you need. To successfully operate an LDAP setup, you also need to be familiar with some basic LDAP terminology. This section introduces the basic layout of an LDAP directory tree and provides the basic terminology used in an LDAP context. Skip this introductory section, if you already have some LDAP background knowledge and just want to learn how to set up an LDAP environment in SUSE Linux Enterprise.
An LDAP directory has a tree structure. All entries (called objects) of the directory have a defined position within this hierarchy. This hierarchy is called the directory information tree (DIT). The complete path to the desired entry, which unambiguously identifies it, is called distinguished name or DN. A single node along the path to this entry is called relative distinguished name or RDN. Objects can generally be assigned to one of two possible types:
These objects can themselves contain other objects. Such object
classes are root (the root element of the directory
tree, which does not really exist), c (country),
ou (organizational unit), and dc
(domain component). This model is comparable to the directories (folders)
in a file system.
These objects sit at the end of a branch and have no subordinate
objects. Examples are person,
InetOrgPerson, or
groupofNames.
The top of the directory hierarchy has a root element
root. This can contain c (country),
dc (domain component), or o
(organization) as subordinate elements. The relations within an LDAP
directory tree become more evident in the following example, shown in
Figure 35.1, “Structure of an LDAP Directory”.
The complete diagram is a fictional directory information tree.
The entries on three levels are depicted. Each entry corresponds to one box
in the picture. The complete, valid distinguished name
for the fictional employee Geeko
Linux, in this case, is cn=Geeko
Linux,ou=doc,dc=example,dc=com. It is composed by adding the RDN
cn=Geeko Linux to the DN of the preceding entry
ou=doc,dc=example,dc=com.
The types of objects that should be stored in the DIT are globally determined following a scheme. The type of an object is determined by the object class. The object class determines what attributes the concerned object must or can be assigned. A scheme, therefore, must contain definitions of all object classes and attributes used in the desired application scenario. There are a few common schemes (see RFC 2252 and 2256). It is, however, possible to create custom schemes or to use multiple schemes complementing each other if this is required by the environment in which the LDAP server should operate.
Table 35.1, “Commonly Used Object Classes and Attributes” offers a small
overview of the object classes from core.schema and
inetorgperson.schema used in the example, including
required attributes and valid attribute values.
Table 35.1. Commonly Used Object Classes and Attributes¶
Object Class | Meaning | Example Entry | Required Attributes |
|---|---|---|---|
dcObject | domainComponent (name components of the domain) | example | dc |
organizationalUnit | organizationalUnit (organizational unit) | doc | ou |
inetOrgPerson | inetOrgPerson (person-related data for the intranet or Internet) | Geeko Linux | sn and cn |
Example 35.1, “Excerpt from schema.core ” shows an excerpt from a scheme directive with explanations (line numbering for explanatory reasons).
Example 35.1. Excerpt from schema.core ¶
#1 attributetype (2.5.4.11 NAME ( 'ou' 'organizationalUnitName')
#2 DESC 'RFC2256: organizational unit this object belongs to'
#3 SUP name )
...
#4 objectclass ( 2.5.6.5 NAME 'organizationalUnit'
#5 DESC 'RFC2256: an organizational unit'
#6 SUP top STRUCTURAL
#7 MUST ou
#8 MAY (userPassword $ searchGuide $ seeAlso $ businessCategory
$ x121Address $ registeredAddress $ destinationIndicator
$ preferredDeliveryMethod $ telexNumber
$ teletexTerminalIdentifier $ telephoneNumber
$ internationaliSDNNumber $ facsimileTelephoneNumber
$ street $ postOfficeBox $ postalCode $ postalAddress
$ physicalDeliveryOfficeName
$ st $ l $ description) )
...The attribute type organizationalUnitName and the
corresponding object class organizationalUnit serve as an
example here. Line 1 features the name of the attribute, its unique OID
(object identifier) (numerical), and the abbreviation
of the attribute.
Line 2 gives a brief description of the attribute with
DESC. The corresponding RFC on which the definition is
based is also mentioned here. SUP in line 3 indicates a
superordinate attribute type to which this attribute belongs.
The definition of the object class
organizationalUnit begins in line 4, like in the
definition of the attribute, with an OID and the name of the object class.
Line 5 features a brief description of the object class. Line 6, with its
entry SUP top, indicates that this object class is not
subordinate to another object class. Line 7, starting with
MUST, lists all attribute types that
must be used in conjunction with an object of the type
organizationalUnit. Line 8, starting with
MAY, lists all attribute types that are permitted in
conjunction with this object class.
A very good introduction to the use of schemes can be found in the
documentation of OpenLDAP. When installed, find
it in
/usr/share/doc/packages/openldap2/admin-guide/index.html.
YaST includes a module to set up LDAP-based user management. If you did not enable this feature during the installation, start the module by selecting +. YaST automatically enables any PAM and NSS related changes as required by LDAP and installs the necessary files.
Background knowledge of the processes acting in the background of a
client machine helps you understand how the YaST LDAP client module
works. If LDAP is activated for network authentication or the YaST module
is called, the packages pam_ldap
and nss_ldap are installed and
the two corresponding configuration files are adapted. pam_ldap is the PAM module responsible for
negotiation between login processes and the LDAP directory as the source of
authentication data. The dedicated module pam_ldap.so
is installed and the PAM configuration is adapted (see
Example 35.2, “pam_unix2.conf Adapted to LDAP”).
Example 35.2. pam_unix2.conf Adapted to LDAP¶
auth: use_ldap account: use_ldap password: use_ldap session: none
When manually configuring additional services to use LDAP, include
the PAM LDAP module in the PAM configuration file corresponding to the
service in /etc/pam.d.
Configuration files already adapted to individual services can be found in
/usr/share/doc/packages/pam_ldap/pam.d/.
Copy appropriate files to /etc/pam.d.
glibc name resolution through the
nsswitch mechanism is adapted to the employment of LDAP
with nss_ldap. A new, adapted
file nsswitch.conf is created in
/etc with the installation of this package.
Find more about the workings of nsswitch.conf
in Section 30.7.1, “Configuration Files”.
The following lines must be present in nsswitch.conf
for user administration and authentication with LDAP. See
Example 35.3, “Adaptations in nsswitch.conf”.
Example 35.3. Adaptations in nsswitch.conf¶
passwd: compat group: compat passwd_compat: ldap group_compat: ldap
These lines order the resolver library of glibc
first to evaluate the corresponding files in /etc and
additionally access the LDAP server as sources for authentication and user
data. Test this mechanism, for example, by reading the content of the user
database with the command getent
passwd. The returned set should contain a
survey of the local users of your system as well as all users stored on the
LDAP server.
To prevent regular users managed through LDAP from logging in to the server
with ssh or login,
the files /etc/passwd and
/etc/group each need to include an additional
line. This is the line
+::::::/sbin/nologin in
/etc/passwd and
+::: in /etc/group.
After the initial adjustments of nss_ldap,
pam_ldap, /etc/passwd, and
/etc/group have been taken care of by YaST, you can
simply connect your client to the server and let YaST manage users
over LDAP. This basic setup is described in Section 35.3.2.1, “Basic Configuration”.
Use the YaST LDAP client to further configure the YaST group and user configuration modules. This includes manipulating the default settings for new users and groups and the number and nature of the attributes assigned to a user or a group. LDAP user management allows you to assign far more and different attributes to users and groups than traditional user or group management solutions. This is described in Section 35.3.2.2, “Configuring the YaST Group and User Administration Modules”.
The basic LDAP client configuration dialog (Figure 35.2, “YaST: Configuration of the LDAP Client”) opens during installation if you choose LDAP user management or when you select + in the YaST Control Center in the installed system.
To authenticate users of your machine against an OpenLDAP server and enable user management via OpenLDAP, proceed as follows:
Click to enable the use of LDAP. Select instead if you want to use LDAP for authentication, but do not want other users to log in to this client.
Enter the IP address of the LDAP server to use.
Enter the to select the search base on the LDAP server. To retrieve the base DN automatically, click . YaST then checks for any LDAP database on the server address specified above. Choose the appropriate base DN from the search results given by YaST.
If TLS or SSL protected communication with the server is required, select .
If the LDAP server still uses LDAPv2, explicitly enable the use of this protocol version by selecting .
Select to mount remote
directories on your client, such as a remotely managed
/home.
Select to have a user's home automatically created on the first user login.
Click to apply your settings.
To modify data on the server as administrator, click . The following dialog is split in two tabs. See Figure 35.3, “YaST: Advanced Configuration”.
In the tab, adjust the following settings to your needs:
If the search base for users, passwords, and groups differs from the global search base specified the , enter these different naming contexts in , , and .
Specify the password change protocol. The standard method to
use whenever a password is changed is crypt,
meaning that password hashes generated by crypt are
used. For details on this and other options, refer to the
pam_ldap man page.
Specify the LDAP group to use with . The default value for this is
member.
In , adjust the following settings:
Set the base for storing your user management data via .
Enter the appropriate value for . This DN must be identical with the
rootdn value specified in
/etc/openldap/slapd.conf to enable this
particular user to manipulate data stored on the LDAP server.
Enter the full DN (such as cn=Administrator,dc=example,dc=com) or
activate to have the
base DN added automatically when you enter
cn=Administrator.
Check to create the basic configuration objects on the server to enable user management via LDAP.
If your client machine should act as a file server for home directories across your network, check .
Use the section to select, add, delete, or modify the password policy settings to use. The configuration of password policies with YaST is part of the LDAP server setup.
Click to leave the then to apply your settings.
Use to edit entries on the LDAP server. Access to the configuration modules on the server is then granted according to the ACLs and ACIs stored on the server. Follow the procedures outlined in Section 35.3.2.2, “Configuring the YaST Group and User Administration Modules”.
Use the YaST LDAP client to adapt the YaST modules for user and group administration and to extend them as needed. Define templates with default values for the individual attributes to simplify the data registration. The presets created here are stored as LDAP objects in the LDAP directory. The registration of user data is still done with the regular YaST modules for user and group management. The registered data is stored as LDAP objects on the server.
The dialog for module configuration (Figure 35.4, “YaST: Module Configuration”) allows the creation of new modules, selection and modification of existing configuration modules, and design and modification of templates for such modules.
To create a new configuration module, proceed as follows:
Click and select the type of module
to create. For a user configuration module, select
suseuserconfiguration and for a group configuration
choose susegroupconfiguration.
Choose a name for the new template. The content view then features a table listing all attributes allowed in this module with their assigned values. Apart from all set attributes, the list also contains all other attributes allowed by the current schema but currently not used.
Accept the preset values or adjust the defaults to use in group
and user configuration by selecting the respective attribute, pressing
, and entering the new value. Rename a module by
simply changing the cn attribute of the
module. Clicking deletes the currently
selected module.
After you click , the new module is added to the selection menu.
The YaST modules for group and user administration embed templates with sensible standard values. To edit a template associated with a configuration module, proceed as follows:
In the dialog, click .
Determine the values of the general attributes assigned to this template according to your needs or leave some of them empty. Empty attributes are deleted on the LDAP server.
Modify, delete, or add new default values for new objects (user or group configuration objects in the LDAP tree).
Connect the template to its module by setting the
susedefaulttemplate attribute value of the module to
the DN of the adapted template.
![]() | |
The default values for an attribute can be created from other
attributes by using a variable instead of an absolute value. For
example, when creating a new user, | |
Once all modules and templates are configured correctly and ready to run, new groups and users can be registered in the usual way with YaST.
The actual registration of user and group data differs only slightly from the procedure when not using LDAP. The following brief instructions relate to the administration of users. The procedure for administering groups is analogous.
Access the YaST user administration with +.
Use to limit the view of users to the LDAP users and enter the password for Root DN.
Click and enter the configuration of a new user. A dialog with four tabs opens:
Specify username, login, and password in the tab.
Check the tab for the group membership, login shell, and home directory of the new user. If necessary, change the default to values that better suit your needs. The default values as well as those of the password settings can be defined with the procedure described in Section 35.3.2.2, “Configuring the YaST Group and User Administration Modules”.
Modify or accept the default .
Enter the tab, select the LDAP plug-in, and click to configure additional LDAP attributes assigned to the new user (see Figure 35.6, “YaST: Additional LDAP Settings”).
Click to apply your settings and leave the user configuration.
The initial input form of user administration offers . This gives the possibility to apply LDAP search filters to the set of available users or go to the module for the configuration of LDAP users and groups by selecting .
To browse the LDAP directory tree and all its entries conveniently, use the YaST LDAP Browser:
Log in as root.
Start ++.
Enter the address of the LDAP server, the AdministratorDN, and the password for the RootDN of this server if you need both to read and write the data stored on the server.
Alternatively, choose and do not provide the password to gain read access to the directory.
The tab displays the content of the LDAP directory to which your machine connected. Click items to unfold their subitems.
To view any of the entries in detail, select it in the view and open the tab.
All attributes and values associated with this entry are displayed.
To change the value of any of these attributes, select the attribute, click , enter the new value, click , and provide the RootDN password when prompted.
Leave the LDAP browser with .
More complex subjects, like SASL configuration or establishment of a replicating LDAP server that distributes the workload among multiple slaves, were intentionally not included in this chapter. Detailed information about both subjects can be found in the OpenLDAP 2.2 Administrator's Guide.
The Web site of the OpenLDAP project offers exhaustive documentation for beginning and advanced LDAP users:
A very rich question and answer collection concerning installation, configuration, and use of OpenLDAP. Find it at http://www.openldap.org/faq/data/cache/1.html.
Brief step-by-step instructions for installing your first LDAP
server. Find it at
http://www.openldap.org/doc/admin22/quickstart.html
or on an installed system in
/usr/share/doc/packages/openldap2/admin-guide/quickstart.html.
A detailed introduction to all important aspects of LDAP
configuration, including access controls and encryption. See http://www.openldap.org/doc/admin22/ or, on an installed
system,
/usr/share/doc/packages/openldap2/admin-guide/index.html.
A detailed general introduction to the basic principles of LDAP: http://www.redbooks.ibm.com/redbooks/pdfs/sg244986.pdf.
Printed literature about LDAP:
LDAP System Administration by Gerald Carter (ISBN 1-56592-491-6)
Understanding and Deploying LDAP Directory Services by Howes, Smith, and Good (ISBN 0-672-32316-8)
The ultimate reference material for the subject of LDAP is the corresponding RFCs (request for comments), 2251 to 2256.