Progress commit.
[Samba.git] / docs / Samba3-HOWTO / TOSHARG-Passdb.xml
blob5ec5c62a8f73fba26aa2d558068db3484f0020a7
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="passdb">
4 <chapterinfo>
5         &author.jelmer;
6         &author.jht;
7         &author.jerry;
8         &author.jeremy;
9         <author>&person.gd;<contrib>LDAP updates</contrib></author>
10         <author>
11                 <firstname>Olivier (lem)</firstname><surname>Lemaire</surname>
12                 <affiliation>
13                         <orgname>IDEALX</orgname>
14                         <address><email>olem@IDEALX.org</email></address>
15                 </affiliation>
16         </author>
17         
18         <pubdate>May 24, 2003</pubdate>
19 </chapterinfo>
20 <title>Account Information Databases</title>
22 <para>
23 <indexterm><primary>account backends</primary></indexterm>
24 <indexterm><primary>password backends</primary></indexterm>
25 <indexterm><primary>scalability</primary></indexterm>
26 <indexterm><primary>ADS</primary></indexterm>
27 Samba-3 implements a new capability to work concurrently with multiple account backends.
28 The possible new combinations of password backends allows Samba-3 a degree of flexibility
29 and scalability that previously could be achieved only with MS Windows Active Directory (ADS).
30 This chapter describes the new functionality and how to get the most out of it.
31 </para>
33 <para>
34 <indexterm><primary>passdb backend</primary></indexterm>
35 <indexterm><primary>smbpasswd</primary></indexterm>
36 <indexterm><primary>tdbsam</primary></indexterm>
37 <indexterm><primary>ldapsam</primary></indexterm>
38 <indexterm><primary>LDAP</primary></indexterm>
39 <indexterm><primary>single repository</primary></indexterm>
40 The three passdb backends that are fully maintained (actively supported) by the Samba Team are:
41 <literal>smbpasswd</literal> (being obsoleted), <literal>tdbsam</literal> (a tdb based binary file format),
42 and <literal>ldapsam</literal> (LDAP directory).  Of these, only the <literal>ldapsam</literal> backend
43 stores both POSIX (UNIX) and Samba user and group account information in a single repository. The
44 <literal>smbpasswd</literal> and <literal>tdbsam</literal> backends store only Samba user accounts.
45 </para>
47 <para>
48 In a strict sense, there are three supported account storage and access systems. One of these is considered
49 obsolete (smbpasswd). It is recommended to use <literal>tdbsam</literal> method for all simple systems. Use
50 the <literal>ldapsam</literal> for larger and more complex networks.
51 </para>
53 <para>
54 <indexterm><primary>passdb backend</primary></indexterm>
55 <indexterm><primary>account storage mechanisms</primary></indexterm>
56 <indexterm><primary>account storage system</primary></indexterm>
57 <indexterm><primary>user and trust accounts</primary></indexterm>
58 <indexterm><primary>machine trust accounts</primary></indexterm>
59 <indexterm><primary>computer accounts</primary></indexterm>
60 <indexterm><primary>interdomain trust accounts</primary></indexterm>
61 In a strict and literal sense, the passdb backends are account storage mechanisms (or methods) alone. The choice
62 of terminology can be misleading, however we are stuck with this choice of wording. This chapter documents the
63 nature of the account storage system with a focus on user and trust accounts. Trust accounts have two forms,
64 machine trust accounts (computer accounts) and interdomain trust accounts. These are all treated as user-like
65 entities.
66 </para>
68 <sect1>
69 <title>Features and Benefits</title>
71 <para>
72 Samba-3 provides for complete backward compatibility with Samba-2.2.x functionality
73 as follows:
74 <indexterm><primary>SAM backend</primary><secondary>smbpasswd</secondary></indexterm>
75 <indexterm><primary>SAM backend</primary><secondary>ldapsam_compat</secondary></indexterm>
76 <indexterm><primary>encrypted passwords</primary></indexterm>
77 </para>
79 <sect2>
80         <title>Backward Compatibility Account Storage Systems</title>
82 <variablelist>
83         <varlistentry><term>Plaintext</term>
84                 <listitem>
85                         <para>
86 <indexterm><primary>plaintext</primary></indexterm>
87 <indexterm><primary>plaintext authentication</primary></indexterm>
88 <indexterm><primary>/etc/passwd</primary></indexterm>
89 <indexterm><primary>/etc/shadow</primary></indexterm>
90 <indexterm><primary>PAM</primary></indexterm>
91                         This isn't really a backend at all, but is listed here for simplicity.  Samba can be configured to pass
92                         plaintext authentication requests to the traditional UNIX/Linux <filename>/etc/passwd</filename> and
93                         <filename>/etc/shadow</filename>-style subsystems.  On systems that have Pluggable Authentication Modules
94                         (PAM) support, all PAM modules are supported. The behavior is just as it was with Samba-2.2.x, and the
95                         protocol limitations imposed by MS Windows clients apply likewise. Please refer to <link
96                         linkend="passdbtech">Technical Information</link>, for more information regarding the limitations of plaintext
97                         password usage.
98                         </para>
99                 </listitem>
100         </varlistentry>
102         <varlistentry><term>smbpasswd</term>
103                 <listitem>
104                         <para>
105 <indexterm><primary>smbpasswd</primary></indexterm>
106 <indexterm><primary>LanMan passwords</primary></indexterm>
107 <indexterm><primary>NT-encrypted passwords</primary></indexterm>
108 <indexterm><primary>SAM</primary></indexterm>
109                         This option allows continued use of the <filename>smbpasswd</filename>
110                         file that maintains a plain ASCII (text) layout that includes the MS Windows
111                         LanMan and NT-encrypted passwords as well as a field that stores some
112                         account information. This form of password backend does not store any of
113                         the MS Windows NT/200x SAM (Security Account Manager) information required to
114                         provide the extended controls that are needed for more comprehensive 
115                         interoperation with MS Windows NT4/200x servers.
116                         </para>
118                         <para>
119                         This backend should be used only for backward compatibility with older
120                         versions of Samba. It may be deprecated in future releases.
121                         </para>
122                 </listitem>
123         </varlistentry>
125         <varlistentry><term>ldapsam_compat (Samba-2.2 LDAP Compatibility)</term>
126                 <listitem>
127                         <para>
128 <indexterm><primary>ldapsam_compat</primary></indexterm>
129 <indexterm><primary>Samba-2.2.x LDAP schema</primary></indexterm>
130 <indexterm><primary>OpenLDAP backend</primary></indexterm>
131                         There is a password backend option that allows continued operation with
132                         an existing OpenLDAP backend that uses the Samba-2.2.x LDAP schema extension.
133                         This option is provided primarily as a migration tool, although there is
134                         no reason to force migration at this time. This tool will eventually
135                         be deprecated.
136                         </para>
137                 </listitem>
138         </varlistentry>
139 </variablelist>
141 </sect2>
143 <sect2>
144 <title>New Account Storage Systems</title>
146 <para>
147 Samba-3 introduces a number of new password backend capabilities.
148 <indexterm><primary>SAM backend</primary><secondary>tdbsam</secondary></indexterm>
149 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
150 <indexterm><primary>SAM backend</primary><secondary>mysqlsam</secondary></indexterm>
151 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
152 </para>
154 <variablelist>
155         <varlistentry><term>tdbsam</term>
156                 <listitem>
157                         <para>
158 <indexterm><primary>rich database backend</primary></indexterm>
159 <indexterm><primary>PDC</primary></indexterm>
160 <indexterm><primary>BDC</primary></indexterm>
161                         This backend provides a rich database backend for local servers. This
162                         backend is not suitable for multiple domain controllers (i.e., PDC + one
163                         or more BDC) installations.
164                         </para>
166                         <para>
167 <indexterm><primary>extended SAM</primary></indexterm>
168 <indexterm><primary>TDB</primary></indexterm>
169 <indexterm><primary>binary format TDB</primary></indexterm>
170 <indexterm><primary>trivial database</primary></indexterm>
171 <indexterm><primary>system access controls</primary></indexterm>
172 <indexterm><primary>MS Windows NT4/200x</primary></indexterm>
173                         The <emphasis>tdbsam</emphasis> password backend stores the old <emphasis>
174                         smbpasswd</emphasis> information plus the extended MS Windows NT/200x
175                         SAM information into a binary format TDB (trivial database) file.
176                         The inclusion of the extended information makes it possible for Samba-3
177                         to implement the same account and system access controls that are possible
178                         with MS Windows NT4/200x-based systems.
179                         </para>
181                         <para>
182 <indexterm><primary>simple operation</primary></indexterm>
183 <indexterm><primary>OpenLDAP</primary></indexterm>
184 <indexterm><primary>ADS</primary></indexterm>
185                         The inclusion of the <emphasis>tdbsam</emphasis> capability is a direct
186                         response to user requests to allow simple site operation without the overhead
187                         of the complexities of running OpenLDAP. It is recommended to use this only
188                         for sites that have fewer than 250 users. For larger sites or implementations,
189                         the use of OpenLDAP or of Active Directory integration is strongly recommended.
190                         </para>
191                 </listitem>
192         </varlistentry>
194         <varlistentry><term>ldapsam</term>
195                 <listitem>
196                         <para>
197 <indexterm><primary>rich directory backend</primary></indexterm>
198 <indexterm><primary>distributed account</primary></indexterm>
199                         This provides a rich directory backend for distributed account installation.    
200                         </para>
202                         <para>
203 <indexterm><primary>LDAP</primary></indexterm>
204 <indexterm><primary>OpenLDAP</primary></indexterm>
205 <indexterm><primary>Samba schema</primary></indexterm>
206 <indexterm><primary>schema file</primary></indexterm>
207 <indexterm><primary>examples/LDAP</primary></indexterm>
208                         Samba-3 has a new and extended LDAP implementation that requires configuration
209                         of OpenLDAP with a new format Samba schema. The new format schema file is
210                         included in the <filename class="directory">examples/LDAP</filename> directory of the Samba distribution.
211                         </para>
213                         <para>
214 <indexterm><primary>expands control abilities</primary></indexterm>
215 <indexterm><primary>profile</primary></indexterm>
216 <indexterm><primary>home directories</primary></indexterm>
217 <indexterm><primary>account access controls</primary></indexterm>
218 <indexterm><primary>greater scalability</primary></indexterm>
219                         The new LDAP implementation significantly expands the control abilities that
220                         were possible with prior versions of Samba. It is now possible to specify
221                         <quote>per-user</quote> profile settings, home directories, account access controls, and
222                         much more. Corporate sites will see that the Samba Team has listened to their
223                         requests both for capability and greater scalability.
224                         </para>
225                 </listitem>
226         </varlistentry>
228         <varlistentry><term>mysqlsam (MySQL-based backend)</term>
229                 <listitem>
230                         <para>
231 <indexterm><primary>MySQL-based SAM</primary></indexterm>
232 <indexterm><primary>database backend</primary></indexterm>
233                         It is expected that the MySQL-based SAM will be very popular in some corners.
234                         This database backend will be of considerable interest to sites that want to
235                         leverage existing MySQL technology.
236                         </para>
237                 </listitem>
238         </varlistentry>
240         <varlistentry><term>pgsqlsam (PostGreSQL-based backend)</term>
241                 <listitem>
242                         <para>
243 <indexterm><primary>PostgreSQL database</primary></indexterm>
244 <indexterm><primary>mysqlsam</primary></indexterm>
245                                 Stores user information in a PostgreSQL database.  This backend is largely undocumented at 
246                                 the moment, though its configuration is very similar to that of the mysqlsam backend.
247                         </para>
248                 </listitem>
249         </varlistentry>
251         <varlistentry><term>xmlsam (XML-based datafile)</term>
252                 <listitem>
253                         <para>
254 <indexterm><primary>pdbedit</primary></indexterm>
255 <indexterm><primary>XML format</primary></indexterm>
256 <indexterm><primary>pdb2pdb</primary></indexterm>
257                         Allows the account and password data to be stored in an XML format
258                         data file. This backend cannot be used for normal operation, it can only 
259                         be used in conjunction with <command>pdbedit</command>'s pdb2pdb 
260                         functionality. The Document Type Definition (DTD) file that is used 
261                         might be subject to changes in the future. (See the XML <ulink
262                         url="http://www.brics.dk/~amoeller/XML/schemas/">reference</ulink> for a definition
263                         of XML terms.)
264                         </para>
266                         <para>
267 <indexterm><primary>account migration</primary></indexterm>
268 <indexterm><primary>database backends</primary></indexterm>
269 <indexterm><primary>backend format</primary></indexterm>
270                         The <parameter>xmlsam</parameter> option can be useful for account migration between database
271                         backends or backups. Use of this tool allows the data to be edited before migration
272                         into another backend format.
273                         </para>
274                 </listitem>
275         </varlistentry>
277 </variablelist>
279 </sect2>
281 </sect1>
283 <sect1 id="passdbtech">
284         <title>Technical Information</title>
286         <para>
287 <indexterm><primary>plaintext passwords</primary></indexterm>
288 <indexterm><primary>encrypted passwords</primary></indexterm>
289         Old Windows clients send plaintext passwords over the wire. Samba can check these
290         passwords by encrypting them and comparing them to the hash stored in the UNIX user database.
291         </para>
293         <para>
294 <indexterm><primary>encrypted passwords</primary></indexterm>   
295 <indexterm><primary>LanMan</primary></indexterm>
296 <indexterm><primary>plaintext passwords</primary></indexterm>
297 <indexterm><primary>registry</primary></indexterm>
298         Newer Windows clients send encrypted passwords (LanMan and NT hashes) instead of plaintext passwords over
299         the wire. The newest clients will send only encrypted passwords and refuse to send plaintext passwords unless
300         their registry is tweaked.
301         </para>
303         <para>
304 <indexterm><primary>UNIX-style encrypted passwords</primary></indexterm>
305 <indexterm><primary>converted</primary></indexterm>
306         Many people ask why Samba can not simply use the UNIX password database. Windows requires
307         passwords that are encrypted in its own format.  The UNIX passwords can't be converted to 
308         UNIX-style encrypted passwords. Because of that, you can't use the standard UNIX user
309         database, and you have to store the LanMan and NT hashes somewhere else.
310         </para>
311         
312         <para>
313 <indexterm><primary>differently encrypted passwords</primary></indexterm>
314 <indexterm><primary>profile</primary></indexterm>
315 <indexterm><primary>workstations</primary></indexterm>
316 <indexterm><primary>tdbsam</primary></indexterm>
317         In addition to differently encrypted passwords, Windows also stores certain data for each
318         user that is not stored in a UNIX user database: for example, workstations the user may logon from,
319         the location where the user's profile is stored, and so on. Samba retrieves and stores this
320         information using a <smbconfoption name="passdb backend"/>. Commonly available backends are LDAP,
321         tdbsam, plain text file, and MySQL. For more information, see the man page for &smb.conf; regarding the 
322         <smbconfoption name="passdb backend"/> parameter.
323         </para>
326         <figure id="idmap-sid2uid">
327                 <title>IDMAP: Resolution of SIDs to UIDs.</title>
328                 <imagefile scale="40">idmap-sid2uid</imagefile>
329         </figure>
331         <para>
332         <indexterm><primary>SID</primary></indexterm>
333 <indexterm><primary>UID</primary></indexterm>
334 <indexterm><primary>SID</primary></indexterm>
335         The resolution of SIDs to UIDs is fundamental to correct operation of Samba. In both cases shown, if winbindd
336         is not running or cannot be contacted, then only local SID/UID resolution is possible. See <link
337         linkend="idmap-sid2uid">resolution of SIDs to UIDs</link> and <link linkend="idmap-uid2sid">resolution of UIDs
338         to SIDs</link> diagrams.
339         </para>
341         <figure id="idmap-uid2sid">
342                 <title>IDMAP: Resolution of UIDs to SIDs.</title>
343                 <imagefile scale="50">idmap-uid2sid</imagefile>
344         </figure>
346         <sect2>
347         <title>Important Notes About Security</title>
348                 
349                 <para>
350 <indexterm><primary>SMB password encryption</primary></indexterm>
351 <indexterm><primary>clear-text passwords</primary></indexterm>
352 <indexterm><primary>hashed password equivalent</primary></indexterm>
353 <indexterm><primary>LDAP</primary></indexterm>
354 <indexterm><primary>MYSQL</primary></indexterm>
355 <indexterm><primary>secret</primary></indexterm>
356                 The UNIX and SMB password encryption techniques seem similar on the surface. This
357                 similarity is, however, only skin deep. The UNIX scheme typically sends clear-text
358                 passwords over the network when logging in. This is bad. The SMB encryption scheme
359                 never sends the clear-text password over the network, but it does store the 16-byte 
360                 hashed values on disk. This is also bad. Why? Because the 16 byte hashed values
361                 are a <quote>password equivalent.</quote> You cannot derive the user's password from them, but
362                 they could potentially be used in a modified client to gain access to a server.
363                 This would require considerable technical knowledge on behalf of the attacker but
364                 is perfectly possible. You should therefore treat the data stored in whatever passdb
365                 backend you use (smbpasswd file, LDAP, MYSQL) as though it contained the clear-text
366                 passwords of all your users. Its contents must be kept secret, and the file should
367                 be protected accordingly.
368                 </para>
369                 
370                 <para>
371 <indexterm><primary>password scheme</primary></indexterm>
372 <indexterm><primary>plaintext passwords</primary></indexterm>
373 <indexterm><primary>compatible</primary></indexterm>
374                 Ideally, we would like a password scheme that involves neither plaintext passwords
375                 on the network nor plaintext passwords on disk. Unfortunately, this is not available because Samba is stuck with
376                 having to be compatible with other SMB systems (Windows NT, Windows for Workgroups, Windows 9x/Me).
377                 </para>
379                 <para>
380 <indexterm><primary>encrypted passwords</primary></indexterm>
381 <indexterm><primary>plaintext passwords</primary></indexterm>
382                 Windows NT 4.0 Service Pack 3 changed the default setting so plaintext passwords
383                 are disabled from being sent over the wire. This mandates either the use of encrypted
384                 password support or editing the Windows NT registry to re-enable plaintext passwords.
385                 </para>
386                 
387                 <para>
388 <indexterm><primary>domain security</primary></indexterm>
389 <indexterm><primary>domain environment</primary></indexterm>
390                 The following versions of Microsoft Windows do not support full domain security protocols,
391                 although they may log onto a domain environment:
392                 </para>
394                 <itemizedlist>
395                         <listitem><para>MS DOS Network client 3.0 with the basic network redirector installed.</para></listitem>
396                         <listitem><para>Windows 95 with the network redirector update installed.</para></listitem>
397                         <listitem><para>Windows 98 [Second Edition].</para></listitem>
398                         <listitem><para>Windows Me.</para></listitem>
399                 </itemizedlist>
401                 <note>
402                 <para>
403 <indexterm><primary>Windows XP Home</primary></indexterm>
404 <indexterm><primary>domain member</primary></indexterm>
405 <indexterm><primary>domain logons</primary></indexterm>
406                 MS Windows XP Home does not have facilities to become a domain member, and it cannot participate in domain logons.
407                 </para>
408                 </note>
410                 <para>
411                 The following versions of MS Windows fully support domain security protocols.
412                 </para>
414                 <itemizedlist>
415                         <listitem><para>Windows NT 3.5x.</para></listitem>
416                         <listitem><para>Windows NT 4.0.</para></listitem>
417                         <listitem><para>Windows 2000 Professional.</para></listitem>
418                         <listitem><para>Windows 200x Server/Advanced Server.</para></listitem>
419                         <listitem><para>Windows XP Professional.</para></listitem>
420                 </itemizedlist>
421                         
422                 <para>
423 <indexterm><primary>SMB/CIFS</primary></indexterm>
424 <indexterm><primary>authentication</primary></indexterm>
425 <indexterm><primary>challenge/response mechanis</primary></indexterm>
426 <indexterm><primary>clear-text</primary></indexterm>
427 <indexterm><primary>encrypted</primary></indexterm>
428 <indexterm><primary>negotiate</primary></indexterm>
429                 All current releases of Microsoft SMB/CIFS clients support authentication via the
430                 SMB challenge/response mechanism described here. Enabling clear-text authentication
431                 does not disable the ability of the client to participate in encrypted authentication.
432                 Instead, it allows the client to negotiate either plaintext or encrypted password
433                 handling.
434                 </para>
436                 <para>
437 <indexterm><primary>cached encrypted password</primary></indexterm>
438 <indexterm><primary>plaintext passwords</primary></indexterm>
439 <indexterm><primary>registry change</primary></indexterm>
440 <indexterm><primary>auto-reconnect</primary></indexterm>
441 <indexterm><primary>encrypted passwords</primary></indexterm>
442                 MS Windows clients will cache the encrypted password alone. Where plaintext passwords
443                 are re-enabled through the appropriate registry change, the plaintext password is never
444                 cached. This means that in the event that a network connections should become disconnected
445                 (broken), only the cached (encrypted) password will be sent to the resource server to
446                 effect an auto-reconnect. If the resource server does not support encrypted passwords, the
447                 auto-reconnect will fail. Use of encrypted passwords is strongly advised.
448                 </para>
450                 <sect3>
451                 <title>Advantages of Encrypted Passwords</title>
453                         <itemizedlist>
454                                 <listitem><para>
455 <indexterm><primary>passed across the network</primary></indexterm>
456 <indexterm><primary>network sniffer</primary></indexterm>
457 <indexterm><primary>SMB server</primary></indexterm>
458                                 Plaintext passwords are not passed across the network. Someone using a network sniffer
459                                 cannot just record passwords going to the SMB server.
460                                 </para></listitem>
462                                 <listitem><para>
463 <indexterm><primary>not stored anywhere</primary></indexterm>
464 <indexterm><primary>memory</primary></indexterm>
465 <indexterm><primary>disk</primary></indexterm>
466                                 Plaintext passwords are not stored anywhere in memory or on disk.
467                                 </para></listitem>
468                          
469                                 <listitem><para>
470 <indexterm><primary>encrypted passwords</primary></indexterm>
471 <indexterm><primary>user-level security</primary></indexterm>
472 <indexterm><primary>password prompt</primary></indexterm>
473 <indexterm><primary>SMB encryption</primary></indexterm>
474                                 Windows NT does not like talking to a server that does not support encrypted passwords. It will refuse to
475                                 browse the server if the server is also in user-level security mode. It will insist on prompting the user for
476                                 the password on each connection, which is very annoying. The only thing you can do to stop this is to use SMB
477                                 encryption.
478                                 </para></listitem>
480                                 <listitem><para>
481 <indexterm><primary>encrypted password</primary></indexterm>
482 <indexterm><primary>automatic reconnects</primary></indexterm>
483                                 Encrypted password support allows automatic share (resource) reconnects.
484                                 </para></listitem>
486                                 <listitem><para>
487 <indexterm><primary>PDC</primary></indexterm>
488 <indexterm><primary>BDC</primary></indexterm>
489                                 Encrypted passwords are essential for PDC/BDC operation.
490                                 </para></listitem>
491                         </itemizedlist>
492                 </sect3>
495                 <sect3>
496                 <title>Advantages of Non-Encrypted Passwords</title>
498                         <itemizedlist>
499                                 <listitem><para>
500 <indexterm><primary>cached in memory</primary></indexterm>
501                                 Plaintext passwords are not kept on disk and are not cached in memory.
502                                 </para></listitem>
503                                 
504                                 <listitem><para>
505 <indexterm><primary>Login</primary></indexterm>
506 <indexterm><primary>FTP</primary></indexterm>
507                                 Plaintext passwords use the same password file as other UNIX services, such as Login and FTP.
508                                 </para></listitem>
509                                 
510                                 <listitem><para>
511 <indexterm><primary>Telnet</primary></indexterm>
512 <indexterm><primary>FTP</primary></indexterm>
513                                 Use of other services (such as Telnet and FTP) that send plaintext passwords over
514                                 the network makes sending them for SMB is not such a big deal.
515                                 </para></listitem>
516                         </itemizedlist>
517                 </sect3>
518         </sect2>
520         <sect2>
521         <title>Mapping User Identifiers between MS Windows and UNIX</title>
523         <para>
524 <indexterm><primary>UID</primary></indexterm>
525 <indexterm><primary>SID</primary></indexterm>
526 <indexterm><primary>mapping</primary></indexterm>
527         Every operation in UNIX/Linux requires a user identifier (UID), just as in
528         MS Windows NT4/200x this requires a security identifier (SID). Samba provides
529         two means for mapping an MS Windows user to a UNIX/Linux UID.
530         </para>
532         <para>
533 <indexterm><primary>Samba SAM</primary></indexterm>
534 <indexterm><primary>SAM</primary></indexterm>
535 <indexterm><primary>UID</primary></indexterm>
536 <indexterm><primary>account information database</primary></indexterm>
537 <indexterm><primary>local user account</primary></indexterm>
538         First, all Samba SAM database accounts require a UNIX/Linux UID that the account will map to. As users are
539         added to the account information database, Samba will call the <smbconfoption name="add user script"/>
540         interface to add the account to the Samba host OS. In essence all accounts in the local SAM require a local
541         user account.
542         </para>
544         <para>
545         <indexterm><primary>idmap uid</primary></indexterm>
546         <indexterm><primary>idmap gid</primary></indexterm>
547         <indexterm><primary>UID</primary></indexterm>
548         <indexterm><primary>SAM</primary></indexterm>
549         <indexterm><primary>foreign domain</primary></indexterm>
550         <indexterm><primary>non-member Windows client</primary></indexterm>
551         <indexterm><primary>SID</primary></indexterm>
552         The second way to map Windows SID to UNIX UID is via the <emphasis>idmap uid</emphasis> and
553         <emphasis>idmap gid</emphasis> parameters in &smb.conf;.  Please refer to the man page for information about
554         these parameters.  These parameters are essential when mapping users from a remote (non-member Windows client
555         or a member of a foreign domain) SAM server.
556         </para>
558         </sect2>
560         <sect2 id="idmapbackend">
561         <title>Mapping Common UIDs/GIDs on Distributed Machines</title>
563         <para>
564 <indexterm><primary>UID</primary></indexterm>
565 <indexterm><primary>GID</primary></indexterm>
566 <indexterm><primary>BDC</primary></indexterm>
567 <indexterm><primary>domain member servers</primary></indexterm>
568 <indexterm><primary>NFS</primary></indexterm>
569 <indexterm><primary>rsync</primary></indexterm>
570         Samba-3 has a special facility that makes it possible to maintain identical UIDs and GIDs
571         on all servers in a distributed network. A distributed network is one where there exists
572         a PDC, one or more BDCs, and/or one or more domain member servers. Why is this important?
573         This is important if files are being shared over more than one protocol (e.g., NFS) and where
574         users are copying files across UNIX/Linux systems using tools such as <command>rsync</command>.
575         </para>
577         <para>
578 <indexterm><primary>LDAP-based</primary></indexterm>
579 <indexterm><primary>idmap backend</primary></indexterm>
580 <indexterm><primary>UID</primary></indexterm>
581 <indexterm><primary>GID</primary></indexterm>
582 <indexterm><primary>LDAP</primary></indexterm>
583 <indexterm><primary>SAM backend</primary></indexterm>
584 <indexterm><primary>LDAP idmap Backend</primary></indexterm>
585         <indexterm><primary>idmap backend</primary></indexterm>
586         The special facility is enabled using a parameter called <parameter>idmap backend</parameter>.
587         The default setting for this parameter is an empty string. Technically it is possible to use
588         an LDAP-based idmap backend for UIDs and GIDs, but it makes most sense when this is done for
589         network configurations that also use LDAP for the SAM backend.
590         <link linkend="idmapbackendexample">Example Configuration with the LDAP idmap Backend</link>
591         shows that configuration.
592         </para>
594 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
595 <example id="idmapbackendexample">
596 <title>Example Configuration with the LDAP idmap Backend</title>
597 <smbconfblock>
598 <smbconfsection name="[global]"/>
599 <smbconfoption name="idmap backend">ldap:ldap://ldap-server.quenya.org:636</smbconfoption>
600 <smbconfcomment>Alternatively, this could be specified as:</smbconfcomment>
601 <smbconfoption name="idmap backend">ldap:ldaps://ldap-server.quenya.org</smbconfoption>
602 </smbconfblock>
603 </example>
605         <para>
606         A network administrator who wants to make significant use of LDAP backends will sooner or later be
607         exposed to the excellent work done by PADL Software. PADL <ulink url="http://www.padl.com"/> have
608         produced and released to open source an array of tools that might be of interest. These tools include:
609         </para>
611         <itemizedlist>
612                 <listitem>
613                 <para>
614                 <emphasis>nss_ldap:</emphasis> An LDAP name service switch (NSS) module to provide native
615                 name service support for AIX, Linux, Solaris, and other operating systems. This tool
616                 can be used for centralized storage and retrieval of UIDs and GIDs.
617                 </para>
618                 </listitem>
620                 <listitem>
621                 <para>
622                 <emphasis>pam_ldap:</emphasis> A PAM module that provides LDAP integration for UNIX/Linux
623                 system access authentication.
624                 </para>
625                 </listitem>
626                 <listitem>
627                 <para>
628                 <emphasis>idmap_ad:</emphasis> An IDMAP backend that supports the Microsoft Services for
629                 UNIX RFC 2307 schema available from the PADL Web 
630                 <ulink url="http://www.padl.com/download/xad_oss_plugins.tar.gz">site</ulink>.
631                 </para>
632                 </listitem>
633         </itemizedlist>
635         </sect2>
637         <sect2>
638         <title>Comments Regarding LDAP</title>
640         <para>
641         There is much excitement and interest in LDAP directories in the information technology world
642         today. The LDAP architecture was designed to be highly scalable. It was also designed for
643         use across a huge number of potential areas of application encompasing a wide range of operating
644         systems and platforms. LDAP technologies are at the heart of the current generations of Federated
645         Identity Management (FIM) solutions that can underlie a corporate Single Sign-On (SSO) environment.
646         </para>
648         <para>
649         LDAP implementations have been built across a wide variety of platforms. It lies at the core of Microsoft
650         Windows Active Directory services, Novell's e-Directory, as well as many others. Implementation of the
651         directory services LDAP involves interaction with legacy as well as new generation applications, all of which
652         depend on some form of authentication services.
653         </para>
655         <para>
656         UNIX services can utilize LDAP directory information for authentication and access controls
657         through intermediate tools and utilities. The total environment that consists of the LDAP directory
658         and the middle-ware tools and utilities makes it possible for all user access to the UNIX platform
659         to be managed from a central environment and yet distributed to wherever the point of need may
660         be physically located. Applications that benefit from this infrastructure include: UNIX login 
661         shells, mail and messaging systems, quota controls, printing systems, DNS servers, DHCP servers,
662         and also Samba.
663         </para>
665         <para>
666         Many sites are installing LDAP for the first time in order to provide a scalable passdb backend
667         for Samba. Others are faced with the need to adapt an existing LDAP directory to new uses such
668         as for the Samba SAM backend. Whatever your particular need and attraction to Samba may be,
669         decisions made in respect of the design of the LDAP directory structure and its implementation
670         are of a durable nature for the site. These have far-reaching implications that affect long term
671         information systems management costs.
672         </para>
674         <para>
675         Do not rush into an LDAP deployment. Take the time to understand how the design of the Directory
676         Information Tree (DIT) may impact current and future site needs, as well as the ability to meet
677         them. The way that Samba SAM information should be stored within the DIT varies from site to site
678         and with each implementation new experience is gained. It is well understood by LDAP veterans that
679         first implementation create awakening, second implementations of LDAP create fear, and 
680         third-generation deployments bring peace and tranquility.
681         </para>
683         <sect3>
684         <title>Caution Regarding LDAP and Samba</title>
686         <para>
687         Samba requires UNIX POSIX identity information as well as a place to store information that is
688         specific to Samba and the Windows networking environment. The most used information that must
689         be dealt with includes: user accounts, group accounts, machine trust accounts, interdomain
690         trust accounts, and intermediate information specific to Samba internals.
691         </para>
693         <para>
694         The example deployment guidelines in this book, as well as other books and HOWTO documents
695         available from the internet may not fit with established directory designs and implementations.
696         The existing DIT may not be able to accomodate the simple information layout proposed in common
697         sources. Additionally, you may find that the common scripts and tools that are used to provision
698         the LDAP directory for use with Samba may not suit your needs.
699         </para>
701         <para>
702         It is not uncommon, for sites that have existing LDAP DITs to find necessity to generate a
703         set of site specific scripts and utilities to make it possible to deploy Samba within the
704         scope of site operations. The way that user and group accounts are distributed throughout
705         the DIT may make this a challenging matter. The solution will of course be rewarding, but
706         the journey to it may be challenging. Take time to understand site needs and do not rush
707         into deployment.
708         </para>
710         <para>
711         Above all, do not blindly use scripts and tools that are not suitable for your site. Check
712         and validate all scripts before you execute them to make sure that the existing infrastructure
713         will not be damaged by inadvertent use of an inappropriate tool.
714         </para>
716         </sect3>
718         </sect2>
720         <sect2>
721         <title>LDAP Directories and Windows Computer Accounts</title>
723                 <para>
724                 Samba doesn't provide a turnkey solution to LDAP. It is best to deal with the design and
725                 configuration of an LDAP directory prior to integration with Samba. A working knowledge
726                 of LDAP makes Samba integration easy, and the lack of a working knowledge of LDAP can make
727                 it a frustrating experience.
728                 </para>
730                 <para>
731                 Computer (machine) accounts can be placed wherever you like in an LDAP directory subject
732                 to some constraints that are described in this chapter.
733                 </para>
735                 <para>
736                 The POSIX and sambaSamAccount components of computer (machine) accounts are both used by Samba.
737                 Thus, machine accounts are treated inside Samba in the same way that Windows NT4/200X treats
738                 them. A user account and a machine account are indistinquishable from each other, except that
739                 the machine account ends in a $ character, as do trust accounts.
740                 </para>
742                 <para>
743                 The need for Windows user, group, machine, trust, and other accounts to be tied to a valid UNIX
744                 UID is a design decision that was made a long way back in the history of Samba development. It
745                 is unlikely that this decision will be reversed or changed during the remaining life of the
746                 Samba-3.x series.
747                 </para>
749                 <para>
750                 The resolution of a UID from the Windows SID is achieved within Samba through a mechanism that
751                 must refer back to the host operating system on which Samba is running. The NSS is the preferred
752                 mechanism that shields applications (like Samba) from the need to know everything about every
753                 host OS it runs on.
754                 </para>
756                 <para>
757                 Samba asks the host OS to provide a UID via the <quote>passwd</quote>, <quote>shadow</quote>,
758                 and <quote>group</quote> facilities in the NSS control (configuration) file. The best tool
759                 for achieving this is left up to the UNIX administrator to determine. It is not imposed by
760                 Samba. Samba provides winbindd with its support libraries as one method. It is
761                 possible to do this via LDAP, and for that Samba provides the appropriate hooks so that
762                 all account entities can be located in an LDAP directory.
763                 </para>
765                 <para>
766                 For many the weapon of choice is to use the PADL nss_ldap utility. This utility must
767                 be configured so that computer accounts can be resolved to a POSIX/UNIX account UID. That
768                 is fundamentally an LDAP design question.  The information provided on the Samba list and
769                 in the documentation is directed at providing working examples only. The design
770                 of an LDAP directory is a complex subject that is beyond the scope of this documentation.
771                 </para>
773         </sect2>
775 </sect1>
777 <sect1 id="acctmgmttools">
778 <title>Account Management Tools</title>
780 <para>
781 <indexterm><primary>pdbedit</primary></indexterm>
782 Samba provides two tools for management of user and machine accounts:
783 <command>smbpasswd</command> and <command>pdbedit</command>. 
784 </para>
786 <para>
787 Some people are confused when reference is made to <literal>smbpasswd</literal> because the
788 name refers to a storage mechanism for SambaSAMAccount information, but it is also the name
789 of a utility tool. That tool is destined to eventually be replaced by new functionality that
790 is being added to the <command>net</command> toolset.
791 </para>
793         <sect2>
794         <title>The <command>smbpasswd</command> Command</title>
795         
796                 <para>
797                 The <command>smbpasswd</command> utility is similar to the <command>passwd</command>
798                 and <command>yppasswd</command> programs. It maintains the two 32 byte password
799                 fields in the passdb backend. This utility operates independantly of the actual
800                 account and password storage methods used (as specified by the <parameter>passdb
801                 backend</parameter> in the &smb.conf; file.
802                 </para>
804                 <para>
805                 <command>smbpasswd</command> works in a client-server mode where it contacts the
806                 local smbd to change the user's password on its behalf. This has enormous benefits.
807                 </para>
809                 <para>
810                 <command>smbpasswd</command> has the capability to change passwords on Windows NT
811                 servers (this only works when the request is sent to the NT PDC if changing an NT
812                 domain user's password).
813                 </para>
815                 <para>
816                 <indexterm><primary>user management</primary></indexterm>
817                 <indexterm><primary>user account</primary><secondary>Adding/Deleting</secondary></indexterm>
818                 <command>smbpasswd</command> can be used to:
819                 </para>
821                 <itemizedlist>
822                         <listitem><para><emphasis>add</emphasis> user or machine accounts.</para></listitem>
823                         <listitem><para><emphasis>delete</emphasis> user or machine accounts.</para></listitem>
824                         <listitem><para><emphasis>enable</emphasis> user or machine accounts.</para></listitem>
825                         <listitem><para><emphasis>disable</emphasis> user or machine accounts.</para></listitem>
826                         <listitem><para><emphasis>set to NULL</emphasis> user passwords.</para></listitem>
827                         <listitem><para><emphasis>manage</emphasis> interdomain trust accounts.</para></listitem>
828                 </itemizedlist>
829                 
830                 <para>
831                 To run smbpasswd as a normal user, just type:
832                 </para>
833                 
834                 <para>
835 <screen>
836 &prompt;<userinput>smbpasswd</userinput>
837 <prompt>Old SMB password: </prompt><userinput><replaceable>secret</replaceable></userinput>
838 </screen>
839                 For <replaceable>secret</replaceable>, type the old value here or press return if
840                 there is no old password.
841 <screen>
842 <prompt>New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
843 <prompt>Repeat New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
844 </screen>
845                 </para>
846                 
847                 <para>
848                 If the old value does not match the current value stored for that user, or the two
849                 new values do not match each other, then the password will not be changed.
850                 </para>
851                 
852                 <para>
853                 When invoked by an ordinary user, the command will allow only the user to change his or her own
854                 SMB password.
855                 </para>
856                 
857                 <para>
858                 When run by root, <command>smbpasswd</command> may take an optional argument specifying
859                 the username whose SMB password you wish to change. When run as root, <command>smbpasswd</command>
860                 does not prompt for or check the old password value, thus allowing root to set passwords 
861                 for users who have forgotten their passwords.
862                 </para>
863                 
864                 <para>
865                 <command>smbpasswd</command> is designed to work in the way familiar to UNIX
866                 users who use the <command>passwd</command> or <command>yppasswd</command> commands.
867                 While designed for administrative use, this tool provides essential user-level
868                 password change capabilities.
869                 </para>
871                 <para>
872                 For more details on using <command>smbpasswd</command>, refer to the man page (the
873                 definitive reference).
874                 </para>
875         </sect2>
877         <sect2 id="pdbeditthing">
878         <title>The <command>pdbedit</command> Command</title>
880                 <para>
881                 <indexterm><primary>pdbedit</primary></indexterm>
882                 <indexterm><primary>User Management</primary></indexterm>
883                 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
884                 <command>pdbedit</command> is a tool that can be used only by root. It is used to
885                 manage the passdb backend. <command>pdbedit</command> can be used to:
886                 </para>
888                 <itemizedlist>
889                         <listitem><para>add, remove, or modify user accounts.</para></listitem>
890                         <listitem><para>list user accounts.</para></listitem>
891                         <listitem><para>migrate user accounts.</para></listitem>
892                 </itemizedlist>
894                 <para>
895                 <indexterm><primary>pdbedit</primary></indexterm>
896                 The <command>pdbedit</command> tool is the only one that can manage the account
897                 security and policy settings. It is capable of all operations that smbpasswd can
898                 do as well as a superset of them.
899                 </para>
901                 <para>
902                 <indexterm><primary>pdbedit</primary></indexterm>
903                 One particularly important purpose of the <command>pdbedit</command> is to allow
904                 the migration of account information from one passdb backend to another. See the
905                 <link linkend="XMLpassdb">XML</link> password backend section of this chapter.
906                 </para>
908                 <para>
909                 The following is an example of the user account information that is stored in
910                 a tdbsam password backend. This listing was produced by running:
911                 </para>
913 <screen>
914 &prompt;<userinput>pdbedit -Lv met</userinput>
915 UNIX username:        met
916 NT username:
917 Account Flags:        [UX         ]
918 User SID:             S-1-5-21-1449123459-1407424037-3116680435-2004
919 Primary Group SID:    S-1-5-21-1449123459-1407424037-3116680435-1201
920 Full Name:            Melissa E Terpstra
921 Home Directory:       \\frodo\met\Win9Profile
922 HomeDir Drive:        H:
923 Logon Script:         scripts\logon.bat
924 Profile Path:         \\frodo\Profiles\met
925 Domain:               &example.workgroup;
926 Account desc:
927 Workstations:         melbelle
928 Munged dial:
929 Logon time:           0
930 Logoff time:          Mon, 18 Jan 2038 20:14:07 GMT
931 Kickoff time:         Mon, 18 Jan 2038 20:14:07 GMT
932 Password last set:    Sat, 14 Dec 2002 14:37:03 GMT
933 Password can change:  Sat, 14 Dec 2002 14:37:03 GMT
934 Password must change: Mon, 18 Jan 2038 20:14:07 GMT
935 </screen>
937                 <para>
938                 <indexterm><primary>pdbedit</primary></indexterm>
939                 The <command>pdbedit</command> tool allows migration of authentication (account)
940                 databases from one backend to another. For example, to migrate accounts from an
941                 old <filename>smbpasswd</filename> database to a <parameter>tdbsam</parameter>
942                 backend:
943                 </para>
945                 <procedure>
946                         <step><para>
947                         Set the <smbconfoption name="passdb backend">tdbsam, smbpasswd</smbconfoption>.
948                         </para></step>
950                         <step><para>
951                         Execute:
952 <screen>
953 &rootprompt;<userinput>pdbedit -i smbpasswd -e tdbsam</userinput>
954 </screen>
955                         </para></step>
957                         <step><para>
958                         Remove the <parameter>smbpasswd</parameter> from the passdb backend
959                         configuration in &smb.conf;.
960                         </para></step>
961                 </procedure>
963         </sect2>
964 </sect1>
966 <sect1>
967 <title>Password Backends</title>
969 <para>
970 Samba offers the greatest flexibility in backend account database design of any SMB/CIFS server
971 technology available today. The flexibility is immediately obvious as one begins to explore this
972 capability.
973 </para>
975 <para>
976 It is possible to specify not only multiple password backends, but even multiple
977 backends of the same type. For example, to use two different <literal>tdbsam</literal> databases:
979 <smbconfblock>
980 <smbconfoption name="passdb backend">tdbsam:/etc/samba/passdb.tdb tdbsam:/etc/samba/old-passdb.tdb</smbconfoption>
981 </smbconfblock>
983 What is possible, is not always sensible. Be careful to avoid complexity to the point that it
984 may be said that the solution is <quote>too clever by half!</quote>
985 </para>
988         <sect2>
989         <title>Plaintext</title>
991                 <para>
992                 Older versions of Samba retrieved user information from the UNIX user database 
993                 and eventually some other fields from the file <filename>/etc/samba/smbpasswd</filename>
994                 or <filename>/etc/smbpasswd</filename>. When password encryption is disabled, no 
995                 SMB-specific data is stored at all. Instead, all operations are conducted via the way
996                 that the Samba host OS will access its <filename>/etc/passwd</filename> database.
997                 On most Linux systems, for example, all user and group resolution is done via PAM.
998                 </para>
1000         </sect2>
1002         <sect2>
1003         <title>smbpasswd: Encrypted Password Database</title>
1005                 <para>
1006                 <indexterm><primary>SAM backend</primary><secondary>smbpasswd</secondary></indexterm>
1007                 Traditionally, when configuring <smbconfoption name="encrypt passwords">yes</smbconfoption>
1008                 in Samba's &smb.conf; file, user account information such as username, LM/NT password hashes,
1009                 password change times, and account flags have been stored in the <filename>smbpasswd(5)</filename>
1010                 file. There are several disadvantages to this approach for sites with large numbers of users
1011                 (counted in the thousands).
1012                 </para>
1014                 <itemizedlist>
1015                 <listitem><para>
1016                 The first problem is that all lookups must be performed sequentially. Given that
1017                 there are approximately two lookups per domain logon (one during intial logon validation
1018                 and one for a session connection setup, such as when mapping a network drive or printer), this
1019                 is a performance bottleneck for large sites. What is needed is an indexed approach
1020                 such as used in databases.
1021                 </para></listitem>
1023                 <listitem><para>
1024                 The second problem is that administrators who desire to replicate an smbpasswd file
1025                 to more than one Samba server are left to use external tools such as
1026                 <command>rsync(1)</command> and <command>ssh(1)</command> and write custom,
1027                 in-house scripts.
1028                 </para></listitem>
1030                 <listitem><para>
1031                 Finally, the amount of information that is stored in an smbpasswd entry leaves
1032                 no room for additional attributes such as a home directory, password expiration time,
1033                 or even a relative identifier (RID).
1034                 </para></listitem>
1035                 </itemizedlist>
1037                 <para>
1038                 As a result of these deficiencies, a more robust means of storing user attributes
1039                 used by smbd was developed. The API that defines access to user accounts
1040                 is commonly referred to as the samdb interface (previously, this was called the passdb
1041                 API and is still so named in the Samba CVS trees). 
1042                 </para>
1044                 <para>
1045                 Samba provides an enhanced set of passdb backends that overcome the deficiencies
1046                 of the smbpasswd plaintext database. These are tdbsam, ldapsam, and xmlsam.
1047                 Of these, ldapsam will be of most interest to large corporate or enterprise sites.
1048                 </para>
1050         </sect2>
1052         <sect2>
1053         <title>tdbsam</title>
1055                 <para>
1056                 <indexterm><primary>SAM backend</primary><secondary>tdbsam</secondary></indexterm>
1057                 Samba can store user and machine account data in a <quote>TDB</quote> (trivial database).
1058                 Using this backend does not require any additional configuration. This backend is
1059                 recommended for new installations that do not require LDAP.
1060                 </para>
1062                 <para>
1063                 As a general guide, the Samba Team does not recommend using the tdbsam backend for sites
1064                 that have 250 or more users. Additionally, tdbsam is not capable of scaling for use
1065                 in sites that require PDB/BDC implementations that require replication of the account
1066                 database. Clearly, for reason of scalability, the use of ldapsam should be encouraged.
1067                 </para>
1069                 <para>
1070                 The recommendation of a 250-user limit is purely based on the notion that this
1071                 would generally involve a site that has routed networks, possibly spread across
1072                 more than one physical location. The Samba Team has not at this time established
1073                 the performance-based scalability limits of the tdbsam architecture.
1074                 </para>
1076                 <para>
1077                 There are sites that have thousands of users and yet require only one server.
1078                 One site recently reported having 4,500 user accounts on one UNIX system and
1079                 reported excellent performance with the <literal>tdbsam</literal> passdb backend.
1080                 The limitation of where the <literal>tdbsam</literal> passdb backend can be used
1081                 is not one pertaining to a limitation in the TDB storage system, it is based
1082                 only on the need for a reliable distribution mechanism for the SambaSAMAccount
1083                 backend.
1084                 </para>
1086         </sect2>
1088         <sect2>
1089         <title>ldapsam</title>
1091                 <para>
1092                 <indexterm><primary>SAM backend</primary><secondary>ldapsam</secondary></indexterm>
1093                 There are a few points to stress that the ldapsam does not provide. The LDAP
1094                 support referred to in this documentation does not include:
1095                 </para>
1097                 <itemizedlist>
1098                         <listitem><para>A means of retrieving user account information from
1099                         a Windows 200x Active Directory server.</para></listitem>
1100                         <listitem><para>A means of replacing /etc/passwd.</para></listitem>
1101                 </itemizedlist>
1103                 <para>
1104                 The second item can be accomplished by using LDAP NSS and PAM modules. LGPL versions of these libraries can be
1105                 obtained from <ulink url="http://www.padl.com/">PADL Software</ulink>.  More information about the
1106                 configuration of these packages may be found in <ulink url="http://safari.oreilly.com/?XmlId=1-56592-491-6">
1107                 <emphasis>LDAP, System Administration</emphasis> by Gerald Carter, Chapter 6, Replacing NIS"</ulink>.
1108                 </para>
1110                 <para>
1111                 This document describes how to use an LDAP directory for storing Samba user
1112                 account information traditionally stored in the smbpasswd(5) file. It is
1113                 assumed that the reader already has a basic understanding of LDAP concepts
1114                 and has a working directory server already installed. For more information
1115                 on LDAP architectures and directories, please refer to the following sites:
1116                 </para>
1118                 <itemizedlist>
1119                         <listitem><para><ulink url="http://www.openldap.org/">OpenLDAP</ulink></para></listitem>
1120                         <listitem><para><ulink url="http://www.sun.com/software/products/directory_srvr_ee/index.xml">
1121                                 Sun One Directory Server</ulink></para></listitem>
1122                         <listitem><para><ulink url="http://www.novell.com/products/edirectory/"></ulink>Novell eDirectory</para></listitem>
1123                         <listitem><para><ulink url="http://www-306.ibm.com/software/tivoli/products/directory-server/">IBM
1124                                 Tivoli Directory Server</ulink></para></listitem>
1125                         <listitem><para><ulink url="http://www.redhat.com/software/rha/directory/">Red Hat Directory
1126                                 Server</ulink></para></listitem>
1127                         <listitem><para><ulink url="http://www.linuxsecurity.com/content/view/119229">Fedora Directory
1128                                 Server</ulink></para></listitem>
1129                 </itemizedlist>
1131                 <para>
1132                 Two additional Samba resources that may prove to be helpful are:
1133                 </para>
1135                 <itemizedlist>
1136                         <listitem><para>The <ulink url="http://www.unav.es/cti/ldap-smb/ldap-smb-3-howto.html">Samba-PDC-LDAP-HOWTO</ulink>
1137                         maintained by Ignacio Coupeau.</para></listitem>
1139                         <listitem><para>The NT migration scripts from <ulink url="http://samba.idealx.org/">IDEALX</ulink> that are
1140                         geared to manage users and groups in such a Samba-LDAP domain controller configuration.
1141                         </para></listitem>
1142                 </itemizedlist>
1144                 <sect3>
1145                 <title>Supported LDAP Servers</title>
1147                         <para>
1148                         The LDAP ldapsam code was developed and tested using the OpenLDAP 2.x server and
1149                         client libraries. The same code should work with Netscape's Directory Server and client SDK.
1150                         However, there are bound to be compile errors and bugs. These should not be hard to fix.
1151                         Please submit fixes via the process outlined in <link linkend="bugreport">Reporting Bugs</link>.
1152                         </para>
1154                         <para>
1155                         Samba is capable of working with any standards compliant LDAP server.
1156                         </para>
1158                 </sect3>
1160                 <sect3>
1161                 <title>Schema and Relationship to the RFC 2307 posixAccount</title>
1164                         <para>
1165                         Samba-3.0 includes the necessary schema file for OpenLDAP 2.x in
1166                         <filename>examples/LDAP/samba.schema</filename> directory of the source code distribution
1167                         tarball. The schema entry for the sambaSamAccount ObjectClass is shown here:
1168 <programlisting>
1169 ObjectClass (1.3.6.1.4.1.7165.2.2.6 NAME 'sambaSamAccount' SUP top AUXILIARY
1170     DESC 'Samba-3.0 Auxiliary SAM Account'
1171     MUST ( uid $ sambaSID )
1172     MAY  ( cn $ sambaLMPassword $ sambaNTPassword $ sambaPwdLastSet $
1173           sambaLogonTime $ sambaLogoffTime $ sambaKickoffTime $
1174           sambaPwdCanChange $ sambaPwdMustChange $ sambaAcctFlags $
1175           displayName $ sambaHomePath $ sambaHomeDrive $ sambaLogonScript $
1176           sambaProfilePath $ description $ sambaUserWorkstations $
1177           sambaPrimaryGroupSID $ sambaDomainName ))
1178 </programlisting>
1179                         </para>
1181                         <para>
1182                         The <filename>samba.schema</filename> file has been formatted for OpenLDAP 2.0/2.1.
1183                         The Samba Team owns the OID space used by the above schema and recommends its use.
1184                         If you translate the schema to be used with Netscape DS, please submit the modified
1185                         schema file as a patch to <ulink url="mailto:jerry@samba.org">jerry@samba.org</ulink>.
1186                         </para>
1188                         <para>
1189                         Just as the smbpasswd file is meant to store information that provides information
1190                         additional to  a user's <filename>/etc/passwd</filename> entry, so is the sambaSamAccount
1191                         object meant to supplement the UNIX user account information. A sambaSamAccount is an
1192                         <constant>AUXILIARY</constant> ObjectClass, so it can be used to augment existing
1193                         user account information in the LDAP directory, thus providing information needed
1194                         for Samba account handling. However, there are several fields (e.g., uid) that overlap
1195                         with the posixAccount ObjectClass outlined in RFC2307. This is by design.
1196                         </para>
1198                         <!--olem: we should perhaps have a note about shadowAccounts too as many
1199                         systems use them, isn'it ? -->
1201                         <para>
1202                         In order to store all user account information (UNIX and Samba) in the directory,
1203                         it is necessary to use the sambaSamAccount and posixAccount ObjectClasses in
1204                         combination. However, <command>smbd</command> will still obtain the user's UNIX account
1205                         information via the standard C library calls, such as getpwnam().
1206                         This means that the Samba server must also have the LDAP NSS library installed
1207                         and functioning correctly. This division of information makes it possible to
1208                         store all Samba account information in LDAP, but still maintain UNIX account
1209                         information in NIS while the network is transitioning to a full LDAP infrastructure.
1210                         </para>
1211                 </sect3>
1213                 <sect3>
1214                 <title>OpenLDAP Configuration</title>
1216                 <para>
1217                 To include support for the sambaSamAccount object in an OpenLDAP directory
1218                 server, first copy the samba.schema file to slapd's configuration directory.
1219                 The samba.schema file can be found in the directory <filename>examples/LDAP</filename>
1220                 in the Samba source distribution.
1221 <screen>
1222 &rootprompt;<userinput>cp samba.schema /etc/openldap/schema/</userinput>
1223 </screen>
1224                 </para>
1226                 <para>
1227                 Next, include the <filename>samba.schema</filename> file in <filename>slapd.conf</filename>.
1228                 The sambaSamAccount object contains two attributes that depend on other schema
1229                 files. The <parameter>uid</parameter> attribute is defined in <filename>cosine.schema</filename> and
1230                 the <parameter>displayName</parameter> attribute is defined in the <filename>inetorgperson.schema</filename>
1231                 file. Both of these must be included before the <filename>samba.schema</filename> file.
1232 <programlisting>
1233 ## /etc/openldap/slapd.conf
1235 ## schema files (core.schema is required by default)
1236 include            /etc/openldap/schema/core.schema
1238 ## needed for sambaSamAccount
1239 include            /etc/openldap/schema/cosine.schema
1240 include            /etc/openldap/schema/inetorgperson.schema
1241 include            /etc/openldap/schema/nis.schema
1242 include            /etc/openldap/schema/samba.schema
1243 ....
1244 </programlisting>
1245                 </para>
1247                 <para>
1248                 It is recommended that you maintain some indices on some of the most useful attributes,
1249                 as in the following example, to speed up searches made on sambaSamAccount ObjectClasses
1250                 (and possibly posixAccount and posixGroup as well):
1251                 </para>
1253 <para>
1254 <programlisting>
1255 # Indices to maintain
1256 ## required by OpenLDAP
1257 index objectclass             eq
1259 index cn                      pres,sub,eq
1260 index sn                      pres,sub,eq
1261 ## required to support pdb_getsampwnam
1262 index uid                     pres,sub,eq
1263 ## required to support pdb_getsambapwrid()
1264 index displayName             pres,sub,eq
1266 ## uncomment these if you are storing posixAccount and
1267 ## posixGroup entries in the directory as well
1268 ##index uidNumber               eq
1269 ##index gidNumber               eq
1270 ##index memberUid               eq
1272 index   sambaSID              eq
1273 index   sambaPrimaryGroupSID  eq
1274 index   sambaDomainName       eq
1275 index   default               sub
1276 </programlisting>
1277 </para>
1279                 <para>
1280                 Create the new index by executing:
1281 <screen>
1282 &rootprompt;./sbin/slapindex -f slapd.conf
1283 </screen>
1284                 </para>
1286                 <para>
1287                 Remember to restart slapd after making these changes:
1288 <screen>
1289 &rootprompt;<userinput>/etc/init.d/slapd restart</userinput>
1290 </screen>
1291                 </para>
1293                 </sect3>
1295                 <sect3>
1296                 <title>Initialize the LDAP Database</title>
1298                 <para>
1299                 Before you can add accounts to the LDAP database, you must create the account containers
1300                 that they will be stored in. The following LDIF file should be modified to match your
1301                 needs (DNS entries, and so on):
1302 <programlisting>
1303 # Organization for Samba Base
1304 dn: dc=quenya,dc=org
1305 objectclass: dcObject
1306 objectclass: organization
1307 dc: quenya
1308 o: Quenya Org Network
1309 description: The Samba-3 Network LDAP Example
1311 # Organizational Role for Directory Management
1312 dn: cn=Manager,dc=quenya,dc=org
1313 objectclass: organizationalRole
1314 cn: Manager
1315 description: Directory Manager
1317 # Setting up container for Users OU
1318 dn: ou=People,dc=quenya,dc=org
1319 objectclass: top
1320 objectclass: organizationalUnit
1321 ou: People
1323 # Setting up admin handle for People OU
1324 dn: cn=admin,ou=People,dc=quenya,dc=org
1325 cn: admin
1326 objectclass: top
1327 objectclass: organizationalRole
1328 objectclass: simpleSecurityObject
1329 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1331 # Setting up container for groups
1332 dn: ou=Groups,dc=quenya,dc=org
1333 objectclass: top
1334 objectclass: organizationalUnit
1335 ou: Groups
1337 # Setting up admin handle for Groups OU
1338 dn: cn=admin,ou=Groups,dc=quenya,dc=org
1339 cn: admin
1340 objectclass: top
1341 objectclass: organizationalRole
1342 objectclass: simpleSecurityObject
1343 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1345 # Setting up container for computers
1346 dn: ou=Computers,dc=quenya,dc=org
1347 objectclass: top
1348 objectclass: organizationalUnit
1349 ou: Computers
1351 # Setting up admin handle for Computers OU
1352 dn: cn=admin,ou=Computers,dc=quenya,dc=org
1353 cn: admin
1354 objectclass: top
1355 objectclass: organizationalRole
1356 objectclass: simpleSecurityObject
1357 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
1358 </programlisting>
1359                 </para>
1361                 <para>
1362                 The userPassword shown above should be generated using <command>slappasswd</command>.
1363                 </para>
1365                 <para>
1366                 The following command will then load the contents of the LDIF file into the LDAP
1367                 database.
1368 <screen>
1369 &prompt;<userinput>slapadd -v -l initldap.dif</userinput>
1370 </screen>
1371                 </para>
1373                 <para>
1374                 Do not forget to secure your LDAP server with an adequate access control list
1375                 as well as an admin password.
1376                 </para>
1378                 <note><para>
1379                 Before Samba can access the LDAP server, you need to store the LDAP admin password
1380                 in the Samba-3 <filename>secrets.tdb</filename> database by:
1381 <screen>
1382 &rootprompt;<userinput>smbpasswd -w <replaceable>secret</replaceable></userinput>
1383 </screen>
1384                 </para></note>
1386                 </sect3>
1388                 <sect3>
1389                 <title>Configuring Samba</title>
1391                         <para>
1392                         The following parameters are available in smb.conf only if your
1393                         version of Samba was built with LDAP support. Samba automatically builds with LDAP support if the
1394                         LDAP libraries are found.
1395                         </para>
1397                         <para>LDAP-related smb.conf options are:
1398                         <smbconfblock>
1399                         <smbconfoption name="passdb backend">ldapsam:url</smbconfoption>
1400                         <smbconfoption name="ldap admin dn"/>
1401                         <smbconfoption name="ldap delete dn"/>
1402                         <smbconfoption name="ldap filter"/>
1403                         <smbconfoption name="ldap group suffix"/>
1404                         <smbconfoption name="ldap idmap suffix"/>
1405                         <smbconfoption name="ldap machine suffix"/>
1406                         <smbconfoption name="ldap passwd sync"/>
1407                         <smbconfoption name="ldap ssl"/>
1408                         <smbconfoption name="ldap suffix"/>
1409                         <smbconfoption name="ldap user suffix"/>
1410                         </smbconfblock>
1411                         </para>
1413                         <para>
1414                         These are described in the &smb.conf; man page and so are not repeated here. However, an example 
1415                         for use with an LDAP directory is shown in <link linkend="confldapex">the Configuration with LDAP.</link>
1416                         </para>
1418 <example id="confldapex">
1419 <title>Configuration with LDAP</title>
1420 <smbconfblock>
1421 <smbconfsection name="[global]"/>
1422 <smbconfoption name="security">user</smbconfoption>
1423 <smbconfoption name="encrypt passwords">yes</smbconfoption>
1424 <smbconfoption name="netbios name">MORIA</smbconfoption>
1425 <smbconfoption name="workgroup">NOLDOR</smbconfoption>
1427 <smbconfcomment>LDAP related parameters:</smbconfcomment>
1429 <smbconfcomment>Define the DN used when binding to the LDAP servers.</smbconfcomment>
1430 <smbconfcomment>The password for this DN is not stored in smb.conf</smbconfcomment>
1431 <smbconfcomment>Set it using 'smbpasswd -w secretpw' to store the</smbconfcomment>
1432 <smbconfcomment>passphrase in the secrets.tdb file.</smbconfcomment>
1433 <smbconfcomment>If the "ldap admin dn" value changes, it must be reset.</smbconfcomment>
1434 <smbconfoption name="ldap admin dn">"cn=Manager,dc=quenya,dc=org"</smbconfoption>
1436 <smbconfcomment>SSL directory connections can be configured by:</smbconfcomment>
1437 <smbconfcomment>('off', 'start tls', or 'on' (default))</smbconfcomment>
1438 <smbconfoption name="ldap ssl">start tls</smbconfoption>
1440 <smbconfcomment>syntax: passdb backend = ldapsam:ldap://server-name[:port]</smbconfcomment>
1441 <smbconfoption name="passdb backend">ldapsam:ldap://frodo.quenya.org</smbconfoption>
1443 <smbconfcomment>smbpasswd -x delete the entire dn-entry</smbconfcomment>
1444 <smbconfoption name="ldap delete dn">no</smbconfoption>
1446 <smbconfcomment>The machine and user suffix are added to the base suffix</smbconfcomment>
1447 <smbconfcomment>wrote WITHOUT quotes. NULL suffixes by default</smbconfcomment>
1448 <smbconfoption name="ldap user suffix">ou=People</smbconfoption>
1449 <smbconfoption name="ldap group suffix">ou=Groups</smbconfoption>
1450 <smbconfoption name="ldap machine suffix">ou=Computers</smbconfoption>
1452 <smbconfcomment>Trust UNIX account information in LDAP</smbconfcomment>
1453 <smbconfcomment> (see the smb.conf man page for details)</smbconfcomment>
1455 <smbconfcomment>Specify the base DN to use when searching the directory</smbconfcomment>
1456 <smbconfoption name="ldap suffix">dc=quenya,dc=org</smbconfoption>
1457 </smbconfblock>
1458 </example>
1460                 </sect3>
1462                 <sect3>
1463                 <title>Accounts and Groups Management</title>
1465                         <para>
1466 <indexterm><primary>User Management</primary></indexterm>
1467 <indexterm><primary>User Accounts</primary><secondary>Adding/Deleting</secondary></indexterm>
1469                         Because user accounts are managed through the sambaSamAccount ObjectClass, you should
1470                         modify your existing administration tools to deal with sambaSamAccount attributes.
1471                         </para>
1473                         <para>
1474                         Machine accounts are managed with the sambaSamAccount ObjectClass, just
1475                         like user accounts. However, it is up to you to store those accounts
1476                         in a different tree of your LDAP namespace. You should use
1477                         <quote>ou=Groups,dc=quenya,dc=org</quote> to store groups and
1478                         <quote>ou=People,dc=quenya,dc=org</quote> to store users. Just configure your
1479                         NSS and PAM accordingly (usually, in the <filename>/etc/openldap/sldap.conf</filename>
1480                         configuration file).
1481                         </para>
1483                         <para>
1484                         In Samba-3, the group management system is based on POSIX
1485                         groups. This means that Samba makes use of the posixGroup ObjectClass.
1486                         For now, there is no NT-like group system management (global and local
1487                         groups). Samba-3 knows only about <constant>Domain Groups</constant>
1488                         and, unlike MS Windows 2000 and Active Directory, Samba-3 does not
1489                         support nested groups. 
1490                         </para>
1492                 </sect3>
1494                 <sect3>
1495                 <title>Security and sambaSamAccount</title>
1498                         <para>
1499                         There are two important points to remember when discussing the security
1500                         of sambaSamAccount entries in the directory.
1501                         </para>
1503                         <itemizedlist>
1504                                 <listitem><para><emphasis>Never</emphasis> retrieve the SambaLMPassword or
1505                                 SambaNTPassword attribute values over an unencrypted LDAP session.</para></listitem>
1506                                 <listitem><para><emphasis>Never</emphasis> allow non-admin users to
1507                                 view the SambaLMPassword or SambaNTPassword attribute values.</para></listitem>
1508                         </itemizedlist>
1510                         <para>
1511                         These password hashes are clear-text equivalents and can be used to impersonate
1512                         the user without deriving the original clear-text strings. For more information
1513                         on the details of LM/NT password hashes, refer to <link linkend="passdb">the Account Information
1514                         Database section</link>.
1515                         </para>
1517                         <para>
1518                         To remedy the first security issue, the <smbconfoption name="ldap ssl"/> &smb.conf; parameter defaults
1519                         to require an encrypted session (<smbconfoption name="ldap ssl">on</smbconfoption>) using
1520                         the default port of <constant>636</constant>
1521                         when contacting the directory server. When using an OpenLDAP server, it
1522                         is possible to use the StartTLS LDAP extended  operation in the place of
1523                         LDAPS. In either case, you are strongly discouraged to disable this security
1524                         (<smbconfoption name="ldap ssl">off</smbconfoption>).
1525                         </para>
1527                         <para>
1528                         Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
1529                         extended operation. However, the OpenLDAP library still provides support for
1530                         the older method of securing communication between clients and servers.
1531                         </para>
1533                         <para>
1534                         The second security precaution is to prevent non-administrative users from
1535                         harvesting password hashes from the directory. This can be done using the
1536                         following ACL in <filename>slapd.conf</filename>:
1537                         </para>
1539 <para>
1540 <programlisting>
1541 ## allow the "ldap admin dn" access, but deny everyone else
1542 access to attrs=SambaLMPassword,SambaNTPassword
1543      by dn="cn=Samba Admin,ou=People,dc=quenya,dc=org" write
1544      by * none
1545 </programlisting>
1546 </para>
1548                 </sect3>
1550                 <sect3>
1551                 <title>LDAP Special Attributes for sambaSamAccounts</title>
1553                         <para> The sambaSamAccount ObjectClass is composed of the attributes shown in next tables: <link
1554                         linkend="attribobjclPartA">Part A</link>, and <link linkend="attribobjclPartB">Part B</link>. 
1555                         </para>
1557                         <para>
1558                         <table frame="all" id="attribobjclPartA">
1559                                 <title>Attributes in the sambaSamAccount ObjectClass (LDAP), Part A</title>
1560                         <tgroup cols="2" align="justify">
1561                                         <colspec align="left"/>
1562                                         <colspec align="justify" colwidth="1*"/>
1563                         <tbody>
1564                                 <row><entry><constant>sambaLMPassword</constant></entry><entry>The LanMan password 16-byte hash stored as a character
1565                                                 representation of a hexadecimal string.</entry></row>
1566                                 <row><entry><constant>sambaNTPassword</constant></entry><entry>The NT password 16-byte hash stored as a character
1567                                                 representation of a hexadecimal string.</entry></row>
1568                                 <row><entry><constant>sambaPwdLastSet</constant></entry><entry>The integer time in seconds since 1970 when the
1569                                                 <constant>sambaLMPassword</constant> and <constant>sambaNTPassword</constant> attributes were last set.
1570                                 </entry></row>
1572                                 <row><entry><constant>sambaAcctFlags</constant></entry><entry>String of 11 characters surrounded by square brackets [ ]
1573                                                 representing account flags such as U (user), W (workstation), X (no password expiration),
1574                                                 I (domain trust account), H (home dir required), S (server trust account),
1575                                                 and D (disabled).</entry></row>
1577                                 <row><entry><constant>sambaLogonTime</constant></entry><entry>Integer value currently unused.</entry></row>
1579                                 <row><entry><constant>sambaLogoffTime</constant></entry><entry>Integer value currently unused.</entry></row>
1581                                 <row><entry><constant>sambaKickoffTime</constant></entry><entry>Specifies the time (UNIX time format) when the user
1582                                 will be locked down and cannot login any longer. If this attribute is omitted, then the account will never expire.
1583                                 Using this attribute together with shadowExpire of the shadowAccount ObjectClass will enable accounts to        
1584                                 expire completely on an exact date.</entry></row>
1586                                 <row><entry><constant>sambaPwdCanChange</constant></entry><entry>Specifies the time (UNIX time format) after which the user is allowed to
1587                                 change his password. If attribute is not set, the user will be free to change his password whenever he wants.</entry></row>
1589                                 <row><entry><constant>sambaPwdMustChange</constant></entry><entry>Specifies the time (UNIX time format) when the user is
1590                                 forced to change his password. If this value is set to 0, the user will have to change his password at first login.
1591                                 If this attribute is not set, then the password will never expire.</entry></row>
1593                                 <row><entry><constant>sambaHomeDrive</constant></entry><entry>Specifies the drive letter to which to map the
1594                                 UNC path specified by sambaHomePath. The drive letter must be specified in the form <quote>X:</quote>
1595                                 where X is the letter of the drive to map. Refer to the <quote>logon drive</quote> parameter in the
1596                                 smb.conf(5) man page for more information.</entry></row>
1598                                 <row><entry><constant>sambaLogonScript</constant></entry><entry>The sambaLogonScript property specifies the path of
1599                                 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
1600                                 is relative to the netlogon share. Refer to the <smbconfoption name="logon script"/> parameter in the
1601                                 &smb.conf; man page for more information.</entry></row>
1603                                 <row><entry><constant>sambaProfilePath</constant></entry><entry>Specifies a path to the user's profile.
1604                                 This value can be a null string, a local absolute path, or a UNC path. Refer to the
1605                                 <smbconfoption name="logon path"/> parameter in the &smb.conf; man page for more information.</entry></row>
1607                                 <row><entry><constant>sambaHomePath</constant></entry><entry>The sambaHomePath property specifies the path of
1608                                 the home directory for the user. The string can be null. If sambaHomeDrive is set and specifies
1609                                 a drive letter, sambaHomePath should be a UNC path. The path must be a network
1610                                 UNC path of the form <filename>\\server\share\directory</filename>. This value can be a null string.
1611                                 Refer to the <command>logon home</command> parameter in the &smb.conf; man page for more information.
1612                                 </entry></row>
1613                         </tbody>
1614                         </tgroup></table>
1615                         </para>
1616                         <para>
1617                         <table frame="all" id="attribobjclPartB">
1618                                 <title>Attributes in the sambaSamAccount ObjectClass (LDAP), Part B</title>
1619                         <tgroup cols="2" align="justify">
1620                                         <colspec align="left"/>
1621                                         <colspec align="justify" colwidth="1*"/>
1622                         <tbody>
1623                                 <row><entry><constant>sambaUserWorkstations</constant></entry><entry>Here you can give a comma-separated list of machines
1624                                 on which the user is allowed to login. You may observe problems when you try to connect to a Samba domain member.
1625                                 Because domain members are not in this list, the domain controllers will reject them. Where this attribute is omitted,
1626                                 the default implies no restrictions.
1627                                 </entry></row>
1629                                 <row><entry><constant>sambaSID</constant></entry><entry>The security identifier(SID) of the user.
1630                                 The Windows equivalent of UNIX UIDs.</entry></row>
1632                                 <row><entry><constant>sambaPrimaryGroupSID</constant></entry><entry>The security identifier (SID) of the primary group
1633                                 of the user.</entry></row>
1635                                 <row><entry><constant>sambaDomainName</constant></entry><entry>Domain the user is part of.</entry></row>
1636                         </tbody>
1637                         </tgroup></table>
1638                         </para>
1640                         <para>
1641                         The majority of these parameters are only used when Samba is acting as a PDC of
1642                         a domain (refer to <link linkend="samba-pdc">Domain Control</link>, for details on
1643                         how to configure Samba as a PDC). The following four attributes
1644                         are only stored with the sambaSamAccount entry if the values are non-default values:
1645                         </para>
1647                         <itemizedlist>
1648                                 <listitem><para>sambaHomePath</para></listitem>
1649                                 <listitem><para>sambaLogonScript</para></listitem>
1650                                 <listitem><para>sambaProfilePath</para></listitem>
1651                                 <listitem><para>sambaHomeDrive</para></listitem>
1652                         </itemizedlist>
1654                         <para>
1655                         These attributes are only stored with the sambaSamAccount entry if
1656                         the values are non-default values. For example, assume MORIA has now been
1657                         configured as a PDC and that <smbconfoption name="logon home">\\%L\%u</smbconfoption> was defined in
1658                         its &smb.conf; file. When a user named <quote>becky</quote> logs on to the domain,
1659                         the <smbconfoption name="logon home"/> string is expanded to \\MORIA\becky.
1660                         If the smbHome attribute exists in the entry <quote>uid=becky,ou=People,dc=samba,dc=org</quote>,
1661                         this value is used. However, if this attribute does not exist, then the value
1662                         of the <smbconfoption name="logon home"/> parameter is used in its place. Samba
1663                         will only write the attribute value to the directory entry if the value is
1664                         something other than the default (e.g., <filename>\\MOBY\becky</filename>).
1665                         </para>
1667                 </sect3>
1669                 <sect3>
1670                 <title>Example LDIF Entries for a sambaSamAccount</title>
1672                         <para>
1673                         The following is a working LDIF that demonstrates the use of the SambaSamAccount ObjectClass:
1674                         </para>
1676         <para>
1677         <programlisting>
1678         dn: uid=guest2, ou=People,dc=quenya,dc=org
1679         sambaLMPassword: 878D8014606CDA29677A44EFA1353FC7
1680         sambaPwdMustChange: 2147483647
1681         sambaPrimaryGroupSID: S-1-5-21-2447931902-1787058256-3961074038-513
1682         sambaNTPassword: 552902031BEDE9EFAAD3B435B51404EE
1683         sambaPwdLastSet: 1010179124
1684         sambaLogonTime: 0
1685         objectClass: sambaSamAccount
1686         uid: guest2
1687         sambaKickoffTime: 2147483647
1688         sambaAcctFlags: [UX         ]
1689         sambaLogoffTime: 2147483647
1690         sambaSID: S-1-5-21-2447931902-1787058256-3961074038-5006
1691         sambaPwdCanChange: 0
1692 </programlisting>
1693         </para>
1695                         <para>
1696                         The following is an LDIF entry for using both the sambaSamAccount and
1697                         posixAccount ObjectClasses:
1698                         </para>
1700                         <para>
1701         <programlisting>
1702         dn: uid=gcarter, ou=People,dc=quenya,dc=org
1703         sambaLogonTime: 0
1704         displayName: Gerald Carter
1705         sambaLMPassword: 552902031BEDE9EFAAD3B435B51404EE
1706         sambaPrimaryGroupSID: S-1-5-21-2447931902-1787058256-3961074038-1201
1707         objectClass: posixAccount
1708         objectClass: sambaSamAccount
1709         sambaAcctFlags: [UX         ]
1710         userPassword: {crypt}BpM2ej8Rkzogo
1711         uid: gcarter
1712         uidNumber: 9000
1713         cn: Gerald Carter
1714         loginShell: /bin/bash
1715         logoffTime: 2147483647
1716         gidNumber: 100
1717         sambaKickoffTime: 2147483647
1718         sambaPwdLastSet: 1010179230
1719         sambaSID: S-1-5-21-2447931902-1787058256-3961074038-5004
1720         homeDirectory: /home/moria/gcarter
1721         sambaPwdCanChange: 0
1722         sambaPwdMustChange: 2147483647
1723         sambaNTPassword: 878D8014606CDA29677A44EFA1353FC7
1724 </programlisting>
1725         </para>
1727                 </sect3>
1729                 <sect3>
1730                 <title>Password Synchronization</title>
1732                 <para>
1733                 Samba-3 and later can update the non-Samba (LDAP) password stored with an account. When
1734                 using pam_ldap, this allows changing both UNIX and Windows passwords at once.
1735                 </para>
1737                 <para>The <smbconfoption name="ldap passwd sync"/> options can have the  values shown in
1738                 <link linkend="ldappwsync">Table 10.3</link>.</para>
1740                 <table frame="all" id="ldappwsync">
1741                         <title>Possible <emphasis>ldap passwd sync</emphasis> Values</title>
1742                 <tgroup cols="2">
1743                         <colspec align="left" colwidth="1*"/>
1744                         <colspec align="justify" colwidth="4*"/>
1745                 <thead>
1746                         <row><entry align="left">Value</entry><entry align="center">Description</entry></row>
1747                 </thead>
1748                 <tbody>
1749                 <row><entry>yes</entry><entry><para>When the user changes his password, update
1750                                <constant>SambaNTPassword</constant>, <constant>SambaLMPassword</constant>,
1751                                and the <constant>password</constant> fields.</para></entry></row>
1753                 <row><entry>no</entry><entry><para>Only update <constant>SambaNTPassword</constant> and <constant>SambaLMPassword</constant>.</para></entry></row>
1755                 <row><entry>only</entry><entry><para>Only update the LDAP password and let the LDAP server worry about the other fields.
1756                         This option is only available on some LDAP servers and only when the LDAP server
1757                         supports LDAP_EXOP_X_MODIFY_PASSWD.</para></entry></row>
1758                 </tbody>
1759                 </tgroup>
1760                 </table>
1763                 <para>More information can be found in the &smb.conf; man page.</para>
1765                 </sect3>
1767         </sect2>
1769         <sect2>
1770         <title>MySQL</title>
1772         <para>
1773 <indexterm><primary>SAM backend</primary><secondary>mysqlsam</secondary></indexterm>
1774         Every so often someone comes along with a great new idea. Storing user accounts in a
1775         SQL backend is one of them. Those who want to do this are in the best position to know what the
1776         specific benefits are to them. This may sound like a cop-out, but in truth we cannot attempt
1777         to document every little detail of why certain things of marginal utility to the bulk of
1778         Samba users might make sense to the rest. In any case, the following instructions should help
1779         the determined SQL user to implement a working system.
1780         </para>
1782                 <sect3>
1783                 <title>Creating the Database</title>
1785                         <para>
1786                         You can set up your own table and specify the field names to pdb_mysql (see
1787                         <link linkend="moremysqlpdbe">MySQL field names for MySQL passdb backend</link> for
1788                         the column names) or use the default table. The file
1789                         <filename>examples/pdb/mysql/mysql.dump</filename> contains the correct queries to
1790                         create the required tables. Use the command:
1791 <screen>
1792 &prompt;<userinput>mysql -u<replaceable>username</replaceable> -h<replaceable>hostname</replaceable> -p<replaceable>password</replaceable> \
1793         <replaceable>databasename</replaceable> &lt; <filename>/path/to/samba/examples/pdb/mysql/mysql.dump</filename></userinput>
1794 </screen>
1795                         </para>
1796                 </sect3>
1798                 <sect3>
1799                 <title>Configuring</title>
1801                         <para>This plug-in lacks some good documentation, but here is some brief information. Add the following to the
1802                         <smbconfoption name="passdb backend"/> variable in your &smb.conf;:
1803 <smbconfblock>
1804 <smbconfoption name="passdb backend">[other-plugins] mysql:identifier [other-plugins]</smbconfoption>
1805 </smbconfblock>
1806                         </para>
1808                         <para>The identifier can be any string you like, as long as it does not collide with 
1809                         the identifiers of other plugins or other instances of pdb_mysql. If you 
1810                         specify multiple pdb_mysql.so entries in <smbconfoption name="passdb backend"/>, you also need to 
1811                         use different identifiers.
1812                         </para>
1814                         <para>
1815                         Additional options can be given through the &smb.conf; file in the <smbconfsection name="[global]"/> section.
1816                         Refer to <link linkend="mysqlpbe">Basic smb.conf Options for MySQL passdb Backend</link>.
1817                         </para>
1819                         <table frame="all" id="mysqlpbe">
1820                                 <title>Basic smb.conf Options for MySQL passdb Backend</title>
1821                                 <tgroup cols="2">
1822                                         <colspec align="left"/>
1823                                         <colspec align="justify" colwidth="1*"/>
1824                                 <thead>
1825                                         <row><entry>Field</entry><entry>Contents</entry></row>
1826                                 </thead>
1827                                 <tbody>
1828                                         <row><entry>mysql host</entry><entry>Host name, defaults to `localhost'</entry></row>
1829                                         <row><entry>mysql password</entry><entry></entry></row>
1830                                         <row><entry>mysql user</entry><entry>Defaults to `samba'</entry></row>
1831                                         <row><entry>mysql database</entry><entry>Defaults to `samba'</entry></row>
1832                                         <row><entry>mysql port</entry><entry>Defaults to 3306</entry></row>
1833                                         <row><entry>table</entry><entry>Name of the table containing the users</entry></row>
1834                                 </tbody>
1835                                 </tgroup>
1836                         </table>
1838                         <warning>
1839                         <para>
1840                         Since the password for the MySQL user is stored in the &smb.conf; file, you should make the &smb.conf; file 
1841                         readable only to the user who runs Samba. This is considered a security bug and will soon be fixed.
1842                         </para>
1843                         </warning>
1845                         <para>Names of the columns are given in <link linkend="moremysqlpdbe">MySQL field names for MySQL
1846                         passdb backend</link>.  The default column names can be found in the example table dump.
1847                          </para>
1849                 <para>
1850                         <table frame="all" id="moremysqlpdbe">
1851                                 <title>MySQL field names for MySQL passdb backend</title>
1852                                 <tgroup cols="3" align="justify">
1853                                         <colspec align="left"/>
1854                                         <colspec align="left"/>
1855                                         <colspec align="justify" colwidth="1*"/>
1856                         <thead>         
1857                                 <row><entry>Field</entry><entry>Type</entry><entry>Contents</entry></row>
1858                         </thead>
1859                         <tbody>
1860                                 <row><entry>logon time column</entry><entry>int(9)</entry><entry>UNIX timestamp of last logon of user</entry></row>
1861                                 <row><entry>logoff time column</entry><entry>int(9)</entry><entry>UNIX timestamp of last logoff of user</entry></row>
1862                                 <row><entry>kickoff time column</entry><entry>int(9)</entry><entry>UNIX timestamp of moment user should be kicked off workstation (not enforced)</entry></row>
1863                                 <row><entry>pass last set time column</entry><entry>int(9)</entry><entry>UNIX timestamp of moment password was last set</entry></row>
1864                                 <row><entry>pass can change time column</entry><entry>int(9)</entry><entry>UNIX timestamp of moment from which password can be changed</entry></row>
1865                                 <row><entry>pass must change time column</entry><entry>int(9)</entry><entry>UNIX timestamp of moment on which password must be changed</entry></row>
1866                                 <row><entry>username column</entry><entry>varchar(255)</entry><entry>UNIX username</entry></row>
1867                                 <row><entry>domain column</entry><entry>varchar(255)</entry><entry>NT domain user belongs to</entry></row>
1868                                 <row><entry>nt username column</entry><entry>varchar(255)</entry><entry>NT username</entry></row>
1869                                 <row><entry>fullname column</entry><entry>varchar(255)</entry><entry>Full name of user</entry></row>
1870                                 <row><entry>home dir column</entry><entry>varchar(255)</entry><entry>UNIX homedir path (equivalent of the <smbconfoption name="logon home"/> parameter.</entry></row>
1871                                 <row><entry>dir drive column</entry><entry>varchar(2)</entry><entry>Directory drive path (e.g., <quote>H:</quote>)</entry></row>
1872                                 <row><entry>logon script column</entry><entry>varchar(255)</entry><entry>Batch file to run on client side when logging on</entry></row>
1873                                 <row><entry>profile path column</entry><entry>varchar(255)</entry><entry>Path of profile</entry></row>
1874                                 <row><entry>acct desc column</entry><entry>varchar(255)</entry><entry>Some ASCII NT user data</entry></row>
1875                                 <row><entry>workstations column</entry><entry>varchar(255)</entry><entry>Workstations user can logon to (or NULL for all)</entry></row>
1876                                 <row><entry>unknown string column</entry><entry>varchar(255)</entry><entry>Unknown string</entry></row>
1877                                 <row><entry>munged dial column</entry><entry>varchar(255)</entry><entry>Unknown</entry></row>
1878                                 <row><entry>user sid column</entry><entry>varchar(255)</entry><entry>NT user SID</entry></row>
1879                                 <row><entry>group sid column</entry><entry>varchar(255)</entry><entry>NT group SID</entry></row>
1880                                 <row><entry>lanman pass column</entry><entry>varchar(255)</entry><entry>Encrypted lanman password</entry></row>
1881                                 <row><entry>nt pass column</entry><entry>varchar(255)</entry><entry>Encrypted nt passwd</entry></row>
1882                                 <row><entry>plain pass column</entry><entry>varchar(255)</entry><entry>Plaintext password</entry></row>
1883                                 <row><entry>acct ctrl column</entry><entry>int(9)</entry><entry>NT user data</entry></row>
1884                                 <row><entry>unknown 3 column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1885                                 <row><entry>logon divs column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1886                                 <row><entry>hours len column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1887                                 <row><entry>bad password count column</entry><entry>int(5)</entry><entry>Number of failed password tries before disabling an account</entry></row>
1888                                 <row><entry>logon count column</entry><entry>int(5)</entry><entry>Number of logon attempts</entry></row>
1889                                 <row><entry>unknown 6 column</entry><entry>int(9)</entry><entry>Unknown</entry></row>
1890                         </tbody></tgroup>
1891                 </table>
1892                 </para>
1894                         <para>
1895                         You can put a colon (:) after the name of each column, which 
1896                         should specify the column to update when updating the table. You 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.
1897                         </para>
1899                         <para><link linkend="mysqlsam">An example configuration</link> is shown in <link
1900                         linkend="mysqlsam">Example Configuration for the MySQL passdb Backend</link>.
1901                         </para>
1903                         <example id="mysqlsam">
1904                         <title>Example Configuration for the MySQL passdb Backend</title>
1905                         <smbconfblock>
1906                         <smbconfsection name="[global]"/>
1907                         <smbconfoption name="passdb backend">mysql:foo</smbconfoption>
1908                         <smbconfoption name="foo:mysql user">samba</smbconfoption>
1909                         <smbconfoption name="foo:mysql password">abmas</smbconfoption>
1910                         <smbconfoption name="foo:mysql database">samba</smbconfoption>
1911                         <smbconfcomment>domain name is static and can't be changed</smbconfcomment>
1912                         <smbconfoption name="foo:domain column">'MYWORKGROUP':</smbconfoption>
1913                         <smbconfcomment>The fullname column comes from several other columns</smbconfcomment>
1914                         <smbconfoption name="foo:fullname column">CONCAT(firstname,' ',surname):</smbconfoption>
1915                         <smbconfcomment>Samba should never write to the password columns</smbconfcomment>
1916                         <smbconfoption name="foo:lanman pass column">lm_pass:</smbconfoption>
1917                         <smbconfoption name="foo:nt pass column">nt_pass:</smbconfoption>
1918                         <smbconfcomment>The unknown 3 column is not stored</smbconfcomment>
1919                         <smbconfoption name="foo:unknown 3 column">NULL</smbconfoption>
1920                         </smbconfblock>
1921                         </example>
1922                 </sect3>
1924                 <sect3>
1925                 <title>Using Plaintext Passwords or Encrypted Password</title>
1927                         <para>
1928 <indexterm><primary>encrypted passwords</primary></indexterm>
1929                         I strongly discourage the use of plaintext passwords; however, you can use them.
1930                         </para>
1932                         <para>
1933                         If you would like to use plaintext passwords, set
1934                         `identifier:lanman pass column' and `identifier:nt pass column' to
1935                         `NULL' (without the quotes) and `identifier:plain pass column' to the
1936                         name of the column containing the plaintext passwords. 
1937                         </para>
1939                         <para>
1940                         If you use encrypted passwords, set the 'identifier:plain pass
1941                         column' to 'NULL' (without the quotes). This is the default.
1942                         </para>
1944                 </sect3>
1946                 <sect3>
1947                 <title>Getting Non-Column Data from the Table</title>
1949                         <para>
1950                         It is possible to have not all data in the database by making some "constant."
1951                         </para>
1953                         <para>
1954                         For example, you can set `identifier:fullname column' to
1955                         something like <?latex \linebreak ?><command>CONCAT(Firstname,' ',Surname)</command>
1956                         </para>
1958                         <para>
1959                         Or, set `identifier:workstations column' to:
1960                         <command>NULL</command></para>.
1962                         <para>See the MySQL documentation for more language constructs.</para>
1964                 </sect3>
1965         </sect2>
1967         <sect2 id="XMLpassdb">
1968         <title>XML</title>
1970         <para>
1971 <indexterm><primary>SAM backend</primary><secondary>xmlsam</secondary></indexterm>
1972                 This module requires libxml2 to be installed.</para>
1974                 <para>The usage of pdb_xml is fairly straightforward. To export data, use:
1975                 </para>
1977                 <para>
1978 <indexterm><primary>pdbedit</primary></indexterm>
1979                         <prompt>$ </prompt> <userinput>pdbedit -e xml:filename</userinput>
1980                 </para>
1982                 <para>
1983                 where filename is the name of the file to put the data in.
1984                 </para>
1986                 <para>
1987                 To import data, use:
1988                 <prompt>$ </prompt> <userinput>pdbedit -i xml:filename</userinput>
1989                 </para>
1990         </sect2>
1991 </sect1>
1993 <sect1>
1994 <title>Common Errors</title>
1996         <sect2>
1997                 <title>Users Cannot Logon</title>
1999                 <para><quote>I've installed Samba, but now I can't log on with my UNIX account! </quote></para>
2001                 <para>Make sure your user has been added to the current Samba <smbconfoption name="passdb backend"/>. 
2002                 Read the <link linkend="acctmgmttools">Account Management Tools,</link> for details.</para>
2004         </sect2>
2006         <sect2>
2007         <title>Users Being Added to the Wrong Backend Database</title>
2009         <para>
2010         A few complaints have been received from users who just moved to Samba-3. The following
2011         &smb.conf; file entries were causing problems: new accounts were being added to the old
2012         smbpasswd file, not to the tdbsam passdb.tdb file:
2013         </para>
2015         <para>
2016         <smbconfblock>
2017         <smbconfsection name="[global]"/>
2018         <member>...</member>
2019         <smbconfoption name="passdb backend">smbpasswd, tdbsam</smbconfoption>
2020         <member>...</member>
2021         </smbconfblock>
2022         </para>
2024         <para>
2025         Samba will add new accounts to the first entry in the <emphasis>passdb backend</emphasis>
2026         parameter entry. If you want to update to the tdbsam, then change the entry to:
2027         </para>
2029         <para>
2030 <smbconfblock>
2031 [globals]
2033 <smbconfoption name="passdb backend">tdbsam, smbpasswd</smbconfoption>
2035 </smbconfblock>
2036         </para>
2038         </sect2>
2040         <sect2>
2041         <title>Configuration of <parameter>auth methods</parameter></title>
2043         <para>
2044         When explicitly setting an <smbconfoption name="auth methods"/> parameter,
2045         <parameter>guest</parameter> must be specified as the first entry on the line &smbmdash;
2046         for example, <smbconfoption name="auth methods">guest sam</smbconfoption>.
2047         </para>
2049         </sect2>
2051 </sect1>
2053 </chapter>