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 <indexterm><primary>idmap uid</primary></indexterm>
376 <indexterm><primary>idmap gid</primary></indexterm>
377 The second way to effect Windows SID to UNIX UID mapping is via the
378 <emphasis>idmap uid</emphasis> and <emphasis>idmap gid</emphasis> parameters in &smb.conf;.
379 Please refer to the man page for information about these parameters.
380 These parameters are essential when mapping users from a remote SAM server.
385 <sect2 id="idmapbackend">
386 <title>Mapping Common UIDs/GIDs on Distributed Machines</title>
389 Samba-3 has a special facility that makes it possible to maintain identical UIDs and GIDs
390 on all servers in a distributed network. A distributed network is one where there exists
391 a PDC, one or more BDCs and/or one or more Domain Member servers. Why is this important?
392 This is important if files are being shared over more than one protocol (e.g., NFS) and where
393 users are copying files across UNIX/Linux systems using tools such as <command>rsync</command>.
397 <indexterm><primary>idmap backend</primary></indexterm>
398 The special facility is enabled using a parameter called <parameter>idmap backend</parameter>.
399 The default setting for this parameter is an empty string. Technically it is possible to use
400 an LDAP based idmap backend for UIDs and GIDs, but it makes most sense when this is done for
401 network configurations that also use LDAP for the SAM backend. Following
402 <link linkend="idmapbackendexample">example</link> shows that.
406 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
407 <smbconfexample id="idmapbackendexample">
408 <title>Example configuration with the LDAP idmap backend</title>
409 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
410 <smbconfsection>[global]</smbconfsection>
411 <smbconfoption><name>idmap backend</name><value>ldap:ldap://ldap-server.quenya.org:636</value></smbconfoption>
412 <smbcomment>Alternately, this could be specified as:</smbcomment>
413 <smbconfoption><name>idmap backend</name><value>ldap:ldaps://ldap-server.quenya.org</value></smbconfoption>
418 A network administrator who wants to make significant use of LDAP backends will sooner or later be
419 exposed to the excellent work done by PADL Software. PADL <ulink url="http://www.padl.com"/> have
420 produced and released to open source an array of tools that might be of interest. These tools include:
426 <emphasis>nss_ldap:</emphasis> An LDAP Name Service Switch module to provide native
427 name service support for AIX, Linux, Solaris, and other operating systems. This tool
428 can be used for centralized storage and retrieval of UIDs/GIDs.
434 <emphasis>pam_ldap:</emphasis> A PAM module that provides LDAP integration for UNIX/Linux
435 system access authentication.
440 <emphasis>idmap_ad:</emphasis> An IDMAP backend that supports the Microsoft Services for
441 UNIX RFC 2307 schema available from their web
442 <ulink url="http://www.padl.com/download/xad_oss_plugins.tar.gz">site</ulink>.
451 <sect1 id="acctmgmttools">
452 <title>Account Management Tools</title>
455 <indexterm><primary>pdbedit</primary></indexterm>
456 Samba provides two tools for management of user and machine accounts. These tools are
457 called <command>smbpasswd</command> and <command>pdbedit</command>.
460 <title>The <emphasis>smbpasswd</emphasis> Command</title>
463 The smbpasswd utility is similar to the <command>passwd</command>
464 or <command>yppasswd</command> programs. It maintains the two 32 byte password
465 fields in the passdb backend.
469 <command>smbpasswd</command> works in a client-server mode where it contacts the
470 local smbd to change the user's password on its behalf. This has enormous benefits.
474 <command>smbpasswd</command> has the capability to change passwords on Windows NT
475 servers (this only works when the request is sent to the NT Primary Domain Controller
476 if changing an NT Domain user's password).
480 <command>smbpasswd</command> can be used to:
481 <indexterm><primary>User Management</primary></indexterm>
482 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
487 <listitem><para><emphasis>add</emphasis> user or machine accounts.</para></listitem>
488 <listitem><para><emphasis>delete</emphasis> user or machine accounts.</para></listitem>
489 <listitem><para><emphasis>enable</emphasis> user or machine accounts.</para></listitem>
490 <listitem><para><emphasis>disable</emphasis> user or machine accounts.</para></listitem>
491 <listitem><para><emphasis>set to NULL</emphasis> user passwords.</para></listitem>
492 <listitem><para><emphasis>manage interdomain trust accounts.</emphasis></para></listitem>
496 To run smbpasswd as a normal user just type:
501 &prompt;<userinput>smbpasswd</userinput>
502 <prompt>Old SMB password: </prompt><userinput><replaceable>secret</replaceable></userinput>
504 For <replaceable>secret</replaceable>, type old value here or press return if
505 there is no old password.
507 <prompt>New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
508 <prompt>Repeat New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
513 If the old value does not match the current value stored for that user, or the two
514 new values do not match each other, then the password will not be changed.
518 When invoked by an ordinary user, the command will only allow the user to change his or her own
523 When run by root, <command>smbpasswd</command> may take an optional argument specifying
524 the user name whose SMB password you wish to change. When run as root, <command>smbpasswd</command>
525 does not prompt for or check the old password value, thus allowing root to set passwords
526 for users who have forgotten their passwords.
530 <command>smbpasswd</command> is designed to work in the way familiar to UNIX
531 users who use the <command>passwd</command> or <command>yppasswd</command> commands.
532 While designed for administrative use, this tool provides essential User Level
533 password change capabilities.
537 For more details on using <command>smbpasswd</command>, refer to the man page (the
538 definitive reference).
542 <sect2 id="pdbeditthing">
543 <title>The <emphasis>pdbedit</emphasis> Command</title>
546 <indexterm><primary>pdbedit</primary></indexterm>
547 <command>pdbedit</command> is a tool that can be used only by root. It is used to
548 manage the passdb backend. <command>pdbedit</command> can be used to:
549 <indexterm><primary>User Management</primary></indexterm>
550 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
555 <listitem><para>add, remove or modify user accounts.</para></listitem>
556 <listitem><para>list user accounts.</para></listitem>
557 <listitem><para>migrate user accounts.</para></listitem>
561 <indexterm><primary>pdbedit</primary></indexterm>
562 The <command>pdbedit</command> tool is the only one that can manage the account
563 security and policy settings. It is capable of all operations that smbpasswd can
564 do as well as a super set of them.
568 <indexterm><primary>pdbedit</primary></indexterm>
569 One particularly important purpose of the <command>pdbedit</command> is to allow
570 the migration of account information from one passdb backend to another. See the
571 <link linkend="XMLpassdb">XML</link> password backend section of this chapter.
575 The following is an example of the user account information that is stored in
576 a tdbsam password backend. This listing was produced by running:
580 &prompt;<userinput>pdbedit -Lv met</userinput>
584 User SID: S-1-5-21-1449123459-1407424037-3116680435-2004
585 Primary Group SID: S-1-5-21-1449123459-1407424037-3116680435-1201
586 Full Name: Melissa E Terpstra
587 Home Directory: \\frodo\met\Win9Profile
589 Logon Script: scripts\logon.bat
590 Profile Path: \\frodo\Profiles\met
591 Domain: &example.workgroup;
593 Workstations: melbelle
596 Logoff time: Mon, 18 Jan 2038 20:14:07 GMT
597 Kickoff time: Mon, 18 Jan 2038 20:14:07 GMT
598 Password last set: Sat, 14 Dec 2002 14:37:03 GMT
599 Password can change: Sat, 14 Dec 2002 14:37:03 GMT
600 Password must change: Mon, 18 Jan 2038 20:14:07 GMT
604 <indexterm><primary>pdbedit</primary></indexterm>
605 The <command>pdbedit</command> tool allows migration of authentication (account)
606 databases from one backend to another. For example: To migrate accounts from an
607 old <filename>smbpasswd</filename> database to a <parameter>tdbsam</parameter>
613 Set the <smbconfoption><name>passdb backend</name><value>tdbsam, smbpasswd</value></smbconfoption>.
619 &rootprompt;<userinput>pdbedit -i smbpasswd -e tdbsam</userinput>
624 Now remove the <parameter>smbpasswd</parameter> from the passdb backend
625 configuration in &smb.conf;.
633 <title>Password Backends</title>
636 Samba offers the greatest flexibility in backend account database design of any SMB/CIFS server
637 technology available today. The flexibility is immediately obvious as one begins to explore this
642 It is possible to specify not only multiple different password backends, but even multiple
643 backends of the same type. For example, to use two different tdbsam databases:
648 <smbconfoption><name>passdb backend</name><value>tdbsam:/etc/samba/passdb.tdb \</value></smbconfoption>
649 <member><parameter>tdbsam:/etc/samba/old-passdb.tdb</parameter></member>
655 <title>Plaintext</title>
658 Older versions of Samba retrieved user information from the UNIX user database
659 and eventually some other fields from the file <filename>/etc/samba/smbpasswd</filename>
660 or <filename>/etc/smbpasswd</filename>. When password encryption is disabled, no
661 SMB specific data is stored at all. Instead all operations are conducted via the way
662 that the Samba host OS will access its <filename>/etc/passwd</filename> database.
663 Linux systems For example, all operations are done via PAM.
669 <title>smbpasswd &smbmdash; Encrypted Password Database</title>
672 <indexterm><primary>SAM backend</primary><secondary>smbpasswd</secondary></indexterm>
673 Traditionally, when configuring <smbconfoption><name>encrypt passwords</name><value>yes</value></smbconfoption> in Samba's &smb.conf; file, user account
674 information such as username, LM/NT password hashes, password change times, and account
675 flags have been stored in the <filename>smbpasswd(5)</filename> file. There are several
676 disadvantages to this approach for sites with large numbers of users (counted
682 The first problem is that all lookups must be performed sequentially. Given that
683 there are approximately two lookups per domain logon (one for a normal
684 session connection such as when mapping a network drive or printer), this
685 is a performance bottleneck for large sites. What is needed is an indexed approach
686 such as used in databases.
690 The second problem is that administrators who desire to replicate a smbpasswd file
691 to more than one Samba server were left to use external tools such as
692 <command>rsync(1)</command> and <command>ssh(1)</command> and wrote custom,
697 Finally, the amount of information that is stored in an smbpasswd entry leaves
698 no room for additional attributes such as a home directory, password expiration time,
699 or even a Relative Identifier (RID).
704 As a result of these deficiencies, a more robust means of storing user attributes
705 used by smbd was developed. The API which defines access to user accounts
706 is commonly referred to as the samdb interface (previously this was called the passdb
707 API, and is still so named in the Samba CVS trees).
711 Samba provides an enhanced set of passdb backends that overcome the deficiencies
712 of the smbpasswd plain text database. These are tdbsam, ldapsam and xmlsam.
713 Of these, ldapsam will be of most interest to large corporate or enterprise sites.
719 <title>tdbsam</title>
722 <indexterm><primary>SAM backend</primary><secondary>tdbsam</secondary></indexterm>
723 Samba can store user and machine account data in a <quote>TDB</quote> (Trivial Database).
724 Using this backend does not require any additional configuration. This backend is
725 recommended for new installations that do not require LDAP.
729 As a general guide, the Samba Team does not recommend using the tdbsam backend for sites
730 that have 250 or more users. Additionally, tdbsam is not capable of scaling for use
731 in sites that require PDB/BDC implementations that require replication of the account
732 database. Clearly, for reason of scalability, the use of ldapsam should be encouraged.
736 The recommendation of a 250 user limit is purely based on the notion that this
737 would generally involve a site that has routed networks, possibly spread across
738 more than one physical location. The Samba Team has not at this time established
739 the performance based scalability limits of the tdbsam architecture.
745 <title>ldapsam</title>
748 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
749 There are a few points to stress that the ldapsam does not provide. The LDAP
750 support referred to in this documentation does not include:
754 <listitem><para>A means of retrieving user account information from
755 an Windows 200x Active Directory server.</para></listitem>
756 <listitem><para>A means of replacing /etc/passwd.</para></listitem>
760 The second item can be accomplished by using LDAP NSS and PAM modules. LGPL
761 versions of these libraries can be obtained from
762 <ulink url="http://www.padl.com/">PADL Software</ulink>.
763 More information about the configuration of these packages may be found at
764 <ulink url="http://safari.oreilly.com/?XmlId=1-56592-491-6">
765 <emphasis>LDAP, System Administration</emphasis>; Gerald Carter by O'Reilly; Chapter 6: Replacing NIS."</ulink>
769 This document describes how to use an LDAP directory for storing Samba user
770 account information traditionally stored in the smbpasswd(5) file. It is
771 assumed that the reader already has a basic understanding of LDAP concepts
772 and has a working directory server already installed. For more information
773 on LDAP architectures and directories, please refer to the following sites:
777 <listitem><para><ulink url="http://www.openldap.org/">OpenLDAP</ulink></para></listitem>
778 <listitem><para><ulink url="http://iplanet.netscape.com/directory">Sun iPlanet Directory Server</ulink></para></listitem>
782 Two additional Samba resources which may prove to be helpful are:
786 <listitem><para>The <ulink url="http://www.unav.es/cti/ldap-smb/ldap-smb-3-howto.html">Samba-PDC-LDAP-HOWTO</ulink>
787 maintained by Ignacio Coupeau.</para></listitem>
789 <listitem><para>The NT migration scripts from <ulink url="http://samba.idealx.org/">IDEALX</ulink> that are
790 geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
795 <title>Supported LDAP Servers</title>
798 The LDAP ldapsam code has been developed and tested using the OpenLDAP 2.0 and 2.1 server and
799 client libraries. The same code should work with Netscape's Directory Server and client SDK.
800 However, there are bound to be compile errors and bugs. These should not be hard to fix.
801 Please submit fixes via the process outlined in <link linkend="bugreport">Reporting Bugs</link> chapter.
807 <title>Schema and Relationship to the RFC 2307 posixAccount</title>
811 Samba-3.0 includes the necessary schema file for OpenLDAP 2.0 in
812 <filename>examples/LDAP/samba.schema</filename>. The sambaSamAccount ObjectClass is given here:
817 ObjectClass (1.3.6.1.4.1.7165.2.2.6 NAME 'sambaSamAccount' SUP top AUXILIARY
818 DESC 'Samba-3.0 Auxiliary SAM Account'
819 MUST ( uid $ sambaSID )
820 MAY ( cn $ sambaLMPassword $ sambaNTPassword $ sambaPwdLastSet $
821 sambaLogonTime $ sambaLogoffTime $ sambaKickoffTime $
822 sambaPwdCanChange $ sambaPwdMustChange $ sambaAcctFlags $
823 displayName $ sambaHomePath $ sambaHomeDrive $ sambaLogonScript $
824 sambaProfilePath $ description $ sambaUserWorkstations $
825 sambaPrimaryGroupSID $ sambaDomainName ))
830 The <filename>samba.schema</filename> file has been formatted for OpenLDAP 2.0/2.1.
831 The Samba Team owns the OID space used by the above schema and recommends its use.
832 If you translate the schema to be used with Netscape DS, please submit the modified
833 schema file as a patch to <ulink url="mailto:jerry@samba.org">jerry@samba.org</ulink>.
837 Just as the smbpasswd file is meant to store information that provides information additional to a
838 user's <filename>/etc/passwd</filename> entry, so is the sambaSamAccount object
839 meant to supplement the UNIX user account information. A sambaSamAccount is a
840 <constant>AUXILIARY</constant> ObjectClass so it can be used to augment existing
841 user account information in the LDAP directory, thus providing information needed
842 for Samba account handling. However, there are several fields (e.g., uid) that overlap
843 with the posixAccount ObjectClass outlined in RFC2307. This is by design.
846 <!--olem: we should perhaps have a note about shadowAccounts too as many
847 systems use them, isn'it ? -->
850 In order to store all user account information (UNIX and Samba) in the directory,
851 it is necessary to use the sambaSamAccount and posixAccount ObjectClass es in
852 combination. However, smbd will still obtain the user's UNIX account
853 information via the standard C library calls (e.g., getpwnam(), et al).
854 This means that the Samba server must also have the LDAP NSS library installed
855 and functioning correctly. This division of information makes it possible to
856 store all Samba account information in LDAP, but still maintain UNIX account
857 information in NIS while the network is transitioning to a full LDAP infrastructure.
862 <title>OpenLDAP Configuration</title>
865 To include support for the sambaSamAccount object in an OpenLDAP directory
866 server, first copy the samba.schema file to slapd's configuration directory.
867 The samba.schema file can be found in the directory <filename>examples/LDAP</filename>
868 in the Samba source distribution.
873 &rootprompt;<userinput>cp samba.schema /etc/openldap/schema/</userinput>
878 Next, include the <filename>samba.schema</filename> file in <filename>slapd.conf</filename>.
879 The sambaSamAccount object contains two attributes that depend on other schema
880 files. The <parameter>uid</parameter> attribute is defined in <filename>cosine.schema</filename> and
881 the <parameter>displayName</parameter> attribute is defined in the <filename>inetorgperson.schema</filename>
882 file. Both of these must be included before the <filename>samba.schema</filename> file.
887 ## /etc/openldap/slapd.conf
889 ## schema files (core.schema is required by default)
890 include /etc/openldap/schema/core.schema
892 ## needed for sambaSamAccount
893 include /etc/openldap/schema/cosine.schema
894 include /etc/openldap/schema/inetorgperson.schema
895 include /etc/openldap/schema/nis.schema
896 include /etc/openldap/schema/samba.schema
902 It is recommended that you maintain some indices on some of the most useful attributes,
903 as in the following example, to speed up searches made on sambaSamAccount objectclasses
904 (and possibly posixAccount and posixGroup as well):
909 # Indices to maintain
910 ## required by OpenLDAP
915 ## required to support pdb_getsampwnam
916 index uid pres,sub,eq
917 ## required to support pdb_getsambapwrid()
918 index displayName pres,sub,eq
920 ## uncomment these if you are storing posixAccount and
921 ## posixGroup entries in the directory as well
927 index sambaPrimaryGroupSID eq
928 index sambaDomainName eq
934 Create the new index by executing:
939 &rootprompt;./sbin/slapindex -f slapd.conf
944 Remember to restart slapd after making these changes:
949 &rootprompt;<userinput>/etc/init.d/slapd restart</userinput>
956 <title>Initialize the LDAP Database</title>
959 Before you can add accounts to the LDAP database you must create the account containers
960 that they will be stored in. The following LDIF file should be modified to match your
961 needs (DNS entries, and so on):
965 <smbfile name="samba.ldif.example">
967 # Organization for Samba Base
969 objectclass: dcObject
970 objectclass: organization
972 o: Quenya Org Network
973 description: The Samba-3 Network LDAP Example
975 # Organizational Role for Directory Management
976 dn: cn=Manager,dc=quenya,dc=org
977 objectclass: organizationalRole
979 description: Directory Manager
981 # Setting up container for users
982 dn: ou=People,dc=quenya,dc=org
984 objectclass: organizationalUnit
987 # Setting up admin handle for People OU
988 dn: cn=admin,ou=People,dc=quenya,dc=org
991 objectclass: organizationalRole
992 objectclass: simpleSecurityObject
993 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
995 # Setting up container for groups
996 dn: ou=Groups,dc=quenya,dc=org
998 objectclass: organizationalUnit
1001 # Setting up admin handle for Groups OU
1002 dn: cn=admin,ou=Groups,dc=quenya,dc=org
1005 objectclass: organizationalRole
1006 objectclass: simpleSecurityObject
1007 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1009 # Setting up container for computers
1010 dn: ou=Computers,dc=quenya,dc=org
1012 objectclass: organizationalUnit
1015 # Setting up admin handle for Computers OU
1016 dn: cn=admin,ou=Computers,dc=quenya,dc=org
1019 objectclass: organizationalRole
1020 objectclass: simpleSecurityObject
1021 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1027 The userPassword shown above should be generated using <command>slappasswd</command>.
1031 The following command will then load the contents of the LDIF file into the LDAP
1037 &prompt;<userinput>slapadd -v -l initldap.dif</userinput>
1042 Do not forget to secure your LDAP server with an adequate access control list
1043 as well as an admin password.
1048 Before Samba can access the LDAP server you need to store the LDAP admin password
1049 into the Samba-3 <filename>secrets.tdb</filename> database by:
1051 &rootprompt;<userinput>smbpasswd -w <replaceable>secret</replaceable></userinput>
1059 <title>Configuring Samba</title>
1062 The following parameters are available in smb.conf only if your
1063 version of Samba was built with LDAP support. Samba automatically builds with LDAP support if the
1064 LDAP libraries are found.
1067 <para>LDAP related smb.conf options:
1068 <smbconfoption><name>passdb backend</name><value>ldapsam:url</value></smbconfoption>,
1069 <smbconfoption><name>ldap admin dn</name></smbconfoption>,
1070 <smbconfoption><name>ldap delete dn</name></smbconfoption>,
1071 <smbconfoption><name>ldap filter</name></smbconfoption>,
1072 <smbconfoption><name>ldap group suffix</name></smbconfoption>,
1073 <smbconfoption><name>ldap idmap suffix</name></smbconfoption>,
1074 <smbconfoption><name>ldap machine suffix</name></smbconfoption>,
1075 <smbconfoption><name>ldap passwd sync</name></smbconfoption>,
1076 <smbconfoption><name>ldap ssl</name></smbconfoption>,
1077 <smbconfoption><name>ldap suffix</name></smbconfoption>,
1078 <smbconfoption><name>ldap user suffix</name></smbconfoption>,
1082 These are described in the &smb.conf; man
1083 page and so will not be repeated here. However, a <link linkend="confldapex">sample &smb.conf; file</link> for
1084 use with an LDAP directory could appear as shown below.
1088 <smbconfexample id="confldapex">
1089 <title>Configuration with LDAP</title>
1090 <smbconfsection>[global]</smbconfsection>
1091 <smbconfoption><name>security</name><value>user</value></smbconfoption>
1092 <smbconfoption><name>encrypt passwords</name><value>yes</value></smbconfoption>
1093 <smbconfoption><name>netbios name</name><value>MORIA</value></smbconfoption>
1094 <smbconfoption><name>workgroup</name><value>NOLDOR</value></smbconfoption>
1096 <smbconfcomment>ldap related parameters</smbconfcomment>
1098 <smbconfcomment>define the DN to use when binding to the directory servers</smbconfcomment>
1099 <smbconfcomment>The password for this DN is not stored in smb.conf. Rather it</smbconfcomment>
1100 <smbconfcomment>must be set by using 'smbpasswd -w <replaceable>secretpw</replaceable>' to store the</smbconfcomment>
1101 <smbconfcomment>passphrase in the secrets.tdb file. If the "ldap admin dn" values</smbconfcomment>
1102 <smbconfcomment>change, this password will need to be reset.</smbconfcomment>
1103 <smbconfoption><name>ldap admin dn</name><value>"cn=Manager,dc=quenya,dc=org"</value></smbconfoption>
1105 <smbconfcomment>Define the SSL option when connecting to the directory</smbconfcomment>
1106 <smbconfcomment>('off', 'start tls', or 'on' (default))</smbconfcomment>
1107 <smbconfoption><name>ldap ssl</name><value>start tls</value></smbconfoption>
1109 <smbconfcomment>syntax: passdb backend = ldapsam:ldap://server-name[:port]</smbconfcomment>
1110 <smbconfoption><name>passdb backend</name><value>ldapsam:ldap://frodo.quenya.org</value></smbconfoption>
1112 <smbconfcomment>smbpasswd -x delete the entire dn-entry</smbconfcomment>
1113 <smbconfoption><name>ldap delete dn</name><value>no</value></smbconfoption>
1115 <smbconfcomment>the machine and user suffix added to the base suffix</smbconfcomment>
1116 <smbconfcomment>wrote WITHOUT quotes. NULL suffixes by default</smbconfcomment>
1117 <smbconfoption><name>ldap user suffix</name><value>ou=People</value></smbconfoption>
1118 <smbconfoption><name>ldap group suffix</name><value>ou=Groups</value></smbconfoption>
1119 <smbconfoption><name>ldap machine suffix</name><value>ou=Computers</value></smbconfoption>
1121 <smbconfcomment>Trust UNIX account information in LDAP</smbconfcomment>
1122 <smbconfcomment> (see the smb.conf man page for details)</smbconfcomment>
1124 <smbconfcomment> specify the base DN to use when searching the directory</smbconfcomment>
1125 <smbconfoption><name>ldap suffix</name><value>dc=quenya,dc=org</value></smbconfoption>
1127 <smbconfcomment> generally the default ldap search filter is ok</smbconfcomment>
1128 <smbconfoption><name>ldap filter</name><value>(uid=%u)</value></smbconfoption>
1135 <title>Accounts and Groups Management</title>
1138 <indexterm><primary>User Management</primary></indexterm>
1139 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
1141 As user accounts are managed through the sambaSamAccount objectclass, you should
1142 modify your existing administration tools to deal with sambaSamAccount attributes.
1146 Machine accounts are managed with the sambaSamAccount objectclass, just
1147 like users accounts. However, it is up to you to store those accounts
1148 in a different tree of your LDAP namespace. You should use
1149 <quote>ou=Groups,dc=quenya,dc=org</quote> to store groups and
1150 <quote>ou=People,dc=quenya,dc=org</quote> to store users. Just configure your
1151 NSS and PAM accordingly (usually, in the <filename>/etc/openldap/sldap.conf</filename>
1152 configuration file).
1156 In Samba-3, the group management system is based on POSIX
1157 groups. This means that Samba makes use of the posixGroup objectclass.
1158 For now, there is no NT-like group system management (global and local
1159 groups). Samba-3 knows only about <constant>Domain Groups</constant>
1160 and, unlike MS Windows 2000 and Active Directory, Samba-3 does not
1161 support nested groups.
1167 <title>Security and sambaSamAccount</title>
1171 There are two important points to remember when discussing the security
1172 of sambaSamAccount entries in the directory.
1176 <listitem><para><emphasis>Never</emphasis> retrieve the SambaLMPassword or
1177 SambaNTPassword attribute values over an unencrypted LDAP session.</para></listitem>
1178 <listitem><para><emphasis>Never</emphasis> allow non-admin users to
1179 view the SambaLMPassword or SambaNTPassword attribute values.</para></listitem>
1183 These password hashes are clear-text equivalents and can be used to impersonate
1184 the user without deriving the original clear-text strings. For more information
1185 on the details of LM/NT password hashes, refer to the
1186 <link linkend="passdb">Account Information Database</link> section of this chapter.
1190 To remedy the first security issue, the <smbconfoption><name>ldap ssl</name></smbconfoption> &smb.conf; parameter defaults
1191 to require an encrypted session (<smbconfoption><name>ldap ssl</name><value>on</value></smbconfoption>) using
1192 the default port of <constant>636</constant>
1193 when contacting the directory server. When using an OpenLDAP server, it
1194 is possible to use the StartTLS LDAP extended operation in the place of
1195 LDAPS. In either case, you are strongly discouraged to disable this security
1196 (<smbconfoption><name>ldap ssl</name><value>off</value></smbconfoption>).
1200 Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
1201 extended operation. However, the OpenLDAP library still provides support for
1202 the older method of securing communication between clients and servers.
1206 The second security precaution is to prevent non-administrative users from
1207 harvesting password hashes from the directory. This can be done using the
1208 following ACL in <filename>slapd.conf</filename>:
1213 ## allow the "ldap admin dn" access, but deny everyone else
1214 access to attrs=SambaLMPassword,SambaNTPassword
1215 by dn="cn=Samba Admin,ou=People,dc=quenya,dc=org" write
1223 <title>LDAP Special Attributes for sambaSamAccounts</title>
1225 <para> The sambaSamAccount objectclass is composed of the attributes shown in next tables: <link
1226 linkend="attribobjclPartA">Part A</link>, and <link linkend="attribobjclPartB">Part B</link>.
1230 <table frame="all" id="attribobjclPartA">
1231 <title>Attributes in the sambaSamAccount objectclass (LDAP) &smbmdash; Part A</title>
1232 <tgroup cols="2" align="justify">
1233 <colspec align="left"/>
1234 <colspec align="justify" colwidth="1*"/>
1236 <row><entry><constant>sambaLMPassword</constant></entry><entry>The LANMAN password 16-byte hash stored as a character
1237 representation of a hexadecimal string.</entry></row>
1238 <row><entry><constant>sambaNTPassword</constant></entry><entry>The NT password hash 16-byte stored as a character
1239 representation of a hexadecimal string.</entry></row>
1240 <row><entry><constant>sambaPwdLastSet</constant></entry><entry>The integer time in seconds since 1970 when the
1241 <constant>sambaLMPassword</constant> and <constant>sambaNTPassword</constant> attributes were last set.
1244 <row><entry><constant>sambaAcctFlags</constant></entry><entry>String of 11 characters surrounded by square brackets []
1245 representing account flags such as U (user), W (workstation), X (no password expiration),
1246 I (Domain trust account), H (Home dir required), S (Server trust account),
1247 and D (disabled).</entry></row>
1249 <row><entry><constant>sambaLogonTime</constant></entry><entry>Integer value currently unused</entry></row>
1251 <row><entry><constant>sambaLogoffTime</constant></entry><entry>Integer value currently unused</entry></row>
1253 <row><entry><constant>sambaKickoffTime</constant></entry><entry>Specifies the time (UNIX time format) when the user
1254 will be locked down and cannot login any longer. If this attribute is omitted, then the account will never expire.
1255 If you use this attribute together with `shadowExpire' of the `shadowAccount' objectClass, will enable accounts to
1256 expire completely on an exact date.</entry></row>
1258 <row><entry><constant>sambaPwdCanChange</constant></entry><entry>Specifies the time (UNIX time format) from which on the user is allowed to
1259 change his password. If attribute is not set, the user will be free to change his password whenever he wants.</entry></row>
1261 <row><entry><constant>sambaPwdMustChange</constant></entry><entry>Specifies the time (UNIX time format) since when the user is
1262 forced to change his password. If this value is set to `0', the user will have to change his password at first login.
1263 If this attribute is not set, then the password will never expire.</entry></row>
1265 <row><entry><constant>sambaHomeDrive</constant></entry><entry>Specifies the drive letter to which to map the
1266 UNC path specified by sambaHomePath. The drive letter must be specified in the form <quote>X:</quote>
1267 where X is the letter of the drive to map. Refer to the <quote>logon drive</quote> parameter in the
1268 smb.conf(5) man page for more information.</entry></row>
1270 <row><entry><constant>sambaLogonScript</constant></entry><entry>The sambaLogonScript property specifies the path of
1271 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
1272 is relative to the netlogon share. Refer to the <smbconfoption><name>logon script</name></smbconfoption> parameter in the
1273 &smb.conf; man page for more information.</entry></row>
1275 <row><entry><constant>sambaProfilePath</constant></entry><entry>Specifies a path to the user's profile.
1276 This value can be a null string, a local absolute path, or a UNC path. Refer to the
1277 <smbconfoption><name>logon path</name></smbconfoption> parameter in the &smb.conf; man page for more information.</entry></row>
1279 <row><entry><constant>sambaHomePath</constant></entry><entry>The sambaHomePath property specifies the path of
1280 the home directory for the user. The string can be null. If sambaHomeDrive is set and specifies
1281 a drive letter, sambaHomePath should be a UNC path. The path must be a network
1282 UNC path of the form <filename>\\server\share\directory</filename>. This value can be a null string.
1283 Refer to the <command>logon home</command> parameter in the &smb.conf; man page for more information.
1289 <table frame="all" id="attribobjclPartB">
1290 <title>Attributes in the sambaSamAccount objectclass (LDAP) &smbmdash; Part B</title>
1291 <tgroup cols="2" align="justify">
1292 <colspec align="left"/>
1293 <colspec align="justify" colwidth="1*"/>
1295 <row><entry><constant>sambaUserWorkstations</constant></entry><entry>Here you can give a comma-separated list of machines
1296 on which the user is allowed to login. You may observe problems when you try to connect to an Samba Domain Member.
1297 Because Domain Members are not in this list, the Domain Controllers will reject them. Where this attribute is omitted,
1298 the default implies no restrictions.
1301 <row><entry><constant>sambaSID</constant></entry><entry>The security identifier(SID) of the user.
1302 The Windows equivalent of UNIX UIDs.</entry></row>
1304 <row><entry><constant>sambaPrimaryGroupSID</constant></entry><entry>The Security IDentifier (SID) of the primary group
1305 of the user.</entry></row>
1307 <row><entry><constant>sambaDomainName</constant></entry><entry>Domain the user is part of.</entry></row>
1313 The majority of these parameters are only used when Samba is acting as a PDC of
1314 a domain (refer to <link linkend="samba-pdc">Domain Control</link>, for details on
1315 how to configure Samba as a Primary Domain Controller). The following four attributes
1316 are only stored with the sambaSamAccount entry if the values are non-default values:
1320 <listitem><para>sambaHomePath</para></listitem>
1321 <listitem><para>sambaLogonScript</para></listitem>
1322 <listitem><para>sambaProfilePath</para></listitem>
1323 <listitem><para>sambaHomeDrive</para></listitem>
1327 These attributes are only stored with the sambaSamAccount entry if
1328 the values are non-default values. For example, assume MORIA has now been
1329 configured as a PDC and that <smbconfoption><name>logon home</name><value>\\%L\%u</value></smbconfoption> was defined in
1330 its &smb.conf; file. When a user named <quote>becky</quote> logons to the domain,
1331 the <smbconfoption><name>logon home</name></smbconfoption> string is expanded to \\MORIA\becky.
1332 If the smbHome attribute exists in the entry <quote>uid=becky,ou=People,dc=samba,dc=org</quote>,
1333 this value is used. However, if this attribute does not exist, then the value
1334 of the <smbconfoption><name>logon home</name></smbconfoption> parameter is used in its place. Samba
1335 will only write the attribute value to the directory entry if the value is
1336 something other than the default (e.g., <filename>\\MOBY\becky</filename>).
1342 <title>Example LDIF Entries for a sambaSamAccount</title>
1345 The following is a working LDIF that demonstrates the use of the SambaSamAccount objectclass:
1349 <smbfile name="samba.ldif.example2">
1351 dn: uid=guest2, ou=People,dc=quenya,dc=org
1352 sambaLMPassword: 878D8014606CDA29677A44EFA1353FC7
1353 sambaPwdMustChange: 2147483647
1354 sambaPrimaryGroupSID: S-1-5-21-2447931902-1787058256-3961074038-513
1355 sambaNTPassword: 552902031BEDE9EFAAD3B435B51404EE
1356 sambaPwdLastSet: 1010179124
1358 objectClass: sambaSamAccount
1360 sambaKickoffTime: 2147483647
1361 sambaAcctFlags: [UX ]
1362 sambaLogoffTime: 2147483647
1363 sambaSID: S-1-5-21-2447931902-1787058256-3961074038-5006
1364 sambaPwdCanChange: 0
1370 The following is an LDIF entry for using both the sambaSamAccount and
1371 posixAccount objectclasses:
1375 <smbfile name="samba.ldif.example3">
1377 dn: uid=gcarter, ou=People,dc=quenya,dc=org
1379 displayName: Gerald Carter
1380 sambaLMPassword: 552902031BEDE9EFAAD3B435B51404EE
1381 sambaPrimaryGroupSID: S-1-5-21-2447931902-1787058256-3961074038-1201
1382 objectClass: posixAccount
1383 objectClass: sambaSamAccount
1384 sambaAcctFlags: [UX ]
1385 userPassword: {crypt}BpM2ej8Rkzogo
1389 loginShell: /bin/bash
1390 logoffTime: 2147483647
1392 sambaKickoffTime: 2147483647
1393 sambaPwdLastSet: 1010179230
1394 sambaSID: S-1-5-21-2447931902-1787058256-3961074038-5004
1395 homeDirectory: /home/moria/gcarter
1396 sambaPwdCanChange: 0
1397 sambaPwdMustChange: 2147483647
1398 sambaNTPassword: 878D8014606CDA29677A44EFA1353FC7
1406 <title>Password Synchronization</title>
1409 Samba-3 and later can update the non-samba (LDAP) password stored with an account. When
1410 using pam_ldap, this allows changing both UNIX and Windows passwords at once.
1413 <para>The <smbconfoption><name>ldap passwd sync</name></smbconfoption> options can have the values shown in
1414 <link linkend="ldappwsync">the next table</link>.</para>
1416 <table iframe="all" id="ldappwsync">
1417 <title>Possible <emphasis>ldap passwd sync</emphasis> values</title>
1419 <colspec align="left" colwidth="1*"/>
1420 <colspec align="justify" colwidth="4*"/>
1422 <row><entry align="left">Value</entry><entry align="center">Description</entry></row>
1425 <row><entry>yes</entry><entry><para>When the user changes his password, update
1426 <constant>SambaNTPassword</constant>, <constant>SambaLMPassword</constant>
1427 and the <constant>password</constant> fields.</para></entry></row>
1429 <row><entry>no</entry><entry><para>Only update <constant>SambaNTPassword</constant> and <constant>SambaLMPassword</constant>.</para></entry></row>
1431 <row><entry>only</entry><entry><para>Only update the LDAP password and let the LDAP server worry about the other fields.
1432 This option is only available on some LDAP servers. Only when the LDAP server
1433 supports LDAP_EXOP_X_MODIFY_PASSWD.</para></entry></row>
1439 <para>More information can be found in the &smb.conf; man page.</para>
1446 <title>MySQL</title>
1449 <indexterm><primary>SAM backend</primary><secondary>mysqlsam</secondary></indexterm>
1450 Every so often someone will come along with a great new idea. Storing user accounts in a
1451 SQL backend is one of them. Those who want to do this are in the best position to know what the
1452 specific benefits are to them. This may sound like a cop-out, but in truth we cannot attempt
1453 to document every little detail why certain things of marginal utility to the bulk of
1454 Samba users might make sense to the rest. In any case, the following instructions should help
1455 the determined SQL user to implement a working system.
1459 <title>Creating the Database</title>
1462 You can set up your own table and specify the field names to pdb_mysql (see below
1463 for the column names) or use the default table. The file <filename>examples/pdb/mysql/mysql.dump</filename>
1464 contains the correct queries to create the required tables. Use the command:
1467 &prompt;<userinput>mysql -u<replaceable>username</replaceable> -h<replaceable>hostname</replaceable> -p<replaceable>password</replaceable> \
1468 <replaceable>databasename</replaceable> < <filename>/path/to/samba/examples/pdb/mysql/mysql.dump</filename></userinput>
1474 <title>Configuring</title>
1476 <para>This plug-in lacks some good documentation, but here is some brief information. Add the following to the
1477 <smbconfoption><name>passdb backend</name></smbconfoption> variable in your &smb.conf;:
1479 <smbconfoption><name>passdb backend</name><value>[other-plugins] mysql:identifier [other-plugins]</value></smbconfoption>
1483 <para>The identifier can be any string you like, as long as it does not collide with
1484 the identifiers of other plugins or other instances of pdb_mysql. If you
1485 specify multiple pdb_mysql.so entries in <smbconfoption><name>passdb backend</name></smbconfoption>, you also need to
1486 use different identifiers.
1490 Additional options can be given through the &smb.conf; file in the <smbconfsection>[global]</smbconfsection> section.
1491 Refer to <link linkend="mysqlpbe">the following table</link>.
1494 <table frame="all" id="mysqlpbe">
1495 <title>Basic smb.conf options for MySQL passdb backend</title>
1497 <colspec align="left"/>
1498 <colspec align="justify" colwidth="1*"/>
1500 <row><entry>Field</entry><entry>Contents</entry></row>
1503 <row><entry>mysql host</entry><entry>Host name, defaults to `localhost'</entry></row>
1504 <row><entry>mysql password</entry><entry></entry></row>
1505 <row><entry>mysql user</entry><entry>Defaults to `samba'</entry></row>
1506 <row><entry>mysql database</entry><entry>Defaults to `samba'</entry></row>
1507 <row><entry>mysql port</entry><entry>Defaults to 3306</entry></row>
1508 <row><entry>table</entry><entry>Name of the table containing the users</entry></row>
1515 Since the password for the MySQL user is stored in the &smb.conf; file, you should make the &smb.conf; file
1516 readable only to the user who runs Samba. This is considered a security bug and will soon be fixed.
1520 <para>Names of the columns are given in <link linkend="moremysqlpdbe">the next table</link>.
1521 The default column names can be found in the example table dump.
1525 <table frame="all" id="moremysqlpdbe">
1526 <title>MySQL field names for MySQL passdb backend</title>
1527 <tgroup cols="3" align="justify">
1528 <colspec align="left"/>
1529 <colspec align="left"/>
1530 <colspec align="justify" colwidth="1*"/>
1532 <row><entry>Field</entry><entry>Type</entry><entry>Contents</entry></row>
1535 <row><entry>logon time column</entry><entry>int(9)</entry><entry>UNIX time stamp of last logon of user</entry></row>
1536 <row><entry>logoff time column</entry><entry>int(9)</entry><entry>UNIX time stamp of last logoff of user</entry></row>
1537 <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>
1538 <row><entry>pass last set time column</entry><entry>int(9)</entry><entry>UNIX time stamp of moment password was last set</entry></row>
1539 <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>
1540 <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>
1541 <row><entry>username column</entry><entry>varchar(255)</entry><entry>UNIX username</entry></row>
1542 <row><entry>domain column</entry><entry>varchar(255)</entry><entry>NT domain user belongs to</entry></row>
1543 <row><entry>nt username column</entry><entry>varchar(255)</entry><entry>NT username</entry></row>
1544 <row><entry>fullname column</entry><entry>varchar(255)</entry><entry>Full name of user</entry></row>
1545 <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>
1546 <row><entry>dir drive column</entry><entry>varchar(2)</entry><entry>Directory drive path (e.g., <quote>H:</quote>)</entry></row>
1547 <row><entry>logon script column</entry><entry>varchar(255)</entry><entry>Batch file to run on client side when logging on</entry></row>
1548 <row><entry>profile path column</entry><entry>varchar(255)</entry><entry>Path of profile</entry></row>
1549 <row><entry>acct desc column</entry><entry>varchar(255)</entry><entry>Some ASCII NT user data</entry></row>
1550 <row><entry>workstations column</entry><entry>varchar(255)</entry><entry>Workstations user can logon to (or NULL for all)</entry></row>
1551 <row><entry>unknown string column</entry><entry>varchar(255)</entry><entry>Unknown string</entry></row>
1552 <row><entry>munged dial column</entry><entry>varchar(255)</entry><entry>Unknown</entry></row>
1553 <row><entry>user sid column</entry><entry>varchar(255)</entry><entry>NT user SID</entry></row>
1554 <row><entry>group sid column</entry><entry>varchar(255)</entry><entry>NT group SID</entry></row>
1555 <row><entry>lanman pass column</entry><entry>varchar(255)</entry><entry>Encrypted lanman password</entry></row>
1556 <row><entry>nt pass column</entry><entry>varchar(255)</entry><entry>Encrypted nt passwd</entry></row>
1557 <row><entry>plain pass column</entry><entry>varchar(255)</entry><entry>Plaintext password</entry></row>
1558 <row><entry>acct ctrl column</entry><entry>int(9)</entry><entry>NT user data</entry></row>
1559 <row><entry>unknown 3 column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1560 <row><entry>logon divs column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1561 <row><entry>hours len column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1562 <row><entry>bad password count column</entry><entry>int(5)</entry><entry>Number of failed password tries before disabling an account</entry></row>
1563 <row><entry>logon count column</entry><entry>int(5)</entry><entry>Number of logon attempts</entry></row>
1564 <row><entry>unknown 6 column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1570 You can put a colon (:) after the name of each column, which
1571 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.
1574 <para><link linkend="mysqlsam">An example configuration</link> looks like:
1577 <smbconfexample id="mysqlsam">
1578 <title>Example configuration for the MySQL passdb backend</title>
1579 <smbconfsection>[global]</smbconfsection>
1580 <smbconfoption><name>passdb backend</name><value>mysql:foo</value></smbconfoption>
1581 <smbconfoption><name>foo:mysql user</name><value>samba</value></smbconfoption>
1582 <smbconfoption><name>foo:mysql password</name><value>abmas</value></smbconfoption>
1583 <smbconfoption><name>foo:mysql database</name><value>samba</value></smbconfoption>
1584 <smbconfcomment>domain name is static and can't be changed</smbconfcomment>
1585 <smbconfoption><name>foo:domain column</name><value>'MYWORKGROUP':</value></smbconfoption>
1586 <smbconfcomment>The fullname column comes from several other columns</smbconfcomment>
1587 <smbconfoption><name>foo:fullname column</name><value>CONCAT(firstname,' ',surname):</value></smbconfoption>
1588 <smbconfcomment>Samba should never write to the password columns</smbconfcomment>
1589 <smbconfoption><name>foo:lanman pass column</name><value>lm_pass:</value></smbconfoption>
1590 <smbconfoption><name>foo:nt pass column</name><value>nt_pass:</value></smbconfoption>
1591 <smbconfcomment>The unknown 3 column is not stored</smbconfcomment>
1592 <smbconfoption><name>foo:unknown 3 column</name><value>NULL</value></smbconfoption>
1597 <title>Using Plaintext Passwords or Encrypted Password</title>
1600 <indexterm><primary>encrypted passwords</primary></indexterm>
1601 I strongly discourage the use of plaintext passwords, however, you can use them.
1605 If you would like to use plaintext passwords, set
1606 `identifier:lanman pass column' and `identifier:nt pass column' to
1607 `NULL' (without the quotes) and `identifier:plain pass column' to the
1608 name of the column containing the plaintext passwords.
1612 If you use encrypted passwords, set the 'identifier:plain pass
1613 column' to 'NULL' (without the quotes). This is the default.
1619 <title>Getting Non-Column Data from the Table</title>
1622 It is possible to have not all data in the database by making some `constant'.
1626 For example, you can set `identifier:fullname column' to
1627 something like <?latex \linebreak ?><command>CONCAT(Firstname,' ',Surname)</command>
1631 Or, set `identifier:workstations column' to:
1632 <command>NULL</command></para>
1634 <para>See the MySQL documentation for more language constructs.</para>
1639 <sect2 id="XMLpassdb">
1643 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
1644 This module requires libxml2 to be installed.</para>
1646 <para>The usage of pdb_xml is fairly straightforward. To export data, use:
1650 <indexterm><primary>pdbedit</primary></indexterm>
1651 <prompt>$ </prompt> <userinput>pdbedit -e xml:filename</userinput>
1655 (where filename is the name of the file to put the data in)
1659 To import data, use:
1660 <prompt>$ </prompt> <userinput>pdbedit -i xml:filename</userinput>
1666 <title>Common Errors</title>
1669 <title>Users Cannot Logon</title>
1671 <para><quote>I've installed Samba, but now I can't log on with my UNIX account! </quote></para>
1673 <para>Make sure your user has been added to the current Samba <smbconfoption><name>passdb backend</name></smbconfoption>.
1674 Read the section <link linkend="acctmgmttools">Account Management Tools</link> for details.</para>
1679 <title>Users Being Added to the Wrong Backend Database</title>
1682 A few complaints have been received from users that just moved to Samba-3. The following
1683 &smb.conf; file entries were causing problems, new accounts were being added to the old
1684 smbpasswd file, not to the tdbsam passdb.tdb file:
1689 <smbconfsection>[global]</smbconfsection>
1690 <member>...</member>
1691 <smbconfoption><name>passdb backend</name><value>smbpasswd, tdbsam</value></smbconfoption>
1692 <member>...</member>
1697 Samba will add new accounts to the first entry in the <emphasis>passdb backend</emphasis>
1698 parameter entry. If you want to update to the tdbsam, then change the entry to:
1705 <smbconfoption><name>passdb backend</name><value>tdbsam, smbpasswd</value></smbconfoption>
1713 <title>Configuration of <parameter>auth methods</parameter></title>
1716 When explicitly setting an <smbconfoption><name>auth methods</name></smbconfoption> parameter,
1717 <parameter>guest</parameter> must be specified as the first entry on the line,
1718 for example, <smbconfoption><name>auth methods</name><value>guest sam</value></smbconfoption>.
1722 This is the exact opposite of the requirement for the <smbconfoption><name>passdb backend</name></smbconfoption>
1723 option, where it must be the <emphasis>LAST</emphasis> parameter on the line.