The third officially supported passdb module is the ldapsam backend. A complete discussion of LDAP is beyond the scope of this book. If you are interested in LDAP and directory services, a recommended resource is LDAP System Administration, by Gerald Carter (OíReilly). The remainder of this section assumes a basic level of comfort with LDAP directories and the OpenLDAP software in particular. If you are using a directory server from a different vendor, the examples should prove easy to adapt.
When you consider the ldapsam backend, the first thing to do is to become familiar with the schema. There are two auxiliary classes and one structural object class that will be encountered in relation to users and groups:
All the necessary attributes and object classes are defined in an OpenLDAP 2.x compatible schema file named samba.schema located in the examples/LDAP directory of the Samba source distribution. In this same location are schema files for other directory services as well, although these may not be up to date. Make sure that you include or import the appropriate schema file into your LDAP serverís configuration. Be aware that Sambaís OpenLDAP schema file requires you include the nis.schema, inetorgperson.schema, and cosine.schema files first.
Remember that the LanMan ( sambaLMPassword ) and NT ( sambaNTPassword ) password hashes stored in the sambaSamAccount object are plain-text equivalents and should never be made readable to users. Access control rules should restrict these attributes to administrative users only, such as Sambaís ldap admin dn distinguished name (discussed a few paragraphs ahead). The following ACLs in OpenLDAPís slapd.conf file protect the passwords from normal users but allow them to be read and modified by Samba:
## protect the samba password hashes
For performance reasons, the directory service should support fast equality searches on the uid , cn , sambaSID , gidNumber , uidNumber , and displayName attributes. Newer Samba releases (beginning with 3.0.23) also use a substring matching rule on the sambaSID attribute. To effect this performance enhancement, add the following indexes (or their equivalents) to the serverís database section, if any are missing.
## Samba's index settings for OpenLDAP's slapd.conf
Finally, it may be necessary to restart your directory server and/or rerun indexing tools to get it to recognize the changes.
Begin configuring smb.conf by setting up the connection parameters, starting with the LDAP serverís URI in the passdb backend value.
By default, all LDAP requests are sent to the directory in an unencrypted form. Unless the master LDAP server and Samba are running on the same machine, it is highly recommended that you take steps to secure the LDAP traffic from eavesdrop ping. Even when an LDAP replica is running locally on the Samba host, any referrals going back to the master LDAP server must still be encrypted.
Use the ldaps:// URI in the passdb backend option if you wish to connect using LDAP over SSL. However, using StartTLS is the recommended method for configuring data privacy when communicating with an LDAP directory. In this case, the ldap:// URI suffices. To enable StartTLS support, add the following setting to the [global] section:
ldap ssl = start_tls
It is possible to include multiple LDAP URIs in a single-quoted string for purposes of fault tolerance or load balancing. If there are two servers, ldap1 and ldap2, which are replicas of the directory, we can configure Samba to use one in case the other is unavailable. The list of servers is passed on to the underlying LDAP client libraries, which handle the actual network connection details and any failover behavior. The ldap ssl parameter is included here to reiterate the need to secure all communication with the directory service; its value, however, specifies the use of StartTLS instead of SSL:
passdb backend = ldapsam:"ldap://ldap1/ ldap://ldap2/ "
Samba treats LDAP as another storage facility for users and groups. Thus all of the userís attributes are retrieved from the directory when a SMB/CIFS connection request must be authenticated. When configuring the directory service access con trol settings, we restricted the password hashes to be readable only by Samba itself when using its ldap admin dn distinguished name to bind to the server:
ldap admin dn = cn=smbadmin,ou=people,dc=example,dc=com
The password associated with this privileged DN is stored in clear text separately in secrets.tdb. The smbpasswd command can store these credentials interactively ( -W option) or on a command line ( -w option). Here we have chosen to enter it interactively so that the password will not be displayed in the output of ps:
root# smbpasswd -W
The final bit of information that Samba requires for ldapsam is the set of base suffixes used to query and store users and groups. The top-level suffix is specified by the ldap suffix option. This DN should be the parent of the other smb.conf search suffixes, which are specified by the following options:
ldap user suffix
ldap machine suffix
ldap group suffix
ldap idmap suffix
The ldap suffix should be specified first in smb.conf and should be a full DN. The remaining search suffixes should be defined relative to the ldap suffix value. In order to support a directory name space such as the directory information tree (DIT) shown in Figure 5-2, we would add the following parameters to Sambaís configuration:
It is possible to define different machine and user suffixes. If you do so, the serverís LDAP NSS module must search both bases when querying for a posixAccount . As one of the Samba developers has said, ďMachines are people too.Ē The nss_ldap library from PADL software (http://www.padl.com) supports this by enabling the
libraryís RFC2307bis extensions (pass the --enable-rfc2307bis option to the nss_ldap configure script when compiling) and then defining multiple nss_base_passwd directives in its configuration file (usually /etc/ldap.conf). The complete details of PADLís nss_ldap configuration is beyond the scope of this discussion. For more information, please refer to PADLís web site and the documentation included with its software.
To finish off the section, Table 5-10 lists the LDAP-related parameters supported in smb.conf. Samba and LDAP integration are revisited in Chapters 9 and 10.
blog comments powered by Disqus