7 <author>&person.gd;<contrib>LDAP updates</contrib></author>
9 <firstname>Olivier (lem)</firstname><surname>Lemaire</surname>
11 <orgname>IDEALX</orgname>
12 <address><email>olem@IDEALX.org</email></address>
16 <pubdate>May 24, 2003</pubdate>
18 <title>Account Information Databases</title>
21 Samba-3 implements a new capability to work concurrently with multiple account backends.
22 The possible new combinations of password backends allows Samba-3 a degree of flexibility
23 and scalability that previously could be achieved only with MS Windows Active Directory.
24 This chapter describes the new functionality and how to get the most out of it.
28 In the development of Samba-3, a number of requests were received to provide the
29 ability to migrate MS Windows NT4 SAM accounts to Samba-3 without the need to provide
30 matching UNIX/Linux accounts. We called this the <emphasis>Non-UNIX Accounts (NUA)</emphasis>
31 capability. The intent was that an administrator could decide to use the <emphasis>tdbsam</emphasis>
32 backend and by simply specifying <smbconfoption><name>passdb backend</name><value>tdbsam_nua</value></smbconfoption>,
33 this would allow Samba-3 to implement a solution that did not use UNIX accounts per se. Late
34 in the development cycle, the team doing this work hit upon some obstacles that prevents this
35 solution from being used. Given the delays with the Samba-3 release, a decision was made to not
36 deliver this functionality until a better method of recognizing NT Group SIDs from NT User
37 SIDs could be found. This feature may return during the life cycle for the Samba-3 series.
41 Samba-3 does not support Non-UNIX Account (NUA) operation for user accounts.
42 Samba-3 does support NUA operation for machine accounts.
46 <title>Features and Benefits</title>
49 Samba-3 provides for complete backward compatibility with Samba-2.2.x functionality
51 <indexterm><primary>SAM backend</primary><secondary>smbpasswd</secondary></indexterm>
52 <indexterm><primary>SAM backend</primary><secondary>ldapsam_compat</secondary></indexterm>
53 <indexterm><primary>encrypted passwords</primary></indexterm>
59 <title>Backward Compatibility Backends</title>
62 <varlistentry><term>Plain Text</term>
65 This option uses nothing but the UNIX/Linux <filename>/etc/passwd</filename>
66 style backend. On systems that have Pluggable Authentication Modules (PAM)
67 support, all PAM modules are supported. The behavior is just as it was with
68 Samba-2.2.x, and the protocol limitations imposed by MS Windows clients
69 apply likewise. Please refer to <link linkend="passdbtech"/> for more information
70 regarding the limitations of Plain Text password usage.
75 <varlistentry><term>smbpasswd</term>
78 This option allows continued use of the <filename>smbpasswd</filename>
79 file that maintains a plain ASCII (text) layout that includes the MS Windows
80 LanMan and NT encrypted passwords as well as a field that stores some
81 account information. This form of password backend does not store any of
82 the MS Windows NT/200x SAM (Security Account Manager) information required to
83 provide the extended controls that are needed for more comprehensive
84 interoperation with MS Windows NT4/200x servers.
88 This backend should be used only for backward compatibility with older
89 versions of Samba. It may be deprecated in future releases.
94 <varlistentry><term>ldapsam_compat (Samba-2.2 LDAP Compatibility)</term>
97 There is a password backend option that allows continued operation with
98 an existing OpenLDAP backend that uses the Samba-2.2.x LDAP schema extension.
99 This option is provided primarily as a migration tool, although there is
100 no reason to force migration at this time. This tool will eventually
110 <title>New Backends</title>
113 Samba-3 introduces a number of new password backend capabilities.
114 <indexterm><primary>SAM backend</primary><secondary>tdbsam</secondary></indexterm>
115 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
116 <indexterm><primary>SAM backend</primary><secondary>mysqlsam</secondary></indexterm>
117 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
121 <varlistentry><term>tdbsam</term>
124 This backend provides a rich database backend for local servers. This
125 backend is not suitable for multiple Domain Controllers (i.e., PDC + one
126 or more BDC) installations.
130 The <emphasis>tdbsam</emphasis> password backend stores the old <emphasis>
131 smbpasswd</emphasis> information plus the extended MS Windows NT / 200x
132 SAM information into a binary format TDB (trivial database) file.
133 The inclusion of the extended information makes it possible for Samba-3
134 to implement the same account and system access controls that are possible
135 with MS Windows NT4/200x-based systems.
139 The inclusion of the <emphasis>tdbsam</emphasis> capability is a direct
140 response to user requests to allow simple site operation without the overhead
141 of the complexities of running OpenLDAP. It is recommended to use this only
142 for sites that have fewer than 250 users. For larger sites or implementations,
143 the use of OpenLDAP or of Active Directory integration is strongly recommended.
148 <varlistentry><term>ldapsam</term>
151 This provides a rich directory backend for distributed account installation.
155 Samba-3 has a new and extended LDAP implementation that requires configuration
156 of OpenLDAP with a new format Samba schema. The new format schema file is
157 included in the <filename class="directory">examples/LDAP</filename> directory of the Samba distribution.
161 The new LDAP implementation significantly expands the control abilities that
162 were possible with prior versions of Samba. It is now possible to specify
163 <quote>per user</quote> profile settings, home directories, account access controls, and
164 much more. Corporate sites will see that the Samba Team has listened to their
165 requests both for capability and to allow greater scalability.
170 <varlistentry><term>mysqlsam (MySQL based backend)</term>
173 It is expected that the MySQL-based SAM will be very popular in some corners.
174 This database backend will be of considerable interest to sites that want to
175 leverage existing MySQL technology.
180 <varlistentry><term>xmlsam (XML based datafile)</term>
183 <indexterm><primary>pdbedit</primary></indexterm>
184 Allows the account and password data to be stored in an XML format
185 data file. This backend cannot be used for normal operation, it can only
186 be used in conjunction with <command>pdbedit</command>'s pdb2pdb
187 functionality. The DTD that is used might be subject to changes in the future.
191 The <parameter>xmlsam</parameter> option can be useful for account migration between database
192 backends or backups. Use of this tool will allow the data to be edited before migration
193 into another backend format.
204 <sect1 id="passdbtech">
205 <title>Technical Information</title>
208 Old Windows clients send plain text passwords over the wire. Samba can check these
209 passwords by encrypting them and comparing them to the hash stored in the UNIX user database.
213 <indexterm><primary>encrypted passwords</primary></indexterm>
214 Newer Windows clients send encrypted passwords (so-called Lanman and NT hashes) over
215 the wire, instead of plain text passwords. The newest clients will send only encrypted
216 passwords and refuse to send plain text passwords, unless their registry is tweaked.
220 These passwords can't be converted to UNIX-style encrypted passwords. Because of that,
221 you can't use the standard UNIX user database, and you have to store the Lanman and NT
222 hashes somewhere else.
226 In addition to differently encrypted passwords, Windows also stores certain data for each
227 user that is not stored in a UNIX user database. For example, workstations the user may logon from,
228 the location where the user's profile is stored, and so on. Samba retrieves and stores this
229 information using a <smbconfoption><name>passdb backend</name></smbconfoption>. Commonly available backends are LDAP, plain text
230 file, and MySQL. For more information, see the man page for &smb.conf; regarding the
231 <smbconfoption><name>passdb backend</name></smbconfoption> parameter.
235 <image scale="50" id="idmap-sid2uid"><imagedescription>IDMAP: Resolution of SIDs to UIDs.</imagedescription><imagefile>idmap-sid2uid</imagefile></image>
238 <indexterm><primary>SID</primary></indexterm>
239 The resolution of SIDs to UIDs is fundamental to correct operation of Samba. In both cases shown, if winbindd is not running, or cannot
240 be contacted, then only local SID/UID resolution is possible. See <link linkend="idmap-sid2uid"/> and
241 <link linkend="idmap-uid2sid"/>.
244 <image scale="50" id="idmap-uid2sid"><imagedescription>IDMAP: Resolution of UIDs to SIDs.</imagedescription><imagefile>idmap-uid2sid</imagefile></image>
247 <title>Important Notes About Security</title>
250 The UNIX and SMB password encryption techniques seem similar on the surface. This
251 similarity is, however, only skin deep. The UNIX scheme typically sends cleartext
252 passwords over the network when logging in. This is bad. The SMB encryption scheme
253 never sends the cleartext password over the network but it does store the 16 byte
254 hashed values on disk. This is also bad. Why? Because the 16 byte hashed values
255 are a <quote>password equivalent.</quote> You cannot derive the user's password from them, but
256 they could potentially be used in a modified client to gain access to a server.
257 This would require considerable technical knowledge on behalf of the attacker but
258 is perfectly possible. You should thus treat the datastored in whatever passdb
259 backend you use (smbpasswd file, LDAP, MYSQL) as though it contained the cleartext
260 passwords of all your users. Its contents must be kept secret and the file should
261 be protected accordingly.
265 Ideally, we would like a password scheme that involves neither plain text passwords
266 on the network nor on disk. Unfortunately, this is not available as Samba is stuck with
267 having to be compatible with other SMB systems (Windows NT, Windows for Workgroups, Windows 9x/Me).
271 Windows NT 4.0 Service Pack 3 changed the default setting so plaintext passwords
272 are disabled from being sent over the wire. This mandates either the use of encrypted
273 password support or editing the Windows NT registry to re-enable plaintext passwords.
277 The following versions of Microsoft Windows do not support full domain security protocols,
278 although they may log onto a domain environment:
282 <listitem><para>MS DOS Network client 3.0 with the basic network redirector installed.</para></listitem>
283 <listitem><para>Windows 95 with the network redirector update installed.</para></listitem>
284 <listitem><para>Windows 98 [Second Edition].</para></listitem>
285 <listitem><para>Windows Me.</para></listitem>
290 MS Windows XP Home does not have facilities to become a Domain Member and it cannot participate in domain logons.
295 The following versions of MS Windows fully support domain security protocols.
299 <listitem><para>Windows NT 3.5x.</para></listitem>
300 <listitem><para>Windows NT 4.0.</para></listitem>
301 <listitem><para>Windows 2000 Professional.</para></listitem>
302 <listitem><para>Windows 200x Server/Advanced Server.</para></listitem>
303 <listitem><para>Windows XP Professional.</para></listitem>
307 All current releases of Microsoft SMB/CIFS clients support authentication via the
308 SMB Challenge/Response mechanism described here. Enabling cleartext authentication
309 does not disable the ability of the client to participate in encrypted authentication.
310 Instead, it allows the client to negotiate either plain text or encrypted password
315 MS Windows clients will cache the encrypted password alone. Where plain text passwords
316 are re-enabled through the appropriate registry change, the plain text password is never
317 cached. This means that in the event that a network connections should become disconnected
318 (broken), only the cached (encrypted) password will be sent to the resource server to
319 effect an auto-reconnect. If the resource server does not support encrypted passwords the
320 auto-reconnect will fail. Use of encrypted passwords is strongly advised.
324 <title>Advantages of Encrypted Passwords</title>
327 <listitem><para>Plaintext passwords are not passed across
328 the network. Someone using a network sniffer cannot just
329 record passwords going to the SMB server.</para></listitem>
331 <listitem><para>Plaintext passwords are not stored anywhere in
332 memory or on disk.</para></listitem>
334 <listitem><para>Windows NT does not like talking to a server
335 that does not support encrypted passwords. It will refuse
336 to browse the server if the server is also in User Level
337 security mode. It will insist on prompting the user for the
338 password on each connection, which is very annoying. The
339 only things you can do to stop this is to use SMB encryption.
342 <listitem><para>Encrypted password support allows automatic share
343 (resource) reconnects.</para></listitem>
345 <listitem><para>Encrypted passwords are essential for PDC/BDC
346 operation.</para></listitem>
352 <title>Advantages of Non-Encrypted Passwords</title>
355 <listitem><para>Plaintext passwords are not kept
356 on disk, and are not cached in memory. </para></listitem>
358 <listitem><para>Uses same password file as other UNIX
359 services such as Login and FTP.</para></listitem>
361 <listitem><para>Use of other services (such as Telnet and FTP) that
362 send plain text passwords over the network, so sending them for SMB
363 is not such a big deal.</para></listitem>
369 <title>Mapping User Identifiers between MS Windows and UNIX</title>
372 Every operation in UNIX/Linux requires a user identifier (UID), just as in
373 MS Windows NT4/200x this requires a Security Identifier (SID). Samba provides
374 two means for mapping an MS Windows user to a UNIX/Linux UID.
378 First, all Samba SAM (Security Account Manager database) accounts require
379 a UNIX/Linux UID that the account will map to. As users are added to the account
380 information database, Samba will call the <smbconfoption><name>add user script</name></smbconfoption>
381 interface to add the account to the Samba host OS. In essence all accounts in
382 the local SAM require a local user account.
386 The second way to effect Windows SID to UNIX UID mapping is via the
387 <emphasis>idmap uid</emphasis> and <emphasis>idmap gid</emphasis> parameters in &smb.conf;.
388 Please refer to the man page for information about these parameters.
389 These parameters are essential when mapping users from a remote SAM server.
394 <sect2 id="idmapbackend">
395 <title>Mapping Common UIDs/GIDs on Distributed Machines</title>
398 Samba-3 has a special facility that makes it possible to maintain identical UIDs and GIDs
399 on all servers in a distributed network. A distributed network is one where there exists
400 a PDC, one or more BDCs and/or one or more Domain Member servers. Why is this important?
401 This is important if files are being shared over more than one protocol (e.g., NFS) and where
402 users are copying files across UNIX/Linux systems using tools such as <command>rsync</command>.
406 The special facility is enabled using a parameter called <parameter>idmap backend</parameter>.
407 The default setting for this parameter is an empty string. Technically it is possible to use
408 an LDAP based idmap backend for UIDs and GIDs, but it makes most sense when this is done for
409 network configurations that also use LDAP for the SAM backend. A sample use is shown in
410 <link linkend="idmapbackendexample"/>.
414 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
415 <smbconfexample id="idmapbackendexample">
416 <title>Example configuration with the LDAP idmap backend</title>
417 <smbconfsection>[global]</smbconfsection>
418 <smbconfoption><name>idmap backend</name><value>ldapsam:ldap://ldap-server.quenya.org:636</value></smbconfoption>
419 <smbconfcomment>Alternately, this could be specified as:</smbconfcomment>
420 <smbconfoption><name>idmap backend</name><value>ldapsam:ldaps://ldap-server.quenya.org</value></smbconfoption>
425 A network administrator who wants to make significant use of LDAP backends will sooner or later be
426 exposed to the excellent work done by PADL Software. PADL <ulink url="http://www.padl.com"/> have
427 produced and released to open source an array of tools that might be of interest. These tools include:
433 <emphasis>nss_ldap:</emphasis> An LDAP Name Service Switch module to provide native
434 name service support for AIX, Linux, Solaris, and other operating systems. This tool
435 can be used for centralized storage and retrieval of UIDs/GIDs.
441 <emphasis>pam_ldap:</emphasis> A PAM module that provides LDAP integration for UNIX/Linux
442 system access authentication.
447 <emphasis>idmap_ad:</emphasis> An IDMAP backend that supports the Microsoft Services for
448 UNIX RFC 2307 schema available from their web
449 <ulink url="http://www.padl.com/download/xad_oss_plugins.tar.gz">site</ulink>.
458 <sect1 id="acctmgmttools">
459 <title>Account Management Tools</title>
462 <indexterm><primary>pdbedit</primary></indexterm>
463 Samba provides two tools for management of user and machine accounts. These tools are
464 called <command>smbpasswd</command> and <command>pdbedit</command>. A third tool is under
465 development but is not expected to ship in time for Samba-3.0.0. The new tool will be a TCL/TK
466 GUI tool that looks much like the MS Windows NT4 Domain User Manager. Hopefully this will
467 be announced in time for the Samba-3.0.1 release.
470 <title>The <emphasis>smbpasswd</emphasis> Command</title>
473 The smbpasswd utility is similar to the <command>passwd</command>
474 or <command>yppasswd</command> programs. It maintains the two 32 byte password
475 fields in the passdb backend.
479 <command>smbpasswd</command> works in a client-server mode where it contacts the
480 local smbd to change the user's password on its behalf. This has enormous benefits.
484 <command>smbpasswd</command> has the capability to change passwords on Windows NT
485 servers (this only works when the request is sent to the NT Primary Domain Controller
486 if changing an NT Domain user's password).
490 <command>smbpasswd</command> can be used to:
491 <indexterm><primary>User Management</primary></indexterm>
492 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
497 <listitem><para><emphasis>add</emphasis> user or machine accounts.</para></listitem>
498 <listitem><para><emphasis>delete</emphasis> user or machine accounts.</para></listitem>
499 <listitem><para><emphasis>enable</emphasis> user or machine accounts.</para></listitem>
500 <listitem><para><emphasis>disable</emphasis> user or machine accounts.</para></listitem>
501 <listitem><para><emphasis>set to NULL</emphasis> user passwords.</para></listitem>
502 <listitem><para><emphasis>manage interdomain trust accounts.</emphasis></para></listitem>
506 To run smbpasswd as a normal user just type:
511 &prompt;<userinput>smbpasswd</userinput>
512 <prompt>Old SMB password: </prompt><userinput><replaceable>secret</replaceable></userinput>
514 For <replaceable>secret</replaceable>, type old value here or press return if
515 there is no old password.
517 <prompt>New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
518 <prompt>Repeat New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
523 If the old value does not match the current value stored for that user, or the two
524 new values do not match each other, then the password will not be changed.
528 When invoked by an ordinary user, the command will only allow the user to change his or her own
533 When run by root, <command>smbpasswd</command> may take an optional argument specifying
534 the user name whose SMB password you wish to change. When run as root, <command>smbpasswd</command>
535 does not prompt for or check the old password value, thus allowing root to set passwords
536 for users who have forgotten their passwords.
540 <command>smbpasswd</command> is designed to work in the way familiar to UNIX
541 users who use the <command>passwd</command> or <command>yppasswd</command> commands.
542 While designed for administrative use, this tool provides essential User Level
543 password change capabilities.
547 For more details on using <command>smbpasswd</command>, refer to the man page (the
548 definitive reference).
552 <sect2 id="pdbeditthing">
553 <title>The <emphasis>pdbedit</emphasis> Command</title>
556 <indexterm><primary>pdbedit</primary></indexterm>
557 <command>pdbedit</command> is a tool that can be used only by root. It is used to
558 manage the passdb backend. <command>pdbedit</command> can be used to:
559 <indexterm><primary>User Management</primary></indexterm>
560 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
565 <listitem><para>add, remove or modify user accounts.</para></listitem>
566 <listitem><para>list user accounts.</para></listitem>
567 <listitem><para>migrate user accounts.</para></listitem>
571 <indexterm><primary>pdbedit</primary></indexterm>
572 The <command>pdbedit</command> tool is the only one that can manage the account
573 security and policy settings. It is capable of all operations that smbpasswd can
574 do as well as a super set of them.
578 <indexterm><primary>pdbedit</primary></indexterm>
579 One particularly important purpose of the <command>pdbedit</command> is to allow
580 the migration of account information from one passdb backend to another. See the
581 <link linkend="XMLpassdb">XML</link> password backend section of this chapter.
585 The following is an example of the user account information that is stored in
586 a tdbsam password backend. This listing was produced by running:
590 &prompt;<userinput>pdbedit -Lv met</userinput>
594 User SID: S-1-5-21-1449123459-1407424037-3116680435-2004
595 Primary Group SID: S-1-5-21-1449123459-1407424037-3116680435-1201
596 Full Name: Melissa E Terpstra
597 Home Directory: \\frodo\met\Win9Profile
599 Logon Script: scripts\logon.bat
600 Profile Path: \\frodo\Profiles\met
601 Domain: &example.workgroup;
603 Workstations: melbelle
606 Logoff time: Mon, 18 Jan 2038 20:14:07 GMT
607 Kickoff time: Mon, 18 Jan 2038 20:14:07 GMT
608 Password last set: Sat, 14 Dec 2002 14:37:03 GMT
609 Password can change: Sat, 14 Dec 2002 14:37:03 GMT
610 Password must change: Mon, 18 Jan 2038 20:14:07 GMT
614 <indexterm><primary>pdbedit</primary></indexterm>
615 The <command>pdbedit</command> tool allows migration of authentication (account)
616 databases from one backend to another. For example: To migrate accounts from an
617 old <filename>smbpasswd</filename> database to a <parameter>tdbsam</parameter>
623 Set the <smbconfoption><name>passdb backend</name><value>tdbsam, smbpasswd</value></smbconfoption>.
629 &rootprompt;<userinput>pdbedit -i smbpassed -e tdbsam</userinput>
634 Now remove the <parameter>smbpasswd</parameter> from the passdb backend
635 configuration in &smb.conf;.
643 <title>Password Backends</title>
646 Samba offers the greatest flexibility in backend account database design of any SMB/CIFS server
647 technology available today. The flexibility is immediately obvious as one begins to explore this
652 It is possible to specify not only multiple different password backends, but even multiple
653 backends of the same type. For example, to use two different tdbsam databases:
658 <smbconfoption><name>passdb backend</name><value>tdbsam:/etc/samba/passdb.tdb \</value></smbconfoption>
659 <member><parameter>tdbsam:/etc/samba/old-passdb.tdb</parameter></member>
665 <title>Plaintext</title>
668 Older versions of Samba retrieved user information from the UNIX user database
669 and eventually some other fields from the file <filename>/etc/samba/smbpasswd</filename>
670 or <filename>/etc/smbpasswd</filename>. When password encryption is disabled, no
671 SMB specific data is stored at all. Instead all operations are conducted via the way
672 that the Samba host OS will access its <filename>/etc/passwd</filename> database.
673 Linux systems For example, all operations are done via PAM.
679 <title>smbpasswd &smbmdash; Encrypted Password Database</title>
682 <indexterm><primary>SAM backend</primary><secondary>smbpasswd</secondary></indexterm>
683 Traditionally, when configuring <smbconfoption><name>encrypt passwords</name><value>yes</value></smbconfoption> in Samba's &smb.conf; file, user account
684 information such as username, LM/NT password hashes, password change times, and account
685 flags have been stored in the <filename>smbpasswd(5)</filename> file. There are several
686 disadvantages to this approach for sites with large numbers of users (counted
692 The first problem is that all lookups must be performed sequentially. Given that
693 there are approximately two lookups per domain logon (one for a normal
694 session connection such as when mapping a network drive or printer), this
695 is a performance bottleneck for large sites. What is needed is an indexed approach
696 such as used in databases.
700 The second problem is that administrators who desire to replicate a smbpasswd file
701 to more than one Samba server were left to use external tools such as
702 <command>rsync(1)</command> and <command>ssh(1)</command> and wrote custom,
707 Finally, the amount of information that is stored in an smbpasswd entry leaves
708 no room for additional attributes such as a home directory, password expiration time,
709 or even a Relative Identifier (RID).
714 As a result of these deficiencies, a more robust means of storing user attributes
715 used by smbd was developed. The API which defines access to user accounts
716 is commonly referred to as the samdb interface (previously this was called the passdb
717 API, and is still so named in the Samba CVS trees).
721 Samba provides an enhanced set of passdb backends that overcome the deficiencies
722 of the smbpasswd plain text database. These are tdbsam, ldapsam and xmlsam.
723 Of these, ldapsam will be of most interest to large corporate or enterprise sites.
729 <title>tdbsam</title>
732 <indexterm><primary>SAM backend</primary><secondary>tdbsam</secondary></indexterm>
733 Samba can store user and machine account data in a <quote>TDB</quote> (Trivial Database).
734 Using this backend does not require any additional configuration. This backend is
735 recommended for new installations that do not require LDAP.
739 As a general guide, the Samba Team does not recommend using the tdbsam backend for sites
740 that have 250 or more users. Additionally, tdbsam is not capable of scaling for use
741 in sites that require PDB/BDC implementations that require replication of the account
742 database. Clearly, for reason of scalability, the use of ldapsam should be encouraged.
746 The recommendation of a 250 user limit is purely based on the notion that this
747 would generally involve a site that has routed networks, possibly spread across
748 more than one physical location. The Samba Team has not at this time established
749 the performance based scalability limits of the tdbsam architecture.
755 <title>ldapsam</title>
758 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
759 There are a few points to stress that the ldapsam does not provide. The LDAP
760 support referred to in this documentation does not include:
764 <listitem><para>A means of retrieving user account information from
765 an Windows 200x Active Directory server.</para></listitem>
766 <listitem><para>A means of replacing /etc/passwd.</para></listitem>
770 The second item can be accomplished by using LDAP NSS and PAM modules. LGPL
771 versions of these libraries can be obtained from
772 <ulink url="http://www.padl.com/">PADL Software</ulink>.
773 More information about the configuration of these packages may be found at
774 <ulink url="http://safari.oreilly.com/?XmlId=1-56592-491-6">
775 <emphasis>LDAP, System Administration</emphasis>; Gerald Carter by O'Reilly; Chapter 6: Replacing NIS."</ulink>
779 This document describes how to use an LDAP directory for storing Samba user
780 account information traditionally stored in the smbpasswd(5) file. It is
781 assumed that the reader already has a basic understanding of LDAP concepts
782 and has a working directory server already installed. For more information
783 on LDAP architectures and directories, please refer to the following sites:
787 <listitem><para><ulink url="http://www.openldap.org/">OpenLDAP</ulink></para></listitem>
788 <listitem><para><ulink url="http://iplanet.netscape.com/directory">Sun iPlanet Directory Server</ulink></para></listitem>
792 Two additional Samba resources which may prove to be helpful are:
796 <listitem><para>The <ulink url="http://www.unav.es/cti/ldap-smb/ldap-smb-3-howto.html">Samba-PDC-LDAP-HOWTO</ulink>
797 maintained by Ignacio Coupeau.</para></listitem>
799 <listitem><para>The NT migration scripts from <ulink url="http://samba.idealx.org/">IDEALX</ulink> that are
800 geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
805 <title>Supported LDAP Servers</title>
808 The LDAP ldapsam code has been developed and tested using the OpenLDAP 2.0 and 2.1 server and
809 client libraries. The same code should work with Netscape's Directory Server and client SDK.
810 However, there are bound to be compile errors and bugs. These should not be hard to fix.
811 Please submit fixes via the process outlined in <link linkend="bugreport"/>.
817 <title>Schema and Relationship to the RFC 2307 posixAccount</title>
821 Samba-3.0 includes the necessary schema file for OpenLDAP 2.0 in
822 <filename>examples/LDAP/samba.schema</filename>. The sambaSamAccount objectclass is given here:
827 objectclass (1.3.6.1.4.1.7165.2.2.6 NAME 'sambaSamAccount' SUP top AUXILIARY
828 DESC 'Samba-3.0 Auxiliary SAM Account'
829 MUST ( uid $ sambaSID )
830 MAY ( cn $ sambaLMPassword $ sambaNTPassword $ sambaPwdLastSet $
831 sambaLogonTime $ sambaLogoffTime $ sambaKickoffTime $
832 sambaPwdCanChange $ sambaPwdMustChange $ sambaAcctFlags $
833 displayName $ sambaHomePath $ sambaHomeDrive $ sambaLogonScript $
834 sambaProfilePath $ description $ sambaUserWorkstations $
835 sambaPrimaryGroupSID $ sambaDomainName ))
840 The <filename>samba.schema</filename> file has been formatted for OpenLDAP 2.0/2.1.
841 The Samba Team owns the OID space used by the above schema and recommends its use.
842 If you translate the schema to be used with Netscape DS, please submit the modified
843 schema file as a patch to <ulink url="mailto:jerry@samba.org">jerry@samba.org</ulink>.
847 Just as the smbpasswd file is meant to store information that provides information additional to a
848 user's <filename>/etc/passwd</filename> entry, so is the sambaSamAccount object
849 meant to supplement the UNIX user account information. A sambaSamAccount is a
850 <constant>AUXILIARY</constant> objectclass so it can be used to augment existing
851 user account information in the LDAP directory, thus providing information needed
852 for Samba account handling. However, there are several fields (e.g., uid) that overlap
853 with the posixAccount objectclass outlined in RFC2307. This is by design.
856 <!--olem: we should perhaps have a note about shadowAccounts too as many
857 systems use them, isn'it ? -->
860 In order to store all user account information (UNIX and Samba) in the directory,
861 it is necessary to use the sambaSamAccount and posixAccount objectclasses in
862 combination. However, smbd will still obtain the user's UNIX account
863 information via the standard C library calls (e.g., getpwnam(), et al).
864 This means that the Samba server must also have the LDAP NSS library installed
865 and functioning correctly. This division of information makes it possible to
866 store all Samba account information in LDAP, but still maintain UNIX account
867 information in NIS while the network is transitioning to a full LDAP infrastructure.
872 <title>OpenLDAP Configuration</title>
875 To include support for the sambaSamAccount object in an OpenLDAP directory
876 server, first copy the samba.schema file to slapd's configuration directory.
877 The samba.schema file can be found in the directory <filename>examples/LDAP</filename>
878 in the Samba source distribution.
883 &rootprompt;<userinput>cp samba.schema /etc/openldap/schema/</userinput>
888 Next, include the <filename>samba.schema</filename> file in <filename>slapd.conf</filename>.
889 The sambaSamAccount object contains two attributes that depend on other schema
890 files. The <parameter>uid</parameter> attribute is defined in <filename>cosine.schema</filename> and
891 the <parameter>displayName</parameter> attribute is defined in the <filename>inetorgperson.schema</filename>
892 file. Both of these must be included before the <filename>samba.schema</filename> file.
897 ## /etc/openldap/slapd.conf
899 ## schema files (core.schema is required by default)
900 include /etc/openldap/schema/core.schema
902 ## needed for sambaSamAccount
903 include /etc/openldap/schema/cosine.schema
904 include /etc/openldap/schema/inetorgperson.schema
905 include /etc/openldap/schema/samba.schema
906 include /etc/openldap/schema/nis.schema
912 It is recommended that you maintain some indices on some of the most useful attributes,
913 as in the following example, to speed up searches made on sambaSamAccount objectclasses
914 (and possibly posixAccount and posixGroup as well):
919 # Indices to maintain
920 ## required by OpenLDAP
925 ## required to support pdb_getsampwnam
926 index uid pres,sub,eq
927 ## required to support pdb_getsambapwrid()
928 index displayName pres,sub,eq
930 ## uncomment these if you are storing posixAccount and
931 ## posixGroup entries in the directory as well
937 index sambaPrimaryGroupSID eq
938 index sambaDomainName eq
944 Create the new index by executing:
949 &rootprompt;./sbin/slapindex -f slapd.conf
954 Remember to restart slapd after making these changes:
959 &rootprompt;<userinput>/etc/init.d/slapd restart</userinput>
966 <title>Initialize the LDAP Database</title>
969 Before you can add accounts to the LDAP database you must create the account containers
970 that they will be stored in. The following LDIF file should be modified to match your
971 needs (DNS entries, and so on):
976 # Organization for Samba Base
978 objectclass: dcObject
979 objectclass: organization
981 o: Quenya Org Network
982 description: The Samba-3 Network LDAP Example
984 # Organizational Role for Directory Management
985 dn: cn=Manager,dc=quenya,dc=org
986 objectclass: organizationalRole
988 description: Directory Manager
990 # Setting up container for users
991 dn: ou=People,dc=quenya,dc=org
993 objectclass: organizationalUnit
996 # Setting up admin handle for People OU
997 dn: cn=admin,ou=People,dc=quenya,dc=org
1000 objectclass: organizationalRole
1001 objectclass: simpleSecurityObject
1002 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1004 # Setting up container for groups
1005 dn: ou=Groups,dc=quenya,dc=org
1007 objectclass: organizationalUnit
1010 # Setting up admin handle for Groups OU
1011 dn: cn=admin,ou=Groups,dc=quenya,dc=org
1014 objectclass: organizationalRole
1015 objectclass: simpleSecurityObject
1016 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1018 # Setting up container for computers
1019 dn: ou=Computers,dc=quenya,dc=org
1021 objectclass: organizationalUnit
1024 # Setting up admin handle for Computers OU
1025 dn: cn=admin,ou=Computers,dc=quenya,dc=org
1028 objectclass: organizationalRole
1029 objectclass: simpleSecurityObject
1030 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1035 The userPassword shown above should be generated using <command>slappasswd</command>.
1039 The following command will then load the contents of the LDIF file into the LDAP
1045 &prompt;<userinput>slapadd -v -l initldap.dif</userinput>
1050 Do not forget to secure your LDAP server with an adequate access control list
1051 as well as an admin password.
1056 Before Samba can access the LDAP server you need to store the LDAP admin password
1057 into the Samba-3 <filename>secrets.tdb</filename> database by:
1059 &rootprompt;<userinput>smbpasswd -w <replaceable>secret</replaceable></userinput>
1067 <title>Configuring Samba</title>
1070 The following parameters are available in smb.conf only if your
1071 version of Samba was built with LDAP support. Samba automatically builds with LDAP support if the
1072 LDAP libraries are found.
1075 <para>LDAP related smb.conf options:
1076 <smbconfoption><name>passdb backend</name><value>ldapsam:url</value></smbconfoption>,
1077 <smbconfoption><name>ldap admin dn</name></smbconfoption>,
1078 <smbconfoption><name>ldap delete dn</name></smbconfoption>,
1079 <smbconfoption><name>ldap filter</name></smbconfoption>,
1080 <smbconfoption><name>ldap group suffix</name></smbconfoption>,
1081 <smbconfoption><name>ldap idmap suffix</name></smbconfoption>,
1082 <smbconfoption><name>ldap machine suffix</name></smbconfoption>,
1083 <smbconfoption><name>ldap passwd sync</name></smbconfoption>,
1084 <smbconfoption><name>ldap ssl</name></smbconfoption>,
1085 <smbconfoption><name>ldap suffix</name></smbconfoption>,
1086 <smbconfoption><name>ldap user suffix</name></smbconfoption>,
1090 These are described in the &smb.conf; man
1091 page and so will not be repeated here. However, a sample &smb.conf; file for
1092 use with an LDAP directory could appear as shown in <link linkend="confldapex"/>.
1096 <smbconfexample id="confldapex">
1097 <title>Configuration with LDAP</title>
1098 <smbconfsection>[global]</smbconfsection>
1099 <smbconfoption><name>security</name><value>user</value></smbconfoption>
1100 <smbconfoption><name>encrypt passwords</name><value>yes</value></smbconfoption>
1101 <smbconfoption><name>netbios name</name><value>MORIA</value></smbconfoption>
1102 <smbconfoption><name>workgroup</name><value>NOLDOR</value></smbconfoption>
1104 <smbconfcomment>ldap related parameters</smbconfcomment>
1106 <smbconfcomment>define the DN to use when binding to the directory servers</smbconfcomment>
1107 <smbconfcomment>The password for this DN is not stored in smb.conf. Rather it</smbconfcomment>
1108 <smbconfcomment>must be set by using 'smbpasswd -w <replaceable>secretpw</replaceable>' to store the</smbconfcomment>
1109 <smbconfcomment>passphrase in the secrets.tdb file. If the "ldap admin dn" values</smbconfcomment>
1110 <smbconfcomment>change, this password will need to be reset.</smbconfcomment>
1111 <smbconfoption><name>ldap admin dn</name><value>"cn=Manager,ou=People,dc=quenya,dc=org"</value></smbconfoption>
1113 <smbconfcomment>Define the SSL option when connecting to the directory</smbconfcomment>
1114 <smbconfcomment>('off', 'start tls', or 'on' (default))</smbconfcomment>
1115 <smbconfoption><name>ldap ssl</name><value>start tls</value></smbconfoption>
1117 <smbconfcomment>syntax: passdb backend = ldapsam:ldap://server-name[:port]</smbconfcomment>
1118 <smbconfoption><name>passdb backend</name><value>ldapsam:ldap://frodo.quenya.org</value></smbconfoption>
1120 <smbconfcomment>smbpasswd -x delete the entire dn-entry</smbconfcomment>
1121 <smbconfoption><name>ldap delete dn</name><value>no</value></smbconfoption>
1123 <smbconfcomment>the machine and user suffix added to the base suffix</smbconfcomment>
1124 <smbconfcomment>wrote WITHOUT quotes. NULL suffixes by default</smbconfcomment>
1125 <smbconfoption><name>ldap user suffix</name><value>ou=People</value></smbconfoption>
1126 <smbconfoption><name>ldap group suffix</name><value>ou=Groups</value></smbconfoption>
1127 <smbconfoption><name>ldap machine suffix</name><value>ou=Computers</value></smbconfoption>
1129 <smbconfcomment>Trust UNIX account information in LDAP</smbconfcomment>
1130 <smbconfcomment> (see the smb.conf manpage for details)</smbconfcomment>
1132 <smbconfcomment> specify the base DN to use when searching the directory</smbconfcomment>
1133 <smbconfoption><name>ldap suffix</name><value>ou=People,dc=quenya,dc=org</value></smbconfoption>
1135 <smbconfcomment> generally the default ldap search filter is ok</smbconfcomment>
1136 <smbconfoption><name>ldap filter</name><value>(&(uid=%u)(objectclass=sambaSamAccount))</value></smbconfoption>
1143 <title>Accounts and Groups Management</title>
1146 <indexterm><primary>User Management</primary></indexterm>
1147 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
1149 As user accounts are managed through the sambaSamAccount objectclass, you should
1150 modify your existing administration tools to deal with sambaSamAccount attributes.
1154 Machine accounts are managed with the sambaSamAccount objectclass, just
1155 like users accounts. However, it is up to you to store those accounts
1156 in a different tree of your LDAP namespace. You should use
1157 <quote>ou=Groups,dc=quenya,dc=org</quote> to store groups and
1158 <quote>ou=People,dc=quenya,dc=org</quote> to store users. Just configure your
1159 NSS and PAM accordingly (usually, in the <filename>/etc/openldap/sldap.conf</filename>
1160 configuration file).
1164 In Samba-3, the group management system is based on POSIX
1165 groups. This means that Samba makes use of the posixGroup objectclass.
1166 For now, there is no NT-like group system management (global and local
1167 groups). Samba-3 knows only about <constant>Domain Groups</constant>
1168 and, unlike MS Windows 2000 and Active Directory, Samba-3 does not
1169 support nested groups.
1175 <title>Security and sambaSamAccount</title>
1179 There are two important points to remember when discussing the security
1180 of sambaSamAccount entries in the directory.
1184 <listitem><para><emphasis>Never</emphasis> retrieve the lmPassword or
1185 ntPassword attribute values over an unencrypted LDAP session.</para></listitem>
1186 <listitem><para><emphasis>Never</emphasis> allow non-admin users to
1187 view the lmPassword or ntPassword attribute values.</para></listitem>
1191 These password hashes are cleartext equivalents and can be used to impersonate
1192 the user without deriving the original cleartext strings. For more information
1193 on the details of LM/NT password hashes, refer to the
1194 <link linkend="passdb">Account Information Database</link> section of this chapter.
1198 To remedy the first security issue, the <smbconfoption><name>ldap ssl</name></smbconfoption> &smb.conf; parameter defaults
1199 to require an encrypted session (<smbconfoption><name>ldap ssl</name><value>on</value></smbconfoption>) using
1200 the default port of <constant>636</constant>
1201 when contacting the directory server. When using an OpenLDAP server, it
1202 is possible to use the use the StartTLS LDAP extended operation in the place of
1203 LDAPS. In either case, you are strongly discouraged to disable this security
1204 (<smbconfoption><name>ldap ssl</name><value>off</value></smbconfoption>).
1208 Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
1209 extended operation. However, the OpenLDAP library still provides support for
1210 the older method of securing communication between clients and servers.
1214 The second security precaution is to prevent non-administrative users from
1215 harvesting password hashes from the directory. This can be done using the
1216 following ACL in <filename>slapd.conf</filename>:
1221 ## allow the "ldap admin dn" access, but deny everyone else
1222 access to attrs=lmPassword,ntPassword
1223 by dn="cn=Samba Admin,ou=People,dc=quenya,dc=org" write
1231 <title>LDAP Special Attributes for sambaSamAccounts</title>
1234 The sambaSamAccount objectclass is composed of the attributes shown in <link linkend="attribobjclPartA"/>, and <link linkend="attribobjclPartB"/>.
1238 <table frame="all" id="attribobjclPartA">
1239 <title>Attributes in the sambaSamAccount objectclass (LDAP) &smbmdash; Part A</title>
1240 <tgroup cols="2" align="justify">
1241 <colspec align="left"/>
1242 <colspec align="justify" colwidth="1*"/>
1244 <row><entry><constant>sambaLMPassword</constant></entry><entry>The LANMAN password 16-byte hash stored as a character
1245 representation of a hexadecimal string.</entry></row>
1246 <row><entry><constant>sambaNTPassword</constant></entry><entry>The NT password hash 16-byte stored as a character
1247 representation of a hexadecimal string.</entry></row>
1248 <row><entry><constant>sambaPwdLastSet</constant></entry><entry>The integer time in seconds since 1970 when the
1249 <constant>sambaLMPassword</constant> and <constant>sambaNTPassword</constant> attributes were last set.
1252 <row><entry><constant>sambaAcctFlags</constant></entry><entry>String of 11 characters surrounded by square brackets []
1253 representing account flags such as U (user), W (workstation), X (no password expiration),
1254 I (Domain trust account), H (Home dir required), S (Server trust account),
1255 and D (disabled).</entry></row>
1257 <row><entry><constant>sambaLogonTime</constant></entry><entry>Integer value currently unused</entry></row>
1259 <row><entry><constant>sambaLogoffTime</constant></entry><entry>Integer value currently unused</entry></row>
1261 <row><entry><constant>sambaKickoffTime</constant></entry><entry>Specifies the time (UNIX time format) when the user
1262 will be locked down and cannot login any longer. If this attribute is ommited, then the account will never expire.
1263 If you use this attribute together with `shadowExpire' of the `shadowAccount' objectClass, will enable accounts to
1264 expire completly on an exact date.</entry></row>
1266 <row><entry><constant>sambaPwdCanChange</constant></entry><entry>Specifies the time (UNIX time format) from which on the user is allowed to
1267 change his password. If attribute is not set, the user will be free to change his password whenever he wants.</entry></row>
1269 <row><entry><constant>sambaPwdMustChange</constant></entry><entry>Specifies the time (UNIX time format) since when the user is
1270 forced to change his password. If this value is set to `0', the user will have to change his password at first login.
1271 If this attribute is not set, then the password will never expire.</entry></row>
1273 <row><entry><constant>sambaHomeDrive</constant></entry><entry>Specifies the drive letter to which to map the
1274 UNC path specified by sambaHomePath. The drive letter must be specified in the form <quote>X:</quote>
1275 where X is the letter of the drive to map. Refer to the <quote>logon drive</quote> parameter in the
1276 smb.conf(5) man page for more information.</entry></row>
1278 <row><entry><constant>sambaLogonScript</constant></entry><entry>The sambaLogonScript property specifies the path of
1279 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
1280 is relative to the netlogon share. Refer to the <smbconfoption><name>logon script</name></smbconfoption> parameter in the
1281 &smb.conf; man page for more information.</entry></row>
1283 <row><entry><constant>sambaProfilePath</constant></entry><entry>Specifies a path to the user's profile.
1284 This value can be a null string, a local absolute path, or a UNC path. Refer to the
1285 <smbconfoption><name>logon path</name></smbconfoption> parameter in the &smb.conf; man page for more information.</entry></row>
1287 <row><entry><constant>sambaHomePath</constant></entry><entry>The sambaHomePath property specifies the path of
1288 the home directory for the user. The string can be null. If sambaHomeDrive is set and specifies
1289 a drive letter, sambaHomePath should be a UNC path. The path must be a network
1290 UNC path of the form <filename>\\server\share\directory</filename>. This value can be a null string.
1291 Refer to the <command>logon home</command> parameter in the &smb.conf; man page for more information.
1297 <table frame="all" id="attribobjclPartB">
1298 <title>Attributes in the sambaSamAccount objectclass (LDAP) &smbmdash; Part B</title>
1299 <tgroup cols="2" align="justify">
1300 <colspec align="left"/>
1301 <colspec align="justify" colwidth="1*"/>
1303 <row><entry><constant>sambaUserWorkstations</constant></entry><entry>Here you can give a comma-seperated list of machines
1304 on which the user is allowed to login. You may observe problems when you try to connect to an Samba Domain Member.
1305 Bacause Domain Members are not in this list, the Domain Controllers will reject them. Where this attribute is ommited,
1306 the default implies no restrictions.
1309 <row><entry><constant>sambaSID</constant></entry><entry>The security identifier(SID) of the user.
1310 The Windows equivalent of UNIX UIDs.</entry></row>
1312 <row><entry><constant>sambaPrimaryGroupSID</constant></entry><entry>The Security IDentifier (SID) of the primary group
1313 of the user.</entry></row>
1315 <row><entry><constant>sambaDomainName</constant></entry><entry>Domain the user is part of.</entry></row>
1321 The majority of these parameters are only used when Samba is acting as a PDC of
1322 a domain (refer to <link linkend="samba-pdc"/>, for details on
1323 how to configure Samba as a Primary Domain Controller). The following four attributes
1324 are only stored with the sambaSamAccount entry if the values are non-default values:
1328 <listitem><para>sambaHomePath</para></listitem>
1329 <listitem><para>sambaLogonScript</para></listitem>
1330 <listitem><para>sambaProfilePath</para></listitem>
1331 <listitem><para>sambaHomeDrive</para></listitem>
1335 These attributes are only stored with the sambaSamAccount entry if
1336 the values are non-default values. For example, assume MORIA has now been
1337 configured as a PDC and that <smbconfoption><name>logon home</name><value>\\%L\%u</value></smbconfoption> was defined in
1338 its &smb.conf; file. When a user named <quote>becky</quote> logons to the domain,
1339 the <smbconfoption><name>logon home</name></smbconfoption> string is expanded to \\MORIA\becky.
1340 If the smbHome attribute exists in the entry <quote>uid=becky,ou=People,dc=samba,dc=org</quote>,
1341 this value is used. However, if this attribute does not exist, then the value
1342 of the <smbconfoption><name>logon home</name></smbconfoption> parameter is used in its place. Samba
1343 will only write the attribute value to the directory entry if the value is
1344 something other than the default (e.g., <filename>\\MOBY\becky</filename>).
1350 <title>Example LDIF Entries for a sambaSamAccount</title>
1353 The following is a working LDIF that demonstrates the use of the SambaSamAccount objectclass:
1358 dn: uid=guest2, ou=People,dc=quenya,dc=org
1359 sambaLMPassword: 878D8014606CDA29677A44EFA1353FC7
1360 sambaPwdMustChange: 2147483647
1361 sambaPrimaryGroupSID: S-1-5-21-2447931902-1787058256-3961074038-513
1362 sambaNTPassword: 552902031BEDE9EFAAD3B435B51404EE
1363 sambaPwdLastSet: 1010179124
1365 objectClass: sambaSamAccount
1367 sambaKickoffTime: 2147483647
1368 sambaAcctFlags: [UX ]
1369 sambaLogoffTime: 2147483647
1370 sambaSID: S-1-5-21-2447931902-1787058256-3961074038-5006
1371 sambaPwdCanChange: 0
1376 The following is an LDIF entry for using both the sambaSamAccount and
1377 posixAccount objectclasses:
1382 dn: uid=gcarter, ou=People,dc=quenya,dc=org
1384 displayName: Gerald Carter
1385 sambaLMPassword: 552902031BEDE9EFAAD3B435B51404EE
1386 sambaPrimaryGroupSID: S-1-5-21-2447931902-1787058256-3961074038-1201
1387 objectClass: posixAccount
1388 objectClass: sambaSamAccount
1389 sambaAcctFlags: [UX ]
1390 userPassword: {crypt}BpM2ej8Rkzogo
1394 loginShell: /bin/bash
1395 logoffTime: 2147483647
1397 sambaKickoffTime: 2147483647
1398 sambaPwdLastSet: 1010179230
1399 sambaSID: S-1-5-21-2447931902-1787058256-3961074038-5004
1400 homeDirectory: /home/moria/gcarter
1401 sambaPwdCanChange: 0
1402 sambaPwdMustChange: 2147483647
1403 sambaNTPassword: 878D8014606CDA29677A44EFA1353FC7
1410 <title>Password Synchronization</title>
1413 Samba-3 and later can update the non-samba (LDAP) password stored with an account. When
1414 using pam_ldap, this allows changing both UNIX and Windows passwords at once.
1417 <para>The <smbconfoption><name>ldap passwd sync</name></smbconfoption> options can have the values shown in
1418 <link linkend="ldappwsync"/>.</para>
1420 <table frame="all" id="ldappwsync">
1421 <title>Possible <emphasis>ldap passwd sync</emphasis> values</title>
1423 <colspec align="left" colwidth="1*"/>
1424 <colspec align="justify" colwidth="4*"/>
1426 <row><entry align="left">Value</entry><entry align="center">Description</entry></row>
1429 <row><entry>yes</entry><entry><para>When the user changes his password, update
1430 <constant>ntPassword</constant>, <constant>lmPassword</constant>
1431 and the <constant>password</constant> fields.</para></entry></row>
1433 <row><entry>no</entry><entry><para>Only update <constant>ntPassword</constant> and <constant>lmPassword</constant>.</para></entry></row>
1435 <row><entry>only</entry><entry><para>Only update the LDAP password and let the LDAP server worry about the other fields.
1436 This option is only available on some LDAP servers. Only when the LDAP server
1437 supports LDAP_EXOP_X_MODIFY_PASSWD.</para></entry></row>
1443 <para>More information can be found in the &smb.conf; manpage.</para>
1450 <title>MySQL</title>
1453 <indexterm><primary>SAM backend</primary><secondary>mysqlsam</secondary></indexterm>
1454 Every so often someone will come along with a great new idea. Storing user accounts in a
1455 SQL backend is one of them. Those who want to do this are in the best position to know what the
1456 specific benefits are to them. This may sound like a cop-out, but in truth we cannot attempt
1457 to document every little detail why certain things of marginal utility to the bulk of
1458 Samba users might make sense to the rest. In any case, the following instructions should help
1459 the determined SQL user to implement a working system.
1463 <title>Creating the Database</title>
1466 You can set up your own table and specify the field names to pdb_mysql (see below
1467 for the column names) or use the default table. The file <filename>examples/pdb/mysql/mysql.dump</filename>
1468 contains the correct queries to create the required tables. Use the command:
1471 &prompt;<userinput>mysql -u<replaceable>username</replaceable> -h<replaceable>hostname</replaceable> -p<replaceable>password</replaceable> \
1472 <replaceable>databasename</replaceable> < <filename>/path/to/samba/examples/pdb/mysql/mysql.dump</filename></userinput>
1478 <title>Configuring</title>
1480 <para>This plugin lacks some good documentation, but here is some brief infoormation. Add the following to the
1481 <smbconfoption><name>passdb backend</name></smbconfoption> variable in your &smb.conf;:
1483 <smbconfoption><name>passdb backend</name><value>[other-plugins] mysql:identifier [other-plugins]</value></smbconfoption>
1487 <para>The identifier can be any string you like, as long as it does not collide with
1488 the identifiers of other plugins or other instances of pdb_mysql. If you
1489 specify multiple pdb_mysql.so entries in <smbconfoption><name>passdb backend</name></smbconfoption>, you also need to
1490 use different identifiers.
1494 Additional options can be given through the &smb.conf; file in the <smbconfsection>[global]</smbconfsection> section.
1495 Refer to <link linkend="mysqlpbe"/>.
1498 <table frame="all" id="mysqlpbe">
1499 <title>Basic smb.conf options for MySQL passdb backend</title>
1501 <colspec align="left"/>
1502 <colspec align="justify" colwidth="1*"/>
1504 <row><entry>Field</entry><entry>Contents</entry></row>
1507 <row><entry>mysql host</entry><entry>Host name, defaults to `localhost'</entry></row>
1508 <row><entry>mysql password</entry><entry></entry></row>
1509 <row><entry>mysql user</entry><entry>Defaults to `samba'</entry></row>
1510 <row><entry>mysql database</entry><entry>Defaults to `samba'</entry></row>
1511 <row><entry>mysql port</entry><entry>Defaults to 3306</entry></row>
1512 <row><entry>table</entry><entry>Name of the table containing the users</entry></row>
1519 Since the password for the MySQL user is stored in the &smb.conf; file, you should make the &smb.conf; file
1520 readable only to the user who runs Samba. This is considered a security bug and will soon be fixed.
1524 <para>Names of the columns are given in <link linkend="moremysqlpdbe"/>. The default column names can be found in the example table dump.
1528 <table frame="all" id="moremysqlpdbe">
1529 <title>MySQL field names for MySQL passdb backend</title>
1530 <tgroup cols="3" align="justify">
1531 <colspec align="left"/>
1532 <colspec align="left"/>
1533 <colspec align="justify" colwidth="1*"/>
1535 <row><entry>Field</entry><entry>Type</entry><entry>Contents</entry></row>
1538 <row><entry>logon time column</entry><entry>int(9)</entry><entry>UNIX time stamp of last logon of user</entry></row>
1539 <row><entry>logoff time column</entry><entry>int(9)</entry><entry>UNIX time stamp of last logoff of user</entry></row>
1540 <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>
1541 <row><entry>pass last set time column</entry><entry>int(9)</entry><entry>UNIX time stamp of moment password was last set</entry></row>
1542 <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>
1543 <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>
1544 <row><entry>username column</entry><entry>varchar(255)</entry><entry>UNIX username</entry></row>
1545 <row><entry>domain column</entry><entry>varchar(255)</entry><entry>NT domain user belongs to</entry></row>
1546 <row><entry>nt username column</entry><entry>varchar(255)</entry><entry>NT username</entry></row>
1547 <row><entry>fullname column</entry><entry>varchar(255)</entry><entry>Full name of user</entry></row>
1548 <row><entry>home dir column</entry><entry>varchar(255)</entry><entry>UNIX homedir path</entry></row>
1549 <row><entry>dir drive column</entry><entry>varchar(2)</entry><entry>Directory drive path (e.g., <quote>H:</quote>)</entry></row>
1550 <row><entry>logon script column</entry><entry>varchar(255)</entry><entry>Batch file to run on client side when logging on</entry></row>
1551 <row><entry>profile path column</entry><entry>varchar(255)</entry><entry>Path of profile</entry></row>
1552 <row><entry>acct desc column</entry><entry>varchar(255)</entry><entry>Some ASCII NT user data</entry></row>
1553 <row><entry>workstations column</entry><entry>varchar(255)</entry><entry>Workstations user can logon to (or NULL for all)</entry></row>
1554 <row><entry>unknown string column</entry><entry>varchar(255)</entry><entry>Unknown string</entry></row>
1555 <row><entry>munged dial column</entry><entry>varchar(255)</entry><entry>Unknown</entry></row>
1556 <row><entry>user sid column</entry><entry>varchar(255)</entry><entry>NT user SID</entry></row>
1557 <row><entry>group sid column</entry><entry>varchar(255)</entry><entry>NT group SID</entry></row>
1558 <row><entry>lanman pass column</entry><entry>varchar(255)</entry><entry>Encrypted lanman password</entry></row>
1559 <row><entry>nt pass column</entry><entry>varchar(255)</entry><entry>Encrypted nt passwd</entry></row>
1560 <row><entry>plain pass column</entry><entry>varchar(255)</entry><entry>Plaintext password</entry></row>
1561 <row><entry>acct ctrl column</entry><entry>int(9)</entry><entry>NT user data</entry></row>
1562 <row><entry>unknown 3 column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1563 <row><entry>logon divs column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1564 <row><entry>hours len column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1565 <row><entry>bad password count column</entry><entry>int(5)</entry><entry>Number of failed password tries before disabling an account</entry></row>
1566 <row><entry>logon count column</entry><entry>int(5)</entry><entry>Number of logon attempts</entry></row>
1567 <row><entry>unknown 6 column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1573 You can put a colon (:) after the name of each column, which
1574 should specify the column to update when updating the table. You can also
1575 specify nothing behind the colon. Then the field data will not be updated. Setting a column name to <parameter>NULL</parameter> means the field should not be used.
1578 <para>An example configuration can be found in <link linkend="mysqlsam"/>.
1581 <smbconfexample id="mysqlsam">
1582 <title>Example configuration for the MySQL passdb backend</title>
1583 <smbconfsection>[global]</smbconfsection>
1584 <smbconfoption><name>passdb backend</name><value>mysql:foo</value></smbconfoption>
1585 <smbconfoption><name>foo:mysql user</name><value>samba</value></smbconfoption>
1586 <smbconfoption><name>foo:mysql password</name><value>abmas</value></smbconfoption>
1587 <smbconfoption><name>foo:mysql database</name><value>samba</value></smbconfoption>
1588 <smbconfcomment>domain name is static and can't be changed</smbconfcomment>
1589 <smbconfoption><name>foo:domain column</name><value>'MYWORKGROUP':</value></smbconfoption>
1590 <smbconfcomment>The fullname column comes from several other columns</smbconfcomment>
1591 <smbconfoption><name>foo:fullname column</name><value>CONCAT(firstname,' ',surname):</value></smbconfoption>
1592 <smbconfcomment>Samba should never write to the password columns</smbconfcomment>
1593 <smbconfoption><name>foo:lanman pass column</name><value>lm_pass:</value></smbconfoption>
1594 <smbconfoption><name>foo:nt pass column</name><value>nt_pass:</value></smbconfoption>
1595 <smbconfcomment>The unknown 3 column is not stored</smbconfcomment>
1596 <smbconfoption><name>foo:unknown 3 column</name><value>NULL</value></smbconfoption>
1601 <title>Using Plaintext Passwords or Encrypted Password</title>
1604 <indexterm><primary>encrypted passwords</primary></indexterm>
1605 I strongly discourage the use of plaintext passwords, however, you can use them.
1609 If you would like to use plaintext passwords, set
1610 `identifier:lanman pass column' and `identifier:nt pass column' to
1611 `NULL' (without the quotes) and `identifier:plain pass column' to the
1612 name of the column containing the plaintext passwords.
1616 If you use encrypted passwords, set the 'identifier:plain pass
1617 column' to 'NULL' (without the quotes). This is the default.
1623 <title>Getting Non-Column Data from the Table</title>
1626 It is possible to have not all data in the database by making some `constant'.
1630 For example, you can set `identifier:fullname column' to
1631 something like <?latex \linebreak ?><command>CONCAT(Firstname,' ',Surname)</command>
1635 Or, set `identifier:workstations column' to:
1636 <command>NULL</command></para>
1638 <para>See the MySQL documentation for more language constructs.</para>
1643 <sect2 id="XMLpassdb">
1647 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
1648 This module requires libxml2 to be installed.</para>
1650 <para>The usage of pdb_xml is fairly straightforward. To export data, use:
1654 <indexterm><primary>pdbedit</primary></indexterm>
1655 <prompt>$ </prompt> <userinput>pdbedit -e xml:filename</userinput>
1659 (where filename is the name of the file to put the data in)
1663 To import data, use:
1664 <prompt>$ </prompt> <userinput>pdbedit -i xml:filename</userinput>
1670 <title>Common Errors</title>
1673 <title>Users Cannot Logon</title>
1675 <para><quote>I've installed Samba, but now I can't log on with my UNIX account! </quote></para>
1677 <para>Make sure your user has been added to the current Samba <smbconfoption><name>passdb backend</name></smbconfoption>. Read the section <link linkend="acctmgmttools"/> for details.</para>
1682 <title>Users Being Added to the Wrong Backend Database</title>
1685 A few complaints have been received from users that just moved to Samba-3. The following
1686 &smb.conf; file entries were causing problems, new accounts were being added to the old
1687 smbpasswd file, not to the tdbsam passdb.tdb file:
1692 <smbconfoption><name>passdb backend</name><value>smbpasswd, tdbsam</value></smbconfoption>
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:
1703 <smbconfsection>[globals]</smbconfsection>
1704 <member>...</member>
1705 <smbconfoption><name>passdb backend</name><value>tdbsam, smbpasswd</value></smbconfoption>
1706 <member>...</member>
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.