1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % global_entities SYSTEM '../entities/global.entities'>
14 <author>&person.gd;<contrib>LDAP updates</contrib></author>
16 <firstname>Olivier (lem)</firstname><surname>Lemaire</surname>
18 <orgname>IDEALX</orgname>
19 <address><email>olem@IDEALX.org</email></address>
23 <pubdate>May 24, 2003</pubdate>
25 <title>Account Information Databases</title>
28 Samba-3 implements a new capability to work concurrently with multiple account backends.
29 The possible new combinations of password backends allows Samba-3 a degree of flexibility
30 and scalability that previously could be achieved only with MS Windows Active Directory.
31 This chapter describes the new functionality and how to get the most out of it.
35 <title>Features and Benefits</title>
38 Samba-3 provides for complete backward compatibility with Samba-2.2.x functionality
40 <indexterm><primary>SAM backend</primary><secondary>smbpasswd</secondary></indexterm>
41 <indexterm><primary>SAM backend</primary><secondary>ldapsam_compat</secondary></indexterm>
42 <indexterm><primary>encrypted passwords</primary></indexterm>
48 <title>Backward Compatibility Backends</title>
51 <varlistentry><term>Plain Text</term>
54 This option uses nothing but the UNIX/Linux <filename>/etc/passwd</filename>
55 style backend. On systems that have Pluggable Authentication Modules (PAM)
56 support, all PAM modules are supported. The behavior is just as it was with
57 Samba-2.2.x, and the protocol limitations imposed by MS Windows clients
58 apply likewise. Please refer to <link linkend="passdbtech">Technical Information</link> for more information
59 regarding the limitations of Plain Text password usage.
64 <varlistentry><term>smbpasswd</term>
67 This option allows continued use of the <filename>smbpasswd</filename>
68 file that maintains a plain ASCII (text) layout that includes the MS Windows
69 LanMan and NT encrypted passwords as well as a field that stores some
70 account information. This form of password backend does not store any of
71 the MS Windows NT/200x SAM (Security Account Manager) information required to
72 provide the extended controls that are needed for more comprehensive
73 inter-operation with MS Windows NT4/200x servers.
77 This backend should be used only for backward compatibility with older
78 versions of Samba. It may be deprecated in future releases.
83 <varlistentry><term>ldapsam_compat (Samba-2.2 LDAP Compatibility)</term>
86 There is a password backend option that allows continued operation with
87 an existing OpenLDAP backend that uses the Samba-2.2.x LDAP schema extension.
88 This option is provided primarily as a migration tool, although there is
89 no reason to force migration at this time. This tool will eventually
99 Samba-3 introduces a number of new password backend capabilities.
100 <indexterm><primary>SAM backend</primary><secondary>tdbsam</secondary></indexterm>
101 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
102 <indexterm><primary>SAM backend</primary><secondary>mysqlsam</secondary></indexterm>
103 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
107 <title>New Backends</title>
110 <varlistentry><term>tdbsam</term>
113 This backend provides a rich database backend for local servers. This
114 backend is not suitable for multiple Domain Controllers (i.e., PDC + one
115 or more BDC) installations.
119 The <emphasis>tdbsam</emphasis> password backend stores the old <emphasis>
120 smbpasswd</emphasis> information plus the extended MS Windows NT / 200x
121 SAM information into a binary format TDB (trivial database) file.
122 The inclusion of the extended information makes it possible for Samba-3
123 to implement the same account and system access controls that are possible
124 with MS Windows NT4/200x-based systems.
128 The inclusion of the <emphasis>tdbsam</emphasis> capability is a direct
129 response to user requests to allow simple site operation without the overhead
130 of the complexities of running OpenLDAP. It is recommended to use this only
131 for sites that have fewer than 250 users. For larger sites or implementations,
132 the use of OpenLDAP or of Active Directory integration is strongly recommended.
137 <varlistentry><term>ldapsam</term>
140 This provides a rich directory backend for distributed account installation.
144 Samba-3 has a new and extended LDAP implementation that requires configuration
145 of OpenLDAP with a new format Samba schema. The new format schema file is
146 included in the <filename class="directory">examples/LDAP</filename> directory of the Samba distribution.
150 The new LDAP implementation significantly expands the control abilities that
151 were possible with prior versions of Samba. It is now possible to specify
152 <quote>per user</quote> profile settings, home directories, account access controls, and
153 much more. Corporate sites will see that the Samba Team has listened to their
154 requests both for capability and to allow greater scalability.
159 <varlistentry><term>mysqlsam (MySQL based backend)</term>
162 It is expected that the MySQL-based SAM will be very popular in some corners.
163 This database backend will be of considerable interest to sites that want to
164 leverage existing MySQL technology.
169 <varlistentry><term>xmlsam (XML based datafile)</term>
172 <indexterm><primary>pdbedit</primary></indexterm>
173 Allows the account and password data to be stored in an XML format
174 data file. This backend cannot be used for normal operation, it can only
175 be used in conjunction with <command>pdbedit</command>'s pdb2pdb
176 functionality. The DTD that is used might be subject to changes in the future.
180 The <parameter>xmlsam</parameter> option can be useful for account migration between database
181 backends or backups. Use of this tool will allow the data to be edited before migration
182 into another backend format.
193 <sect1 id="passdbtech">
194 <title>Technical Information</title>
197 Old Windows clients send plain text passwords over the wire. Samba can check these
198 passwords by encrypting them and comparing them to the hash stored in the UNIX user database.
202 <indexterm><primary>encrypted passwords</primary></indexterm>
203 Newer Windows clients send encrypted passwords (so-called LanMan and NT hashes) over
204 the wire, instead of plain text passwords. The newest clients will send only encrypted
205 passwords and refuse to send plain text passwords, unless their registry is tweaked.
209 These passwords can't be converted to UNIX-style encrypted passwords. Because of that,
210 you can't use the standard UNIX user database, and you have to store the LanMan and NT
211 hashes somewhere else.
215 In addition to differently encrypted passwords, Windows also stores certain data for each
216 user that is not stored in a UNIX user database. For example, workstations the user may logon from,
217 the location where the user's profile is stored, and so on. Samba retrieves and stores this
218 information using a <smbconfoption><name>passdb backend</name></smbconfoption>. Commonly available backends are LDAP, plain text
219 file, and MySQL. For more information, see the man page for &smb.conf; regarding the
220 <smbconfoption><name>passdb backend</name></smbconfoption> parameter.
224 <image scale="50" id="idmap-sid2uid"><imagedescription>IDMAP: Resolution of SIDs to UIDs.</imagedescription><imagefile>idmap-sid2uid</imagefile></image>
227 <indexterm><primary>SID</primary></indexterm>
228 The resolution of SIDs to UIDs is fundamental to correct operation of Samba. In both cases shown, if winbindd is not running, or cannot
229 be contacted, then only local SID/UID resolution is possible. See <link linkend="idmap-sid2uid">resolution of SIDs to UIDs</link> and
230 <link linkend="idmap-uid2sid">resolution of UIDs to SIDs</link> diagrams.
233 <image scale="50" id="idmap-uid2sid"><imagedescription>IDMAP: Resolution of UIDs to SIDs.</imagedescription><imagefile>idmap-uid2sid</imagefile></image>
236 <title>Important Notes About Security</title>
239 The UNIX and SMB password encryption techniques seem similar on the surface. This
240 similarity is, however, only skin deep. The UNIX scheme typically sends clear-text
241 passwords over the network when logging in. This is bad. The SMB encryption scheme
242 never sends the clear-text password over the network but it does store the 16 byte
243 hashed values on disk. This is also bad. Why? Because the 16 byte hashed values
244 are a <quote>password equivalent.</quote> You cannot derive the user's password from them, but
245 they could potentially be used in a modified client to gain access to a server.
246 This would require considerable technical knowledge on behalf of the attacker but
247 is perfectly possible. You should thus treat the data stored in whatever passdb
248 backend you use (smbpasswd file, LDAP, MYSQL) as though it contained the clear-text
249 passwords of all your users. Its contents must be kept secret and the file should
250 be protected accordingly.
254 Ideally, we would like a password scheme that involves neither plain text passwords
255 on the network nor on disk. Unfortunately, this is not available as Samba is stuck with
256 having to be compatible with other SMB systems (Windows NT, Windows for Workgroups, Windows 9x/Me).
260 Windows NT 4.0 Service Pack 3 changed the default setting so plaintext passwords
261 are disabled from being sent over the wire. This mandates either the use of encrypted
262 password support or editing the Windows NT registry to re-enable plaintext passwords.
266 The following versions of Microsoft Windows do not support full domain security protocols,
267 although they may log onto a domain environment:
271 <listitem><para>MS DOS Network client 3.0 with the basic network redirector installed.</para></listitem>
272 <listitem><para>Windows 95 with the network redirector update installed.</para></listitem>
273 <listitem><para>Windows 98 [Second Edition].</para></listitem>
274 <listitem><para>Windows Me.</para></listitem>
279 MS Windows XP Home does not have facilities to become a Domain Member and it cannot participate in domain logons.
284 The following versions of MS Windows fully support domain security protocols.
288 <listitem><para>Windows NT 3.5x.</para></listitem>
289 <listitem><para>Windows NT 4.0.</para></listitem>
290 <listitem><para>Windows 2000 Professional.</para></listitem>
291 <listitem><para>Windows 200x Server/Advanced Server.</para></listitem>
292 <listitem><para>Windows XP Professional.</para></listitem>
296 All current releases of Microsoft SMB/CIFS clients support authentication via the
297 SMB Challenge/Response mechanism described here. Enabling clear-text authentication
298 does not disable the ability of the client to participate in encrypted authentication.
299 Instead, it allows the client to negotiate either plain text or encrypted password
304 MS Windows clients will cache the encrypted password alone. Where plain text passwords
305 are re-enabled through the appropriate registry change, the plain text password is never
306 cached. This means that in the event that a network connections should become disconnected
307 (broken), only the cached (encrypted) password will be sent to the resource server to
308 effect an auto-reconnect. If the resource server does not support encrypted passwords the
309 auto-reconnect will fail. Use of encrypted passwords is strongly advised.
313 <title>Advantages of Encrypted Passwords</title>
316 <listitem><para>Plaintext passwords are not passed across
317 the network. Someone using a network sniffer cannot just
318 record passwords going to the SMB server.</para></listitem>
320 <listitem><para>Plaintext passwords are not stored anywhere in
321 memory or on disk.</para></listitem>
323 <listitem><para>Windows NT does not like talking to a server
324 that does not support encrypted passwords. It will refuse
325 to browse the server if the server is also in User Level
326 security mode. It will insist on prompting the user for the
327 password on each connection, which is very annoying. The
328 only things you can do to stop this is to use SMB encryption.
331 <listitem><para>Encrypted password support allows automatic share
332 (resource) reconnects.</para></listitem>
334 <listitem><para>Encrypted passwords are essential for PDC/BDC
335 operation.</para></listitem>
341 <title>Advantages of Non-Encrypted Passwords</title>
344 <listitem><para>Plaintext passwords are not kept
345 on disk, and are not cached in memory. </para></listitem>
347 <listitem><para>Uses same password file as other UNIX
348 services such as Login and FTP.</para></listitem>
350 <listitem><para>Use of other services (such as Telnet and FTP) that
351 send plain text passwords over the network, so sending them for SMB
352 is not such a big deal.</para></listitem>
358 <title>Mapping User Identifiers between MS Windows and UNIX</title>
361 Every operation in UNIX/Linux requires a user identifier (UID), just as in
362 MS Windows NT4/200x this requires a Security Identifier (SID). Samba provides
363 two means for mapping an MS Windows user to a UNIX/Linux UID.
367 First, all Samba SAM (Security Account Manager database) accounts require
368 a UNIX/Linux UID that the account will map to. As users are added to the account
369 information database, Samba will call the <smbconfoption><name>add user script</name></smbconfoption>
370 interface to add the account to the Samba host OS. In essence all accounts in
371 the local SAM require a local user account.
375 The second way to effect Windows SID to UNIX UID mapping is via the
376 <emphasis>idmap uid</emphasis> and <emphasis>idmap gid</emphasis> parameters in &smb.conf;.
377 Please refer to the man page for information about these parameters.
378 These parameters are essential when mapping users from a remote SAM server.
383 <sect2 id="idmapbackend">
384 <title>Mapping Common UIDs/GIDs on Distributed Machines</title>
387 Samba-3 has a special facility that makes it possible to maintain identical UIDs and GIDs
388 on all servers in a distributed network. A distributed network is one where there exists
389 a PDC, one or more BDCs and/or one or more Domain Member servers. Why is this important?
390 This is important if files are being shared over more than one protocol (e.g., NFS) and where
391 users are copying files across UNIX/Linux systems using tools such as <command>rsync</command>.
395 The special facility is enabled using a parameter called <parameter>idmap backend</parameter>.
396 The default setting for this parameter is an empty string. Technically it is possible to use
397 an LDAP based idmap backend for UIDs and GIDs, but it makes most sense when this is done for
398 network configurations that also use LDAP for the SAM backend. Following
399 <link linkend="idmapbackendexample">example</link> shows that.
403 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
404 <smbconfexample id="idmapbackendexample">
405 <title>Example configuration with the LDAP idmap backend</title>
406 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
407 <smbconfsection>[global]</smbconfsection>
408 <smbconfoption><name>idmap backend</name><value>ldap:ldap://ldap-server.quenya.org:636</value></smbconfoption>
409 <smbcomment>Alternately, this could be specified as:</smbcomment>
410 <smbconfoption><name>idmap backend</name><value>ldap:ldaps://ldap-server.quenya.org</value></smbconfoption>
415 A network administrator who wants to make significant use of LDAP backends will sooner or later be
416 exposed to the excellent work done by PADL Software. PADL <ulink url="http://www.padl.com"/> have
417 produced and released to open source an array of tools that might be of interest. These tools include:
423 <emphasis>nss_ldap:</emphasis> An LDAP Name Service Switch module to provide native
424 name service support for AIX, Linux, Solaris, and other operating systems. This tool
425 can be used for centralized storage and retrieval of UIDs/GIDs.
431 <emphasis>pam_ldap:</emphasis> A PAM module that provides LDAP integration for UNIX/Linux
432 system access authentication.
437 <emphasis>idmap_ad:</emphasis> An IDMAP backend that supports the Microsoft Services for
438 UNIX RFC 2307 schema available from their web
439 <ulink url="http://www.padl.com/download/xad_oss_plugins.tar.gz">site</ulink>.
448 <sect1 id="acctmgmttools">
449 <title>Account Management Tools</title>
452 <indexterm><primary>pdbedit</primary></indexterm>
453 Samba provides two tools for management of user and machine accounts. These tools are
454 called <command>smbpasswd</command> and <command>pdbedit</command>.
457 <title>The <emphasis>smbpasswd</emphasis> Command</title>
460 The smbpasswd utility is similar to the <command>passwd</command>
461 or <command>yppasswd</command> programs. It maintains the two 32 byte password
462 fields in the passdb backend.
466 <command>smbpasswd</command> works in a client-server mode where it contacts the
467 local smbd to change the user's password on its behalf. This has enormous benefits.
471 <command>smbpasswd</command> has the capability to change passwords on Windows NT
472 servers (this only works when the request is sent to the NT Primary Domain Controller
473 if changing an NT Domain user's password).
477 <command>smbpasswd</command> can be used to:
478 <indexterm><primary>User Management</primary></indexterm>
479 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
484 <listitem><para><emphasis>add</emphasis> user or machine accounts.</para></listitem>
485 <listitem><para><emphasis>delete</emphasis> user or machine accounts.</para></listitem>
486 <listitem><para><emphasis>enable</emphasis> user or machine accounts.</para></listitem>
487 <listitem><para><emphasis>disable</emphasis> user or machine accounts.</para></listitem>
488 <listitem><para><emphasis>set to NULL</emphasis> user passwords.</para></listitem>
489 <listitem><para><emphasis>manage interdomain trust accounts.</emphasis></para></listitem>
493 To run smbpasswd as a normal user just type:
498 &prompt;<userinput>smbpasswd</userinput>
499 <prompt>Old SMB password: </prompt><userinput><replaceable>secret</replaceable></userinput>
501 For <replaceable>secret</replaceable>, type old value here or press return if
502 there is no old password.
504 <prompt>New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
505 <prompt>Repeat New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
510 If the old value does not match the current value stored for that user, or the two
511 new values do not match each other, then the password will not be changed.
515 When invoked by an ordinary user, the command will only allow the user to change his or her own
520 When run by root, <command>smbpasswd</command> may take an optional argument specifying
521 the user name whose SMB password you wish to change. When run as root, <command>smbpasswd</command>
522 does not prompt for or check the old password value, thus allowing root to set passwords
523 for users who have forgotten their passwords.
527 <command>smbpasswd</command> is designed to work in the way familiar to UNIX
528 users who use the <command>passwd</command> or <command>yppasswd</command> commands.
529 While designed for administrative use, this tool provides essential User Level
530 password change capabilities.
534 For more details on using <command>smbpasswd</command>, refer to the man page (the
535 definitive reference).
539 <sect2 id="pdbeditthing">
540 <title>The <emphasis>pdbedit</emphasis> Command</title>
543 <indexterm><primary>pdbedit</primary></indexterm>
544 <command>pdbedit</command> is a tool that can be used only by root. It is used to
545 manage the passdb backend. <command>pdbedit</command> can be used to:
546 <indexterm><primary>User Management</primary></indexterm>
547 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
552 <listitem><para>add, remove or modify user accounts.</para></listitem>
553 <listitem><para>list user accounts.</para></listitem>
554 <listitem><para>migrate user accounts.</para></listitem>
558 <indexterm><primary>pdbedit</primary></indexterm>
559 The <command>pdbedit</command> tool is the only one that can manage the account
560 security and policy settings. It is capable of all operations that smbpasswd can
561 do as well as a super set of them.
565 <indexterm><primary>pdbedit</primary></indexterm>
566 One particularly important purpose of the <command>pdbedit</command> is to allow
567 the migration of account information from one passdb backend to another. See the
568 <link linkend="XMLpassdb">XML</link> password backend section of this chapter.
572 The following is an example of the user account information that is stored in
573 a tdbsam password backend. This listing was produced by running:
577 &prompt;<userinput>pdbedit -Lv met</userinput>
581 User SID: S-1-5-21-1449123459-1407424037-3116680435-2004
582 Primary Group SID: S-1-5-21-1449123459-1407424037-3116680435-1201
583 Full Name: Melissa E Terpstra
584 Home Directory: \\frodo\met\Win9Profile
586 Logon Script: scripts\logon.bat
587 Profile Path: \\frodo\Profiles\met
588 Domain: &example.workgroup;
590 Workstations: melbelle
593 Logoff time: Mon, 18 Jan 2038 20:14:07 GMT
594 Kickoff time: Mon, 18 Jan 2038 20:14:07 GMT
595 Password last set: Sat, 14 Dec 2002 14:37:03 GMT
596 Password can change: Sat, 14 Dec 2002 14:37:03 GMT
597 Password must change: Mon, 18 Jan 2038 20:14:07 GMT
601 <indexterm><primary>pdbedit</primary></indexterm>
602 The <command>pdbedit</command> tool allows migration of authentication (account)
603 databases from one backend to another. For example: To migrate accounts from an
604 old <filename>smbpasswd</filename> database to a <parameter>tdbsam</parameter>
610 Set the <smbconfoption><name>passdb backend</name><value>tdbsam, smbpasswd</value></smbconfoption>.
616 &rootprompt;<userinput>pdbedit -i smbpasswd -e tdbsam</userinput>
621 Now remove the <parameter>smbpasswd</parameter> from the passdb backend
622 configuration in &smb.conf;.
630 <title>Password Backends</title>
633 Samba offers the greatest flexibility in backend account database design of any SMB/CIFS server
634 technology available today. The flexibility is immediately obvious as one begins to explore this
639 It is possible to specify not only multiple different password backends, but even multiple
640 backends of the same type. For example, to use two different tdbsam databases:
645 <smbconfoption><name>passdb backend</name><value>tdbsam:/etc/samba/passdb.tdb \</value></smbconfoption>
646 <member><parameter>tdbsam:/etc/samba/old-passdb.tdb</parameter></member>
652 <title>Plaintext</title>
655 Older versions of Samba retrieved user information from the UNIX user database
656 and eventually some other fields from the file <filename>/etc/samba/smbpasswd</filename>
657 or <filename>/etc/smbpasswd</filename>. When password encryption is disabled, no
658 SMB specific data is stored at all. Instead all operations are conducted via the way
659 that the Samba host OS will access its <filename>/etc/passwd</filename> database.
660 Linux systems For example, all operations are done via PAM.
666 <title>smbpasswd &smbmdash; Encrypted Password Database</title>
669 <indexterm><primary>SAM backend</primary><secondary>smbpasswd</secondary></indexterm>
670 Traditionally, when configuring <smbconfoption><name>encrypt passwords</name><value>yes</value></smbconfoption> in Samba's &smb.conf; file, user account
671 information such as username, LM/NT password hashes, password change times, and account
672 flags have been stored in the <filename>smbpasswd(5)</filename> file. There are several
673 disadvantages to this approach for sites with large numbers of users (counted
679 The first problem is that all lookups must be performed sequentially. Given that
680 there are approximately two lookups per domain logon (one for a normal
681 session connection such as when mapping a network drive or printer), this
682 is a performance bottleneck for large sites. What is needed is an indexed approach
683 such as used in databases.
687 The second problem is that administrators who desire to replicate a smbpasswd file
688 to more than one Samba server were left to use external tools such as
689 <command>rsync(1)</command> and <command>ssh(1)</command> and wrote custom,
694 Finally, the amount of information that is stored in an smbpasswd entry leaves
695 no room for additional attributes such as a home directory, password expiration time,
696 or even a Relative Identifier (RID).
701 As a result of these deficiencies, a more robust means of storing user attributes
702 used by smbd was developed. The API which defines access to user accounts
703 is commonly referred to as the samdb interface (previously this was called the passdb
704 API, and is still so named in the Samba CVS trees).
708 Samba provides an enhanced set of passdb backends that overcome the deficiencies
709 of the smbpasswd plain text database. These are tdbsam, ldapsam and xmlsam.
710 Of these, ldapsam will be of most interest to large corporate or enterprise sites.
716 <title>tdbsam</title>
719 <indexterm><primary>SAM backend</primary><secondary>tdbsam</secondary></indexterm>
720 Samba can store user and machine account data in a <quote>TDB</quote> (Trivial Database).
721 Using this backend does not require any additional configuration. This backend is
722 recommended for new installations that do not require LDAP.
726 As a general guide, the Samba Team does not recommend using the tdbsam backend for sites
727 that have 250 or more users. Additionally, tdbsam is not capable of scaling for use
728 in sites that require PDB/BDC implementations that require replication of the account
729 database. Clearly, for reason of scalability, the use of ldapsam should be encouraged.
733 The recommendation of a 250 user limit is purely based on the notion that this
734 would generally involve a site that has routed networks, possibly spread across
735 more than one physical location. The Samba Team has not at this time established
736 the performance based scalability limits of the tdbsam architecture.
742 <title>ldapsam</title>
745 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
746 There are a few points to stress that the ldapsam does not provide. The LDAP
747 support referred to in this documentation does not include:
751 <listitem><para>A means of retrieving user account information from
752 an Windows 200x Active Directory server.</para></listitem>
753 <listitem><para>A means of replacing /etc/passwd.</para></listitem>
757 The second item can be accomplished by using LDAP NSS and PAM modules. LGPL
758 versions of these libraries can be obtained from
759 <ulink url="http://www.padl.com/">PADL Software</ulink>.
760 More information about the configuration of these packages may be found at
761 <ulink url="http://safari.oreilly.com/?XmlId=1-56592-491-6">
762 <emphasis>LDAP, System Administration</emphasis>; Gerald Carter by O'Reilly; Chapter 6: Replacing NIS."</ulink>
766 This document describes how to use an LDAP directory for storing Samba user
767 account information traditionally stored in the smbpasswd(5) file. It is
768 assumed that the reader already has a basic understanding of LDAP concepts
769 and has a working directory server already installed. For more information
770 on LDAP architectures and directories, please refer to the following sites:
774 <listitem><para><ulink url="http://www.openldap.org/">OpenLDAP</ulink></para></listitem>
775 <listitem><para><ulink url="http://iplanet.netscape.com/directory">Sun iPlanet Directory Server</ulink></para></listitem>
779 Two additional Samba resources which may prove to be helpful are:
783 <listitem><para>The <ulink url="http://www.unav.es/cti/ldap-smb/ldap-smb-3-howto.html">Samba-PDC-LDAP-HOWTO</ulink>
784 maintained by Ignacio Coupeau.</para></listitem>
786 <listitem><para>The NT migration scripts from <ulink url="http://samba.idealx.org/">IDEALX</ulink> that are
787 geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
792 <title>Supported LDAP Servers</title>
795 The LDAP ldapsam code has been developed and tested using the OpenLDAP 2.0 and 2.1 server and
796 client libraries. The same code should work with Netscape's Directory Server and client SDK.
797 However, there are bound to be compile errors and bugs. These should not be hard to fix.
798 Please submit fixes via the process outlined in <link linkend="bugreport">Reporting Bugs</link> chapter.
804 <title>Schema and Relationship to the RFC 2307 posixAccount</title>
808 Samba-3.0 includes the necessary schema file for OpenLDAP 2.0 in
809 <filename>examples/LDAP/samba.schema</filename>. The sambaSamAccount ObjectClass is given here:
814 ObjectClass (1.3.6.1.4.1.7165.2.2.6 NAME 'sambaSamAccount' SUP top AUXILIARY
815 DESC 'Samba-3.0 Auxiliary SAM Account'
816 MUST ( uid $ sambaSID )
817 MAY ( cn $ sambaLMPassword $ sambaNTPassword $ sambaPwdLastSet $
818 sambaLogonTime $ sambaLogoffTime $ sambaKickoffTime $
819 sambaPwdCanChange $ sambaPwdMustChange $ sambaAcctFlags $
820 displayName $ sambaHomePath $ sambaHomeDrive $ sambaLogonScript $
821 sambaProfilePath $ description $ sambaUserWorkstations $
822 sambaPrimaryGroupSID $ sambaDomainName ))
827 The <filename>samba.schema</filename> file has been formatted for OpenLDAP 2.0/2.1.
828 The Samba Team owns the OID space used by the above schema and recommends its use.
829 If you translate the schema to be used with Netscape DS, please submit the modified
830 schema file as a patch to <ulink url="mailto:jerry@samba.org">jerry@samba.org</ulink>.
834 Just as the smbpasswd file is meant to store information that provides information additional to a
835 user's <filename>/etc/passwd</filename> entry, so is the sambaSamAccount object
836 meant to supplement the UNIX user account information. A sambaSamAccount is a
837 <constant>AUXILIARY</constant> ObjectClass so it can be used to augment existing
838 user account information in the LDAP directory, thus providing information needed
839 for Samba account handling. However, there are several fields (e.g., uid) that overlap
840 with the posixAccount ObjectClass outlined in RFC2307. This is by design.
843 <!--olem: we should perhaps have a note about shadowAccounts too as many
844 systems use them, isn'it ? -->
847 In order to store all user account information (UNIX and Samba) in the directory,
848 it is necessary to use the sambaSamAccount and posixAccount ObjectClass es in
849 combination. However, smbd will still obtain the user's UNIX account
850 information via the standard C library calls (e.g., getpwnam(), et al).
851 This means that the Samba server must also have the LDAP NSS library installed
852 and functioning correctly. This division of information makes it possible to
853 store all Samba account information in LDAP, but still maintain UNIX account
854 information in NIS while the network is transitioning to a full LDAP infrastructure.
859 <title>OpenLDAP Configuration</title>
862 To include support for the sambaSamAccount object in an OpenLDAP directory
863 server, first copy the samba.schema file to slapd's configuration directory.
864 The samba.schema file can be found in the directory <filename>examples/LDAP</filename>
865 in the Samba source distribution.
870 &rootprompt;<userinput>cp samba.schema /etc/openldap/schema/</userinput>
875 Next, include the <filename>samba.schema</filename> file in <filename>slapd.conf</filename>.
876 The sambaSamAccount object contains two attributes that depend on other schema
877 files. The <parameter>uid</parameter> attribute is defined in <filename>cosine.schema</filename> and
878 the <parameter>displayName</parameter> attribute is defined in the <filename>inetorgperson.schema</filename>
879 file. Both of these must be included before the <filename>samba.schema</filename> file.
884 ## /etc/openldap/slapd.conf
886 ## schema files (core.schema is required by default)
887 include /etc/openldap/schema/core.schema
889 ## needed for sambaSamAccount
890 include /etc/openldap/schema/cosine.schema
891 include /etc/openldap/schema/inetorgperson.schema
892 include /etc/openldap/schema/nis.schema
893 include /etc/openldap/schema/samba.schema
899 It is recommended that you maintain some indices on some of the most useful attributes,
900 as in the following example, to speed up searches made on sambaSamAccount objectclasses
901 (and possibly posixAccount and posixGroup as well):
906 # Indices to maintain
907 ## required by OpenLDAP
912 ## required to support pdb_getsampwnam
913 index uid pres,sub,eq
914 ## required to support pdb_getsambapwrid()
915 index displayName pres,sub,eq
917 ## uncomment these if you are storing posixAccount and
918 ## posixGroup entries in the directory as well
924 index sambaPrimaryGroupSID eq
925 index sambaDomainName eq
931 Create the new index by executing:
936 &rootprompt;./sbin/slapindex -f slapd.conf
941 Remember to restart slapd after making these changes:
946 &rootprompt;<userinput>/etc/init.d/slapd restart</userinput>
953 <title>Initialize the LDAP Database</title>
956 Before you can add accounts to the LDAP database you must create the account containers
957 that they will be stored in. The following LDIF file should be modified to match your
958 needs (DNS entries, and so on):
962 <smbfile name="samba.ldif.example">
964 # Organization for Samba Base
966 objectclass: dcObject
967 objectclass: organization
969 o: Quenya Org Network
970 description: The Samba-3 Network LDAP Example
972 # Organizational Role for Directory Management
973 dn: cn=Manager,dc=quenya,dc=org
974 objectclass: organizationalRole
976 description: Directory Manager
978 # Setting up container for users
979 dn: ou=People,dc=quenya,dc=org
981 objectclass: organizationalUnit
984 # Setting up admin handle for People OU
985 dn: cn=admin,ou=People,dc=quenya,dc=org
988 objectclass: organizationalRole
989 objectclass: simpleSecurityObject
990 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
992 # Setting up container for groups
993 dn: ou=Groups,dc=quenya,dc=org
995 objectclass: organizationalUnit
998 # Setting up admin handle for Groups OU
999 dn: cn=admin,ou=Groups,dc=quenya,dc=org
1002 objectclass: organizationalRole
1003 objectclass: simpleSecurityObject
1004 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1006 # Setting up container for computers
1007 dn: ou=Computers,dc=quenya,dc=org
1009 objectclass: organizationalUnit
1012 # Setting up admin handle for Computers OU
1013 dn: cn=admin,ou=Computers,dc=quenya,dc=org
1016 objectclass: organizationalRole
1017 objectclass: simpleSecurityObject
1018 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1024 The userPassword shown above should be generated using <command>slappasswd</command>.
1028 The following command will then load the contents of the LDIF file into the LDAP
1034 &prompt;<userinput>slapadd -v -l initldap.dif</userinput>
1039 Do not forget to secure your LDAP server with an adequate access control list
1040 as well as an admin password.
1045 Before Samba can access the LDAP server you need to store the LDAP admin password
1046 into the Samba-3 <filename>secrets.tdb</filename> database by:
1048 &rootprompt;<userinput>smbpasswd -w <replaceable>secret</replaceable></userinput>
1056 <title>Configuring Samba</title>
1059 The following parameters are available in smb.conf only if your
1060 version of Samba was built with LDAP support. Samba automatically builds with LDAP support if the
1061 LDAP libraries are found.
1064 <para>LDAP related smb.conf options:
1065 <smbconfoption><name>passdb backend</name><value>ldapsam:url</value></smbconfoption>,
1066 <smbconfoption><name>ldap admin dn</name></smbconfoption>,
1067 <smbconfoption><name>ldap delete dn</name></smbconfoption>,
1068 <smbconfoption><name>ldap filter</name></smbconfoption>,
1069 <smbconfoption><name>ldap group suffix</name></smbconfoption>,
1070 <smbconfoption><name>ldap idmap suffix</name></smbconfoption>,
1071 <smbconfoption><name>ldap machine suffix</name></smbconfoption>,
1072 <smbconfoption><name>ldap passwd sync</name></smbconfoption>,
1073 <smbconfoption><name>ldap ssl</name></smbconfoption>,
1074 <smbconfoption><name>ldap suffix</name></smbconfoption>,
1075 <smbconfoption><name>ldap user suffix</name></smbconfoption>,
1079 These are described in the &smb.conf; man
1080 page and so will not be repeated here. However, a <link linkend="confldapex">sample &smb.conf; file</link> for
1081 use with an LDAP directory could appear as shown below.
1085 <smbconfexample id="confldapex">
1086 <title>Configuration with LDAP</title>
1087 <smbconfsection>[global]</smbconfsection>
1088 <smbconfoption><name>security</name><value>user</value></smbconfoption>
1089 <smbconfoption><name>encrypt passwords</name><value>yes</value></smbconfoption>
1090 <smbconfoption><name>netbios name</name><value>MORIA</value></smbconfoption>
1091 <smbconfoption><name>workgroup</name><value>NOLDOR</value></smbconfoption>
1093 <smbconfcomment>ldap related parameters</smbconfcomment>
1095 <smbconfcomment>define the DN to use when binding to the directory servers</smbconfcomment>
1096 <smbconfcomment>The password for this DN is not stored in smb.conf. Rather it</smbconfcomment>
1097 <smbconfcomment>must be set by using 'smbpasswd -w <replaceable>secretpw</replaceable>' to store the</smbconfcomment>
1098 <smbconfcomment>passphrase in the secrets.tdb file. If the "ldap admin dn" values</smbconfcomment>
1099 <smbconfcomment>change, this password will need to be reset.</smbconfcomment>
1100 <smbconfoption><name>ldap admin dn</name><value>"cn=Manager,dc=quenya,dc=org"</value></smbconfoption>
1102 <smbconfcomment>Define the SSL option when connecting to the directory</smbconfcomment>
1103 <smbconfcomment>('off', 'start tls', or 'on' (default))</smbconfcomment>
1104 <smbconfoption><name>ldap ssl</name><value>start tls</value></smbconfoption>
1106 <smbconfcomment>syntax: passdb backend = ldapsam:ldap://server-name[:port]</smbconfcomment>
1107 <smbconfoption><name>passdb backend</name><value>ldapsam:ldap://frodo.quenya.org</value></smbconfoption>
1109 <smbconfcomment>smbpasswd -x delete the entire dn-entry</smbconfcomment>
1110 <smbconfoption><name>ldap delete dn</name><value>no</value></smbconfoption>
1112 <smbconfcomment>the machine and user suffix added to the base suffix</smbconfcomment>
1113 <smbconfcomment>wrote WITHOUT quotes. NULL suffixes by default</smbconfcomment>
1114 <smbconfoption><name>ldap user suffix</name><value>ou=People</value></smbconfoption>
1115 <smbconfoption><name>ldap group suffix</name><value>ou=Groups</value></smbconfoption>
1116 <smbconfoption><name>ldap machine suffix</name><value>ou=Computers</value></smbconfoption>
1118 <smbconfcomment>Trust UNIX account information in LDAP</smbconfcomment>
1119 <smbconfcomment> (see the smb.conf man page for details)</smbconfcomment>
1121 <smbconfcomment> specify the base DN to use when searching the directory</smbconfcomment>
1122 <smbconfoption><name>ldap suffix</name><value>dc=quenya,dc=org</value></smbconfoption>
1124 <smbconfcomment> generally the default ldap search filter is ok</smbconfcomment>
1125 <smbconfoption><name>ldap filter</name><value>(uid=%u)</value></smbconfoption>
1132 <title>Accounts and Groups Management</title>
1135 <indexterm><primary>User Management</primary></indexterm>
1136 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
1138 As user accounts are managed through the sambaSamAccount objectclass, you should
1139 modify your existing administration tools to deal with sambaSamAccount attributes.
1143 Machine accounts are managed with the sambaSamAccount objectclass, just
1144 like users accounts. However, it is up to you to store those accounts
1145 in a different tree of your LDAP namespace. You should use
1146 <quote>ou=Groups,dc=quenya,dc=org</quote> to store groups and
1147 <quote>ou=People,dc=quenya,dc=org</quote> to store users. Just configure your
1148 NSS and PAM accordingly (usually, in the <filename>/etc/openldap/sldap.conf</filename>
1149 configuration file).
1153 In Samba-3, the group management system is based on POSIX
1154 groups. This means that Samba makes use of the posixGroup objectclass.
1155 For now, there is no NT-like group system management (global and local
1156 groups). Samba-3 knows only about <constant>Domain Groups</constant>
1157 and, unlike MS Windows 2000 and Active Directory, Samba-3 does not
1158 support nested groups.
1164 <title>Security and sambaSamAccount</title>
1168 There are two important points to remember when discussing the security
1169 of sambaSamAccount entries in the directory.
1173 <listitem><para><emphasis>Never</emphasis> retrieve the SambaLMPassword or
1174 SambaNTPassword attribute values over an unencrypted LDAP session.</para></listitem>
1175 <listitem><para><emphasis>Never</emphasis> allow non-admin users to
1176 view the SambaLMPassword or SambaNTPassword attribute values.</para></listitem>
1180 These password hashes are clear-text equivalents and can be used to impersonate
1181 the user without deriving the original clear-text strings. For more information
1182 on the details of LM/NT password hashes, refer to the
1183 <link linkend="passdb">Account Information Database</link> section of this chapter.
1187 To remedy the first security issue, the <smbconfoption><name>ldap ssl</name></smbconfoption> &smb.conf; parameter defaults
1188 to require an encrypted session (<smbconfoption><name>ldap ssl</name><value>on</value></smbconfoption>) using
1189 the default port of <constant>636</constant>
1190 when contacting the directory server. When using an OpenLDAP server, it
1191 is possible to use the StartTLS LDAP extended operation in the place of
1192 LDAPS. In either case, you are strongly discouraged to disable this security
1193 (<smbconfoption><name>ldap ssl</name><value>off</value></smbconfoption>).
1197 Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
1198 extended operation. However, the OpenLDAP library still provides support for
1199 the older method of securing communication between clients and servers.
1203 The second security precaution is to prevent non-administrative users from
1204 harvesting password hashes from the directory. This can be done using the
1205 following ACL in <filename>slapd.conf</filename>:
1210 ## allow the "ldap admin dn" access, but deny everyone else
1211 access to attrs=SambaLMPassword,SambaNTPassword
1212 by dn="cn=Samba Admin,ou=People,dc=quenya,dc=org" write
1220 <title>LDAP Special Attributes for sambaSamAccounts</title>
1222 <para> The sambaSamAccount objectclass is composed of the attributes shown in next tables: <link
1223 linkend="attribobjclPartA">Part A</link>, and <link linkend="attribobjclPartB">Part B</link>.
1227 <table frame="all" id="attribobjclPartA">
1228 <title>Attributes in the sambaSamAccount objectclass (LDAP) &smbmdash; Part A</title>
1229 <tgroup cols="2" align="justify">
1230 <colspec align="left"/>
1231 <colspec align="justify" colwidth="1*"/>
1233 <row><entry><constant>sambaLMPassword</constant></entry><entry>The LANMAN password 16-byte hash stored as a character
1234 representation of a hexadecimal string.</entry></row>
1235 <row><entry><constant>sambaNTPassword</constant></entry><entry>The NT password hash 16-byte stored as a character
1236 representation of a hexadecimal string.</entry></row>
1237 <row><entry><constant>sambaPwdLastSet</constant></entry><entry>The integer time in seconds since 1970 when the
1238 <constant>sambaLMPassword</constant> and <constant>sambaNTPassword</constant> attributes were last set.
1241 <row><entry><constant>sambaAcctFlags</constant></entry><entry>String of 11 characters surrounded by square brackets []
1242 representing account flags such as U (user), W (workstation), X (no password expiration),
1243 I (Domain trust account), H (Home dir required), S (Server trust account),
1244 and D (disabled).</entry></row>
1246 <row><entry><constant>sambaLogonTime</constant></entry><entry>Integer value currently unused</entry></row>
1248 <row><entry><constant>sambaLogoffTime</constant></entry><entry>Integer value currently unused</entry></row>
1250 <row><entry><constant>sambaKickoffTime</constant></entry><entry>Specifies the time (UNIX time format) when the user
1251 will be locked down and cannot login any longer. If this attribute is omitted, then the account will never expire.
1252 If you use this attribute together with `shadowExpire' of the `shadowAccount' objectClass, will enable accounts to
1253 expire completely on an exact date.</entry></row>
1255 <row><entry><constant>sambaPwdCanChange</constant></entry><entry>Specifies the time (UNIX time format) from which on the user is allowed to
1256 change his password. If attribute is not set, the user will be free to change his password whenever he wants.</entry></row>
1258 <row><entry><constant>sambaPwdMustChange</constant></entry><entry>Specifies the time (UNIX time format) since when the user is
1259 forced to change his password. If this value is set to `0', the user will have to change his password at first login.
1260 If this attribute is not set, then the password will never expire.</entry></row>
1262 <row><entry><constant>sambaHomeDrive</constant></entry><entry>Specifies the drive letter to which to map the
1263 UNC path specified by sambaHomePath. The drive letter must be specified in the form <quote>X:</quote>
1264 where X is the letter of the drive to map. Refer to the <quote>logon drive</quote> parameter in the
1265 smb.conf(5) man page for more information.</entry></row>
1267 <row><entry><constant>sambaLogonScript</constant></entry><entry>The sambaLogonScript property specifies the path of
1268 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
1269 is relative to the netlogon share. Refer to the <smbconfoption><name>logon script</name></smbconfoption> parameter in the
1270 &smb.conf; man page for more information.</entry></row>
1272 <row><entry><constant>sambaProfilePath</constant></entry><entry>Specifies a path to the user's profile.
1273 This value can be a null string, a local absolute path, or a UNC path. Refer to the
1274 <smbconfoption><name>logon path</name></smbconfoption> parameter in the &smb.conf; man page for more information.</entry></row>
1276 <row><entry><constant>sambaHomePath</constant></entry><entry>The sambaHomePath property specifies the path of
1277 the home directory for the user. The string can be null. If sambaHomeDrive is set and specifies
1278 a drive letter, sambaHomePath should be a UNC path. The path must be a network
1279 UNC path of the form <filename>\\server\share\directory</filename>. This value can be a null string.
1280 Refer to the <command>logon home</command> parameter in the &smb.conf; man page for more information.
1286 <table frame="all" id="attribobjclPartB">
1287 <title>Attributes in the sambaSamAccount objectclass (LDAP) &smbmdash; Part B</title>
1288 <tgroup cols="2" align="justify">
1289 <colspec align="left"/>
1290 <colspec align="justify" colwidth="1*"/>
1292 <row><entry><constant>sambaUserWorkstations</constant></entry><entry>Here you can give a comma-separated list of machines
1293 on which the user is allowed to login. You may observe problems when you try to connect to an Samba Domain Member.
1294 Because Domain Members are not in this list, the Domain Controllers will reject them. Where this attribute is omitted,
1295 the default implies no restrictions.
1298 <row><entry><constant>sambaSID</constant></entry><entry>The security identifier(SID) of the user.
1299 The Windows equivalent of UNIX UIDs.</entry></row>
1301 <row><entry><constant>sambaPrimaryGroupSID</constant></entry><entry>The Security IDentifier (SID) of the primary group
1302 of the user.</entry></row>
1304 <row><entry><constant>sambaDomainName</constant></entry><entry>Domain the user is part of.</entry></row>
1310 The majority of these parameters are only used when Samba is acting as a PDC of
1311 a domain (refer to <link linkend="samba-pdc">Domain Control</link>, for details on
1312 how to configure Samba as a Primary Domain Controller). The following four attributes
1313 are only stored with the sambaSamAccount entry if the values are non-default values:
1317 <listitem><para>sambaHomePath</para></listitem>
1318 <listitem><para>sambaLogonScript</para></listitem>
1319 <listitem><para>sambaProfilePath</para></listitem>
1320 <listitem><para>sambaHomeDrive</para></listitem>
1324 These attributes are only stored with the sambaSamAccount entry if
1325 the values are non-default values. For example, assume MORIA has now been
1326 configured as a PDC and that <smbconfoption><name>logon home</name><value>\\%L\%u</value></smbconfoption> was defined in
1327 its &smb.conf; file. When a user named <quote>becky</quote> logons to the domain,
1328 the <smbconfoption><name>logon home</name></smbconfoption> string is expanded to \\MORIA\becky.
1329 If the smbHome attribute exists in the entry <quote>uid=becky,ou=People,dc=samba,dc=org</quote>,
1330 this value is used. However, if this attribute does not exist, then the value
1331 of the <smbconfoption><name>logon home</name></smbconfoption> parameter is used in its place. Samba
1332 will only write the attribute value to the directory entry if the value is
1333 something other than the default (e.g., <filename>\\MOBY\becky</filename>).
1339 <title>Example LDIF Entries for a sambaSamAccount</title>
1342 The following is a working LDIF that demonstrates the use of the SambaSamAccount objectclass:
1346 <smbfile name="samba.ldif.example2">
1348 dn: uid=guest2, ou=People,dc=quenya,dc=org
1349 sambaLMPassword: 878D8014606CDA29677A44EFA1353FC7
1350 sambaPwdMustChange: 2147483647
1351 sambaPrimaryGroupSID: S-1-5-21-2447931902-1787058256-3961074038-513
1352 sambaNTPassword: 552902031BEDE9EFAAD3B435B51404EE
1353 sambaPwdLastSet: 1010179124
1355 objectClass: sambaSamAccount
1357 sambaKickoffTime: 2147483647
1358 sambaAcctFlags: [UX ]
1359 sambaLogoffTime: 2147483647
1360 sambaSID: S-1-5-21-2447931902-1787058256-3961074038-5006
1361 sambaPwdCanChange: 0
1367 The following is an LDIF entry for using both the sambaSamAccount and
1368 posixAccount objectclasses:
1372 <smbfile name="samba.ldif.example3">
1374 dn: uid=gcarter, ou=People,dc=quenya,dc=org
1376 displayName: Gerald Carter
1377 sambaLMPassword: 552902031BEDE9EFAAD3B435B51404EE
1378 sambaPrimaryGroupSID: S-1-5-21-2447931902-1787058256-3961074038-1201
1379 objectClass: posixAccount
1380 objectClass: sambaSamAccount
1381 sambaAcctFlags: [UX ]
1382 userPassword: {crypt}BpM2ej8Rkzogo
1386 loginShell: /bin/bash
1387 logoffTime: 2147483647
1389 sambaKickoffTime: 2147483647
1390 sambaPwdLastSet: 1010179230
1391 sambaSID: S-1-5-21-2447931902-1787058256-3961074038-5004
1392 homeDirectory: /home/moria/gcarter
1393 sambaPwdCanChange: 0
1394 sambaPwdMustChange: 2147483647
1395 sambaNTPassword: 878D8014606CDA29677A44EFA1353FC7
1403 <title>Password Synchronization</title>
1406 Samba-3 and later can update the non-samba (LDAP) password stored with an account. When
1407 using pam_ldap, this allows changing both UNIX and Windows passwords at once.
1410 <para>The <smbconfoption><name>ldap passwd sync</name></smbconfoption> options can have the values shown in
1411 <link linkend="ldappwsync">the next table</link>.</para>
1413 <table iframe="all" id="ldappwsync">
1414 <title>Possible <emphasis>ldap passwd sync</emphasis> values</title>
1416 <colspec align="left" width="1*"/>
1417 <colspec align="justify" width="4*"/>
1419 <row><entry align="left">Value</entry><entry align="center">Description</entry></row>
1422 <row><entry>yes</entry><entry><para>When the user changes his password, update
1423 <constant>SambaNTPassword</constant>, <constant>SambaLMPassword</constant>
1424 and the <constant>password</constant> fields.</para></entry></row>
1426 <row><entry>no</entry><entry><para>Only update <constant>SambaNTPassword</constant> and <constant>SambaLMPassword</constant>.</para></entry></row>
1428 <row><entry>only</entry><entry><para>Only update the LDAP password and let the LDAP server worry about the other fields.
1429 This option is only available on some LDAP servers. Only when the LDAP server
1430 supports LDAP_EXOP_X_MODIFY_PASSWD.</para></entry></row>
1436 <para>More information can be found in the &smb.conf; man page.</para>
1443 <title>MySQL</title>
1446 <indexterm><primary>SAM backend</primary><secondary>mysqlsam</secondary></indexterm>
1447 Every so often someone will come along with a great new idea. Storing user accounts in a
1448 SQL backend is one of them. Those who want to do this are in the best position to know what the
1449 specific benefits are to them. This may sound like a cop-out, but in truth we cannot attempt
1450 to document every little detail why certain things of marginal utility to the bulk of
1451 Samba users might make sense to the rest. In any case, the following instructions should help
1452 the determined SQL user to implement a working system.
1456 <title>Creating the Database</title>
1459 You can set up your own table and specify the field names to pdb_mysql (see below
1460 for the column names) or use the default table. The file <filename>examples/pdb/mysql/mysql.dump</filename>
1461 contains the correct queries to create the required tables. Use the command:
1464 &prompt;<userinput>mysql -u<replaceable>username</replaceable> -h<replaceable>hostname</replaceable> -p<replaceable>password</replaceable> \
1465 <replaceable>databasename</replaceable> < <filename>/path/to/samba/examples/pdb/mysql/mysql.dump</filename></userinput>
1471 <title>Configuring</title>
1473 <para>This plug-in lacks some good documentation, but here is some brief information. Add the following to the
1474 <smbconfoption><name>passdb backend</name></smbconfoption> variable in your &smb.conf;:
1476 <smbconfoption><name>passdb backend</name><value>[other-plugins] mysql:identifier [other-plugins]</value></smbconfoption>
1480 <para>The identifier can be any string you like, as long as it does not collide with
1481 the identifiers of other plugins or other instances of pdb_mysql. If you
1482 specify multiple pdb_mysql.so entries in <smbconfoption><name>passdb backend</name></smbconfoption>, you also need to
1483 use different identifiers.
1487 Additional options can be given through the &smb.conf; file in the <smbconfsection>[global]</smbconfsection> section.
1488 Refer to <link linkend="mysqlpbe">the following table</link>.
1491 <table frame="all" id="mysqlpbe">
1492 <title>Basic smb.conf options for MySQL passdb backend</title>
1494 <colspec align="left"/>
1495 <colspec align="justify" colwidth="1*"/>
1497 <row><entry>Field</entry><entry>Contents</entry></row>
1500 <row><entry>mysql host</entry><entry>Host name, defaults to `localhost'</entry></row>
1501 <row><entry>mysql password</entry><entry></entry></row>
1502 <row><entry>mysql user</entry><entry>Defaults to `samba'</entry></row>
1503 <row><entry>mysql database</entry><entry>Defaults to `samba'</entry></row>
1504 <row><entry>mysql port</entry><entry>Defaults to 3306</entry></row>
1505 <row><entry>table</entry><entry>Name of the table containing the users</entry></row>
1512 Since the password for the MySQL user is stored in the &smb.conf; file, you should make the &smb.conf; file
1513 readable only to the user who runs Samba. This is considered a security bug and will soon be fixed.
1517 <para>Names of the columns are given in <link linkend="moremysqlpdbe">the next table</link>.
1518 The default column names can be found in the example table dump.
1522 <table frame="all" id="moremysqlpdbe">
1523 <title>MySQL field names for MySQL passdb backend</title>
1524 <tgroup cols="3" align="justify">
1525 <colspec align="left"/>
1526 <colspec align="left"/>
1527 <colspec align="justify" colwidth="1*"/>
1529 <row><entry>Field</entry><entry>Type</entry><entry>Contents</entry></row>
1532 <row><entry>logon time column</entry><entry>int(9)</entry><entry>UNIX time stamp of last logon of user</entry></row>
1533 <row><entry>logoff time column</entry><entry>int(9)</entry><entry>UNIX time stamp of last logoff of user</entry></row>
1534 <row><entry>kickoff time column</entry><entry>int(9)</entry><entry>UNIX time stamp of moment user should be kicked off workstation (not enforced)</entry></row>
1535 <row><entry>pass last set time column</entry><entry>int(9)</entry><entry>UNIX time stamp of moment password was last set</entry></row>
1536 <row><entry>pass can change time column</entry><entry>int(9)</entry><entry>UNIX time stamp of moment from which password can be changed</entry></row>
1537 <row><entry>pass must change time column</entry><entry>int(9)</entry><entry>UNIX time stamp of moment on which password must be changed</entry></row>
1538 <row><entry>username column</entry><entry>varchar(255)</entry><entry>UNIX username</entry></row>
1539 <row><entry>domain column</entry><entry>varchar(255)</entry><entry>NT domain user belongs to</entry></row>
1540 <row><entry>nt username column</entry><entry>varchar(255)</entry><entry>NT username</entry></row>
1541 <row><entry>fullname column</entry><entry>varchar(255)</entry><entry>Full name of user</entry></row>
1542 <row><entry>home dir column</entry><entry>varchar(255)</entry><entry>UNIX homedir path (equivalent of the <smbconfoption><name>logon home</name></smbconfoption> parameter.</entry></row>
1543 <row><entry>dir drive column</entry><entry>varchar(2)</entry><entry>Directory drive path (e.g., <quote>H:</quote>)</entry></row>
1544 <row><entry>logon script column</entry><entry>varchar(255)</entry><entry>Batch file to run on client side when logging on</entry></row>
1545 <row><entry>profile path column</entry><entry>varchar(255)</entry><entry>Path of profile</entry></row>
1546 <row><entry>acct desc column</entry><entry>varchar(255)</entry><entry>Some ASCII NT user data</entry></row>
1547 <row><entry>workstations column</entry><entry>varchar(255)</entry><entry>Workstations user can logon to (or NULL for all)</entry></row>
1548 <row><entry>unknown string column</entry><entry>varchar(255)</entry><entry>Unknown string</entry></row>
1549 <row><entry>munged dial column</entry><entry>varchar(255)</entry><entry>Unknown</entry></row>
1550 <row><entry>user sid column</entry><entry>varchar(255)</entry><entry>NT user SID</entry></row>
1551 <row><entry>group sid column</entry><entry>varchar(255)</entry><entry>NT group SID</entry></row>
1552 <row><entry>lanman pass column</entry><entry>varchar(255)</entry><entry>Encrypted lanman password</entry></row>
1553 <row><entry>nt pass column</entry><entry>varchar(255)</entry><entry>Encrypted nt passwd</entry></row>
1554 <row><entry>plain pass column</entry><entry>varchar(255)</entry><entry>Plaintext password</entry></row>
1555 <row><entry>acct ctrl column</entry><entry>int(9)</entry><entry>NT user data</entry></row>
1556 <row><entry>unknown 3 column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1557 <row><entry>logon divs column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1558 <row><entry>hours len column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1559 <row><entry>bad password count column</entry><entry>int(5)</entry><entry>Number of failed password tries before disabling an account</entry></row>
1560 <row><entry>logon count column</entry><entry>int(5)</entry><entry>Number of logon attempts</entry></row>
1561 <row><entry>unknown 6 column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1567 You can put a colon (:) after the name of each column, which
1568 should specify the column to update when updating the table. One can also specify nothing behind the colon, in which case the field data will not be updated. Setting a column name to <parameter>NULL</parameter> means the field should not be used.
1571 <para><link linkend="mysqlsam">An example configuration</link> looks like:
1574 <smbconfexample id="mysqlsam">
1575 <title>Example configuration for the MySQL passdb backend</title>
1576 <smbconfsection>[global]</smbconfsection>
1577 <smbconfoption><name>passdb backend</name><value>mysql:foo</value></smbconfoption>
1578 <smbconfoption><name>foo:mysql user</name><value>samba</value></smbconfoption>
1579 <smbconfoption><name>foo:mysql password</name><value>abmas</value></smbconfoption>
1580 <smbconfoption><name>foo:mysql database</name><value>samba</value></smbconfoption>
1581 <smbconfcomment>domain name is static and can't be changed</smbconfcomment>
1582 <smbconfoption><name>foo:domain column</name><value>'MYWORKGROUP':</value></smbconfoption>
1583 <smbconfcomment>The fullname column comes from several other columns</smbconfcomment>
1584 <smbconfoption><name>foo:fullname column</name><value>CONCAT(firstname,' ',surname):</value></smbconfoption>
1585 <smbconfcomment>Samba should never write to the password columns</smbconfcomment>
1586 <smbconfoption><name>foo:lanman pass column</name><value>lm_pass:</value></smbconfoption>
1587 <smbconfoption><name>foo:nt pass column</name><value>nt_pass:</value></smbconfoption>
1588 <smbconfcomment>The unknown 3 column is not stored</smbconfcomment>
1589 <smbconfoption><name>foo:unknown 3 column</name><value>NULL</value></smbconfoption>
1594 <title>Using Plaintext Passwords or Encrypted Password</title>
1597 <indexterm><primary>encrypted passwords</primary></indexterm>
1598 I strongly discourage the use of plaintext passwords, however, you can use them.
1602 If you would like to use plaintext passwords, set
1603 `identifier:lanman pass column' and `identifier:nt pass column' to
1604 `NULL' (without the quotes) and `identifier:plain pass column' to the
1605 name of the column containing the plaintext passwords.
1609 If you use encrypted passwords, set the 'identifier:plain pass
1610 column' to 'NULL' (without the quotes). This is the default.
1616 <title>Getting Non-Column Data from the Table</title>
1619 It is possible to have not all data in the database by making some `constant'.
1623 For example, you can set `identifier:fullname column' to
1624 something like <?latex \linebreak ?><command>CONCAT(Firstname,' ',Surname)</command>
1628 Or, set `identifier:workstations column' to:
1629 <command>NULL</command></para>
1631 <para>See the MySQL documentation for more language constructs.</para>
1636 <sect2 id="XMLpassdb">
1640 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
1641 This module requires libxml2 to be installed.</para>
1643 <para>The usage of pdb_xml is fairly straightforward. To export data, use:
1647 <indexterm><primary>pdbedit</primary></indexterm>
1648 <prompt>$ </prompt> <userinput>pdbedit -e xml:filename</userinput>
1652 (where filename is the name of the file to put the data in)
1656 To import data, use:
1657 <prompt>$ </prompt> <userinput>pdbedit -i xml:filename</userinput>
1663 <title>Common Errors</title>
1666 <title>Users Cannot Logon</title>
1668 <para><quote>I've installed Samba, but now I can't log on with my UNIX account! </quote></para>
1670 <para>Make sure your user has been added to the current Samba <smbconfoption><name>passdb backend</name></smbconfoption>.
1671 Read the section <link linkend="acctmgmttools">Account Management Tools</link> for details.</para>
1676 <title>Users Being Added to the Wrong Backend Database</title>
1679 A few complaints have been received from users that just moved to Samba-3. The following
1680 &smb.conf; file entries were causing problems, new accounts were being added to the old
1681 smbpasswd file, not to the tdbsam passdb.tdb file:
1686 <smbconfsection>[global]</smbconfsection>
1687 <member>...</member>
1688 <smbconfoption><name>passdb backend</name><value>smbpasswd, tdbsam</value></smbconfoption>
1689 <member>...</member>
1694 Samba will add new accounts to the first entry in the <emphasis>passdb backend</emphasis>
1695 parameter entry. If you want to update to the tdbsam, then change the entry to:
1702 <smbconfoption><name>passdb backend</name><value>tdbsam, smbpasswd</value></smbconfoption>
1710 <title>Configuration of <parameter>auth methods</parameter></title>
1713 When explicitly setting an <smbconfoption><name>auth methods</name></smbconfoption> parameter,
1714 <parameter>guest</parameter> must be specified as the first entry on the line,
1715 for example, <smbconfoption><name>auth methods</name><value>guest sam</value></smbconfoption>.
1719 This is the exact opposite of the requirement for the <smbconfoption><name>passdb backend</name></smbconfoption>
1720 option, where it must be the <emphasis>LAST</emphasis> parameter on the line.