This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[sfrench/samba-autobuild/.git] / docs / docbook / projdoc / passdb.xml
1 <chapter id="passdb">
2 <chapterinfo>
3         &author.jelmer;
4         &author.jerry;
5         &author.jeremy;
6         &author.jht;
7         <author>
8                 <firstname>Olivier (lem)</firstname><surname>Lemaire</surname>
9                 <affiliation>
10                         <orgname>IDEALX</orgname>
11                         <address><email>olem@IDEALX.org</email></address>
12                 </affiliation>
13         </author>
14         
15         <pubdate>May 24, 2003</pubdate>
16 </chapterinfo>
17 <title>Account Information Databases</title>
18
19 <para>
20 Samba-3 implements a new capability to work concurrently with mulitple account backends.
21 The possible new combinations of password backends allows Samba-3 a degree of flexibility
22 and scalability that previously could be achieved only with MS Windows Active Directory.
23 This chapter describes the new functionality and how to get the most out of it.
24 </para>
25
26 <para>
27 In the course of development of Samba-3 a number of requests were received to provide the
28 ability to migrate MS Windows NT4 SAM accounts to Samba-3 without the need to provide
29 matching Unix/Linux accounts. We called this the <emphasis>Non Unix Accounts (NUA)</emphasis>
30 capability. The intent was that an administrator could decide to use the <emphasis>tdbsam</emphasis>
31 backend and by simply specifying <emphasis>"passdb backedn = tdbsam_nua, guest"</emphasis>
32 this would allow Samba-3 to implement a solution that did not use Unix accounts per se. Late
33 in the development cycle the team doing this work hit upon some obstacles that prevents this
34 solution from being used. Given the delays with Samba-3 release a decision was made to NOT
35 deliver this functionality until a better method of recognising NT Group SIDs from NT User
36 SIDs could be found. This feature may thus return during the life cycle for the Samba-3 series.
37 </para>
38
39 <note><para>
40 Samba-3.0.0 does NOT support Non-Unix Account (NUA) operation.
41 </para></note>
42
43 <sect1>
44 <title>Features and Benefits</title>
45
46 <para>
47 Samba-3 provides for complete backwards compatibility with Samba-2.2.x functionality
48 as follows:
49 </para>
50
51 <variablelist>
52 <title>Backwards Compatibility Backends</title>
53         <varlistentry><term>Plain Text:</term>
54                 <listitem>
55                         <para>
56                         This option uses nothing but the Unix/Linux <filename>/etc/passwd</filename>
57                         style back end. On systems that have PAM (Pluggable Authentication Modules)
58                         support all PAM modules are supported. The behaviour is just as it was with
59                         Samba-2.2.x, and the protocol limitations imposed by MS Windows clients
60                         apply likewise.
61                         </para>
62                 </listitem>
63         </varlistentry>
64
65         <varlistentry><term>smbpasswd:</term>
66                 <listitem>
67                         <para>
68                         This option allows continues use of the <filename>smbpasswd</filename>
69                         file that maintains a plain ASCII (text) layout that includes the MS Windows
70                         LanMan and NT encrypted passwords as well as a field that stores some
71                         account information. This form of password backend does NOT store any of
72                         the MS Windows NT/200x SAM (Security Account Manager) information needed to
73                         provide the extended controls that are needed for more comprehensive 
74                         interoperation with MS Windows NT4 / 200x servers.
75                         </para>
76
77                         <para>
78                         This backend should be used only for backwards compatibility with older
79                         versions of Samba. It may be deprecated in future releases.
80                         </para>
81                 </listitem>
82         </varlistentry>
83
84         <varlistentry><term>ldapsam_compat (Samba-2.2 LDAP Compatibilty):</term>
85                 <listitem>
86                         <para>
87                         There is a password backend option that allows continued operation with
88                         a existing OpenLDAP backend that uses the Samba-2.2.x LDAP schema extension.
89                         This option is provided primarily as a migration tool, although there is
90                         no reason to force migration at this time. Note that this tool will eventually
91                         be deprecated.
92                         </para>
93                 </listitem>
94         </varlistentry>
95 </variablelist>
96
97 <para>
98 Samba-3 introduces the following new password backend capabilities:
99 </para>
100
101 <variablelist>
102 <title>New Backends</title>
103         <varlistentry><term>guest:</term>
104                 <listitem>
105                         <para>
106                         This is <emphasis>always</emphasis> required as the last backend specified.
107                         It provides the ability to handle guest account requirements for access to
108                         resources like <parameter>IPC$</parameter> which is used for browsing.
109                         </para>
110                 </listitem>
111         </varlistentry>
112
113         <varlistentry><term>tdbsam:</term>
114                 <listitem>
115                         <para>
116                         This backend provides a rich database backend for local servers. This
117                         backend is NOT suitable for multiple domain controller (ie: PDC + one
118                         or more BDC) installations.
119                         </para>
120
121                         <para>
122                         The <emphasis>tdbsam</emphasis> password backend stores the old <emphasis>
123                         smbpasswd</emphasis> information PLUS the extended MS Windows NT / 200x
124                         SAM information into a binary format TDB (trivial database) file.
125                         The inclusion of the extended information makes it possible for Samba-3
126                         to implement the same account and system access controls that are possible
127                         with MS Windows NT4 and MS Windows 200x based systems.
128                         </para>
129
130                         <para>
131                         The inclusion of the <emphasis>tdbssam</emphasis> capability is a direct
132                         response to user requests to allow simple site operation without the overhead
133                         of the complexities of running OpenLDAP. It is recommended to use this only
134                         for sites that have fewer than 250 users. For larger sites or implementations
135                         the use of OpenLDAP or of Active Directory integration is strongly recommended.
136                         </para>
137                 </listitem>
138         </varlistentry>
139
140         <varlistentry><term>ldapsam:</term>
141                 <listitem>
142                         <para>
143                         This provides a rich directory backend for distributed account installation     
144                         </para>
145
146                         <para>
147                         Samba-3 has a new and extended LDAP implementation that requires configuration
148                         of OpenLDAP with a new format samba schema. The new format schema file is
149                         included in the <filename>~samba/examples/LDAP</filename> directory.
150                         </para>
151
152                         <para>
153                         The new LDAP implmentation significantly expands the control abilities that
154                         were possible with prior versions of Samba. It is now possible to specify
155                         "per user" profile settings, home directories, account access controls, and
156                         much more. Corporate sites will see that the Samba-Team has listened to their
157                         requests both for capability and to allow greater scalability.
158                         </para>
159                 </listitem>
160         </varlistentry>
161
162         <varlistentry><term>mysqlsam (MySQL based backend):</term>
163                 <listitem>
164                         <para>
165                         It is expected that the MySQL based SAM will be very popular in some corners.
166                         This database backend will be on considerable interest to sites that want to
167                         leverage existing MySQL technology.
168                         </para>
169                 </listitem>
170         </varlistentry>
171
172         <varlistentry><term>xmlsam (XML based datafile):</term>
173                 <listitem>
174                         <para>
175                         Allows the account and password data to be stored in an XML format
176                         data file. This backend can not be used for normal operation, it can only 
177                         be used in conjunction with <command>pdbedit</command>'s pdb2pdb 
178                         functionality. The DTD that is used might be subject to changes in the future.
179                         </para>
180
181                         <para>
182                         The xmlsam option can be useful for account migration between database
183                         backends or backups. Use of this tool will allow the data to be edited before migration
184                         into another backend format.
185                         </para>
186                 </listitem>
187         </varlistentry>
188
189         <varlistentry><term>nisplussam:</term>
190                 <listitem>
191                         <para>
192                         The  NIS+ based passdb backend. Takes name NIS domain as an
193                         optional argument. Only works with Sun NIS+ servers.
194                         </para>
195                 </listitem>
196         </varlistentry>
197
198 </variablelist>
199
200 </sect1>
201
202 <sect1>
203         <title>Technical Information</title>
204
205         <para>
206         Old windows clients send plain text passwords over the wire. Samba can check these
207         passwords by crypting them and comparing them to the hash stored in the unix user database.
208         </para>
209         
210         <para>
211         Newer windows clients send encrypted passwords (so-called Lanman and NT hashes) over 
212         the wire, instead of plain text passwords. The newest clients will send only encrypted
213         passwords and refuse to send plain text passwords, unless their registry is tweaked.
214         </para>
215
216         <para>
217         These passwords can't be converted to unix style encrypted passwords. Because of that
218         you can't use the standard unix user database, and you have to store the Lanman and NT
219         hashes somewhere else.
220         </para>
221         
222         <para>
223         In addition to differently encrypted passwords, windows also stores certain data for each
224         user that is not stored in a unix user database. e.g: workstations the user may logon from,
225         the location where the users' profile is stored, and so on. Samba retrieves and stores this
226         information using a <parameter>passdb backend</parameter>.  Commonly available backends are LDAP, plain text
227         file, MySQL and nisplus.  For more information, see the man page for &smb.conf; regarding the 
228         <parameter>passdb backend</parameter> parameter.
229         </para>
230
231         <sect2>
232         <title>Important Notes About Security</title>
233                 
234                 <para>
235                 The unix and SMB password encryption techniques seem similar on the surface. This
236                 similarity is, however, only skin deep. The unix scheme typically sends clear text
237                 passwords over the network when logging in. This is bad. The SMB encryption scheme
238                 never sends the cleartext password over the network but it does store the 16 byte 
239                 hashed values on disk. This is also bad. Why? Because the 16 byte hashed values
240                 are a "password equivalent". You cannot derive the user's password from them, but
241                 they could potentially be used in a modified client to gain access to a server.
242                 This would require considerable technical knowledge on behalf of the attacker but
243                 is perfectly possible. You should thus treat the data stored in whatever passdb
244                 backend you use (smbpasswd file, ldap, mysql) as though it contained the cleartext
245                 passwords of all your users. Its contents must be kept secret, and the file should
246                 be protected accordingly.
247                 </para>
248                 
249                 <para>
250                 Ideally we would like a password scheme that involves neither plain text passwords
251                 on the net nor on disk. Unfortunately this is not available as Samba is stuck with
252                 having to be compatible with other SMB systems (WinNT, WfWg, Win95 etc).
253                 </para>
254
255                 <para>
256                 Windows NT 4.0 Service pack 3 changed the default setting so that plaintext passwords
257                 are disabled from being sent over the wire. This mandates either the use of encrypted
258                 password support or edit the Windows NT registry to re-enable plaintext passwords.
259                 </para>
260                 
261                 <para>
262                 The following versions of MS Windows do not support full domain security protocols,
263                 although they may log onto a domain environment:
264                 </para>
265
266                 <simplelist>
267                         <member>MS DOS Network client 3.0 with the basic network redirector installed</member>
268                         <member>Windows 95 with the network redirector update installed</member>
269                         <member>Windows 98 [se]</member>
270                         <member>Windows Me</member>
271                 </simplelist>
272
273                 <note>
274                 <para>
275                 MS Windows XP Home does not have facilities to become a domain member and it can
276                 not participate in domain logons.
277                 </para>
278                 </note>
279
280                 <para>
281                 The following versions of MS Windows fully support domain security protocols.
282                 </para>
283
284                 <simplelist>
285                         <member>Windows NT 3.5x</member>
286                         <member>Windows NT 4.0</member>
287                         <member>Windows 2000 Professional</member>
288                         <member>Windows 200x Server/Advanced Server</member>
289                         <member>Windows XP Professional</member>
290                 </simplelist>
291                         
292                 <para>
293                 All current release of Microsoft SMB/CIFS clients support authentication via the
294                 SMB Challenge/Response mechanism described here. Enabling clear text authentication
295                 does not disable the ability of the client to participate in encrypted authentication.
296                 Instead, it allows the client to negotiate either plain text _or_ encrypted password
297                 handling.
298                 </para>
299
300                 <para>
301                 MS Windows clients will cache the encrypted password alone. Where plain text passwords
302                 are re-enabled, through the appropriate registry change, the plain text password is NEVER
303                 cached. This means that in the event that a network connections should become disconnected
304                 (broken) only the cached (encrypted) password will be sent to the resource server to
305                 affect a auto-reconnect. If the resource server does not support encrypted passwords the
306                 auto-reconnect will fail. <emphasis>USE OF ENCRYPTED PASSWORDS IS STRONGLY ADVISED.</emphasis>
307                 </para>
308
309                 <sect3>
310                 <title>Advantages of Encrypted Passwords</title>
311
312                         <itemizedlist>
313                                 <listitem><para>Plain text passwords are not passed across 
314                                 the network. Someone using a network sniffer cannot just 
315                                 record passwords going to the SMB server.</para></listitem>
316
317                                 <listitem><para>Plain text passwords are not stored anywhere in
318                                 memory or on disk.</para></listitem>
319                          
320                                 <listitem><para>WinNT doesn't like talking to a server 
321                                 that does not support encrypted passwords. It will refuse 
322                                 to browse the server if the server is also in user level 
323                                 security mode. It will insist on prompting the user for the 
324                                 password on each connection, which is very annoying. The
325                                 only things you can do to stop this is to use SMB encryption.
326                                 </para></listitem>
327
328                                 <listitem><para>Encrypted password support allows automatic share
329                                 (resource) reconnects.</para></listitem>
330
331                                 <listitem><para>Encrypted passwords are essential for PDC/BDC
332                                 operation.</para></listitem>
333                         </itemizedlist>
334                 </sect3>
335
336
337                 <sect3>
338                 <title>Advantages of non-encrypted passwords</title>
339
340                         <itemizedlist>
341                                 <listitem><para>Plain text passwords are not kept 
342                                 on disk, and are NOT cached in memory. </para></listitem>
343                                 
344                                 <listitem><para>Uses same password file as other unix 
345                                 services such as login and ftp</para></listitem>
346                                 
347                                 <listitem><para>Use of other services (such as telnet and ftp) which
348                                 send plain text passwords over the net, so sending them for SMB
349                                 isn't such a big deal.</para></listitem>
350                         </itemizedlist>
351                 </sect3>
352         </sect2>
353
354         <sect2>
355         <title>Mapping User Identifiers between MS Windows and Unix</title>
356
357         <para>
358         Every operation in Unix/Linux requires a user identifier (UID), just as in
359         MS Windows NT4 / 200x this requires a Security Identifier (SID). Samba provides
360         two means for mapping an MS Windows user to a Unix/Linux UID.
361         </para>
362
363         <para>
364         Firstly, all Samba SAM (Security Account Management database) accounts require
365         a Unix/Linux UID that the account will map to. As users are added to the account
366         information database samba-3 will call the <parameter>add user script</parameter>
367         interface to add the account to the Samba host OS. In essence all accounts in
368         the local SAM require a local user account.
369         </para>
370
371         <para>
372         The second way to affect Windows SID to Unix UID mapping is via the
373         <emphasis>idmap uid, idmap gid</emphasis> parameters in &smb.conf;.
374         Please refer to the man page for information about these parameters.
375         These parameters are essential when mapping users from a remote SAM server.
376         </para>
377
378         </sect2>
379 </sect1>
380
381 <sect1>
382 <title>Account Management Tools</title>
383
384 <para>
385 Samba-3 provides two (2) tools for management of User and machine accounts. These tools are
386 called <filename>smbpasswd</filename> and <command>pdbedit</command>. A third tool is under
387 development but is NOT expected to ship in time for Samba-3.0.0. The new tool will be a TCL/TK
388 GUI tool that looks much like the MS Windows NT4 Domain User Manager - hopefully this will
389 be announced in time for samba-3.0.1 release timing.
390 </para>
391         <sect2>
392         <title>The <emphasis>smbpasswd</emphasis> Command</title>
393         
394                 <para>
395                 The smbpasswd utility is a utility similar to the <command>passwd</command>
396                 or <command>yppasswd</command> programs.  It maintains the two 32 byte password
397                 fields in the passdb backend.
398                 </para>
399
400                 <para>
401                 <command>smbpasswd</command> works in a client-server mode where it contacts the
402                 local smbd to change the user's password on its behalf.This has enormous benefits
403                 as follows:
404                 </para>
405
406                 <para>
407                 <command>smbpasswd</command> has the capability to change passwords on Windows NT
408                 servers (this only works when the request is sent to the NT Primary Domain Controller
409                 if changing an NT Domain user's password).
410                 </para>
411
412                 <para>
413                 <command>smbpasswd</command> can be used to:
414                 </para>
415                 
416                 <simplelist>
417                         <member><emphasis>add</emphasis> user or machine accounts</member>
418                         <member><emphasis>delete</emphasis> user or machine accounts</member>
419                         <member><emphasis>enable</emphasis> user or machine accounts</member>
420                         <member><emphasis>disable</emphasis> user or machine accounts</member>
421                         <member><emphasis>set to NULL</emphasis> user passwords</member>
422                         <member><emphasis>manage interdomain trust accounts</emphasis></member>
423                 </simplelist>
424                 
425                 <para>
426                 To run smbpasswd as a normal user just type:
427                 </para>
428                 
429                 <para>
430                 <screen>
431                 <prompt>$ </prompt><userinput>smbpasswd</userinput>
432                 <prompt>Old SMB password: </prompt><userinput><replaceable>secret</replaceable></userinput>
433                 </screen>
434                 For <replaceable>secret</replaceable> type old value here - or hit return if
435                 there was no old password
436                 <screen>
437                 <prompt>New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
438                 <prompt>Repeat New SMB Password: </prompt><userinput><replaceable>new secret</replaceable></userinput>
439                 </screen>
440                 </para>
441                 
442                 <para>
443                 If the old value does not match the current value stored for that user, or the two
444                 new values do not match each other, then the password will not be changed.
445                 </para>
446                 
447                 <para>
448                 When invoked by an ordinary user it will only allow change of their own
449                 SMB password.
450                 </para>
451                 
452                 <para>
453                 When run by root smbpasswd may take an optional argument, specifying
454                 the user name whose SMB password you wish to change. When run as root, smbpasswd
455                 does not prompt for or check the old password value, thus allowing root to set passwords 
456                 for users who have forgotten their passwords.
457                 </para>
458                 
459                 <para>
460                 <command>smbpasswd</command> is designed to work in the way familiar to UNIX
461                 users who use the <command>passwd</command> or <command>yppasswd</command> commands.
462                 While designed for administrative use, this tool provides essential user level
463                 password change capabilities.
464                 </para>
465
466                 <para>
467                 For more details on using <command>smbpasswd</command> refer to the man page (the
468                 definitive reference).
469                 </para>
470         </sect2>
471
472         <sect2>
473         <title>The <emphasis>pdbedit</emphasis> Command</title>
474
475                 <para>
476                 <command>pdbedit</command> is a tool that can be used only by root. It is used to
477                 manage the passdb backend. <command>pdbedit</command> can be used to:
478                 </para>
479
480                 <simplelist>
481                         <member>add, remove or modify user accounts</member>
482                         <member>listing user accounts</member>
483                         <member>migrate user accounts</member>
484                 </simplelist>
485
486                 <para>
487                 The <command>pdbedit</command> tool is the only one that can manage the account
488                 security and policy settings. It is capable of all operations that smbpasswd can
489                 do as well as a super set of them.
490                 </para>
491
492                 <para>
493                 One particularly important purpose of the <command>pdbedit</command> is to allow
494                 the migration of account information from one passdb backend to another. See the
495                 <link linkend="XMLpassdb">XML</link> password backend section of this chapter.
496                 </para>
497
498                 <para>
499                 The following is an example of the user account information that is stored in
500                 a tdbsam password backend. This listing was produced by running:
501                 </para>
502
503                 <screen>
504                 <prompt>$ </prompt><userinput>pdbedit -Lv met</userinput>
505                 Unix username:        met
506                 NT username:
507                 Account Flags:        [UX         ]
508                 User SID:             S-1-5-21-1449123459-1407424037-3116680435-2004
509                 Primary Group SID:    S-1-5-21-1449123459-1407424037-3116680435-1201
510                 Full Name:            Melissa E Terpstra
511                 Home Directory:       \\frodo\met\Win9Profile
512                 HomeDir Drive:        H:
513                 Logon Script:         scripts\logon.bat
514                 Profile Path:         \\frodo\Profiles\met
515                 Domain:               MIDEARTH
516                 Account desc:
517                 Workstations:         melbelle
518                 Munged dial:
519                 Logon time:           0
520                 Logoff time:          Mon, 18 Jan 2038 20:14:07 GMT
521                 Kickoff time:         Mon, 18 Jan 2038 20:14:07 GMT
522                 Password last set:    Sat, 14 Dec 2002 14:37:03 GMT
523                 Password can change:  Sat, 14 Dec 2002 14:37:03 GMT
524                 Password must change: Mon, 18 Jan 2038 20:14:07 GMT
525                 </screen>
526
527                 <!-- FIXME: Add note about migrating user accounts -->
528
529         </sect2>
530 </sect1>
531
532 <sect1>
533 <title>Password Backends</title>
534
535 <para>
536 Samba-3 offers the greatest flexibility in backend account database design of any SMB/CIFS server
537 technology available today. The flexibility is immediately obvious as one begins to explore this
538 capability.
539 </para>
540
541 <para>
542 It is possible to specify not only multiple different password backends, but even multiple
543 backends of the same type. For example, to use two different tdbsam databases:
544 </para>
545
546 <para>
547 <programlisting>
548 [globals]
549                 passdb backend = tdbsam:/etc/samba/passdb.tdb, \
550                 tdbsam:/etc/samba/old-passdb.tdb, guest
551 </programlisting>
552 </para>
553
554
555         <sect2>
556         <title>Plain Text</title>
557
558                 <para>
559                 Older versions of samba retrieved user information from the unix user database 
560                 and eventually some other fields from the file <filename>/etc/samba/smbpasswd</filename>
561                 or <filename>/etc/smbpasswd</filename>. When password encryption is disabled, no 
562                 SMB specific data is stored at all. Instead all operations are conduected via the way
563                 that the samba host OS will access it's <filename>/etc/passwd</filename> database.
564                 eg: On Linux systems that is done via PAM.
565                 </para>
566
567         </sect2>
568
569         <sect2>
570         <title>smbpasswd - Encrypted Password Database</title>
571
572                 <para>
573                 Traditionally, when configuring <ulink url="smb.conf.5.html#ENCRYPTPASSWORDS">"encrypt
574                 passwords = yes"</ulink> in Samba's <filename>smb.conf</filename> file, user account
575                 information such as username, LM/NT password hashes, password change times, and account
576                 flags have been stored in the <filename>smbpasswd(5)</filename> file.  There are several
577                 disadvantages to this approach for sites with very large numbers of users (counted
578                 in the thousands).
579                 </para>
580
581                 <itemizedlist>
582                 <listitem><para>
583                 The first is that all lookups must be performed sequentially.  Given that
584                 there are approximately two lookups per domain logon (one for a normal
585                 session connection such as when mapping a network drive or printer), this
586                 is a performance bottleneck for large sites.  What is needed is an indexed approach
587                 such as is used in databases.
588                 </para></listitem>
589
590                 <listitem><para>
591                 The second problem is that administrators who desire to replicate a smbpasswd file
592                 to more than one Samba server were left to use external tools such as
593                 <command>rsync(1)</command> and <command>ssh(1)</command> and wrote custom,
594                 in-house scripts.
595                 </para></listitem>
596
597                 <listitem><para>
598                 And finally, the amount of information which is stored in an smbpasswd entry leaves
599                 no room for additional attributes such as a home directory, password expiration time,
600                 or even a Relative Identified (RID).
601                 </para></listitem>
602                 </itemizedlist>
603
604                 <para>
605                 As a result of these defeciencies, a more robust means of storing user attributes
606                 used by smbd was developed.  The API which defines access to user accounts
607                 is commonly referred to as the samdb interface (previously this was called the passdb
608                 API, and is still so named in the Samba CVS trees). 
609                 </para>
610
611                 <para>
612                 Samba-3 provides an enhanced set of passdb backends that overcome the deficiencies
613                 of the smbpasswd plain text database. These are tdbsam, ldapsam, and xmlsam.
614                 Of these ldapsam will be of most interest to large corporate or enterprise sites.
615                 </para>
616
617         </sect2>
618
619         <sect2>
620         <title>tdbsam</title>
621
622                 <para>Samba can store user and machine account data in a "TDB" (Trivial Database).
623                 Using this backend doesn't require any additional configuration. This backend is
624                 recommended for new installations that do not require LDAP.
625                 </para>
626
627                 <para>
628                 As a general guide the Samba-Team do NOT recommend using the tdbsam backend for sites
629                 that have 250 or more users. Additionally, tdbsam is not capable of scaling for use
630                 in sites that require PDB/BDC implmentations that requires replication of the account
631                 database. Clearly, for reason of scalability the use of ldapsam should be encouraged.
632                 </para>
633
634         </sect2>
635
636         <sect2>
637         <title>ldapsam</title>
638
639                 <para>
640                 There are a few points to stress that the ldapsam does not provide. The LDAP
641                 support referred to in the this documentation does not include:
642                 </para>
643
644                 <itemizedlist>
645                         <listitem><para>A means of retrieving user account information from
646                         an Windows 200x Active Directory server.</para></listitem>
647                         <listitem><para>A means of replacing /etc/passwd.</para></listitem>
648                 </itemizedlist>
649
650                 <para>
651                 The second item can be accomplished by using LDAP NSS and PAM modules.  LGPL
652                 versions of these libraries can be obtained from PADL Software
653                 (<ulink url="http://www.padl.com/">http://www.padl.com/</ulink>). More
654                 information about the configuration of these packages may be found at "LDAP,
655                 System Administration; Gerald Carter, O'Reilly; Chapter 6: Replacing NIS".
656                 Refer to <ulink url="http://safari.oreilly.com/?XmlId=1-56592-491-6">
657                 http://safari.oreilly.com/?XmlId=1-56592-491-6</ulink> for those who might wish to know
658                 more about configuration and adminstration of an OpenLDAP server.
659                 </para>
660
661                 <para>
662                 This document describes how to use an LDAP directory for storing Samba user
663                 account information traditionally stored in the smbpasswd(5) file.  It is
664                 assumed that the reader already has a basic understanding of LDAP concepts
665                 and has a working directory server already installed.  For more information
666                 on LDAP architectures and Directories, please refer to the following sites.
667                 </para>
668
669                 <itemizedlist>
670                         <listitem><para>OpenLDAP - <ulink url="http://www.openldap.org/">http://www.openldap.org/</ulink></para></listitem>
671                         <listitem><para>iPlanet Directory Server -
672                          <ulink url="http://iplanet.netscape.com/directory">http://iplanet.netscape.com/directory</ulink></para></listitem>
673                 </itemizedlist>
674
675                 <para>
676                 Two additional Samba resources which may prove to be helpful are
677                 </para>
678
679                 <itemizedlist>
680                         <listitem><para>The <ulink url="http://www.unav.es/cti/ldap-smb/ldap-smb-3-howto.html">Samba-PDC-LDAP-HOWTO</ulink>
681                         maintained by Ignacio Coupeau.</para></listitem>
682
683                         <listitem><para>The NT migration scripts from <ulink url="http://samba.idealx.org/">IDEALX</ulink> that are
684                         geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
685                         </para></listitem>
686                 </itemizedlist>
687
688                 <sect3>
689                 <title>Supported LDAP Servers</title>
690
691                         <para>
692                         The LDAP ldapsam code has been developed and tested using the OpenLDAP 2.0 and 2.1 server and
693                         client libraries.  The same code should work with Netscape's Directory Server and client SDK.
694                         However, there are bound to be compile errors and bugs. These should not be hard to fix.
695                         Please submit fixes via <link linkend="bugreport">Bug reporting facility</link>.
696                         </para>
697
698                 </sect3>
699
700                 <sect3>
701                 <title>Schema and Relationship to the RFC 2307 posixAccount</title>
702
703
704                         <para>
705                         Samba 3.0 includes the necessary schema file for OpenLDAP 2.0 in
706                         <filename>examples/LDAP/samba.schema</filename>.  The sambaAccount objectclass is given here:
707                         </para>
708
709 <para>
710 <programlisting>
711 objectclass ( 1.3.6.1.4.1.7165.2.2.3 NAME 'sambaAccount' SUP top AUXILIARY
712     DESC 'Samba Auxilary Account'
713     MUST ( uid $ rid )
714     MAY  ( cn $ lmPassword $ ntPassword $ pwdLastSet $ logonTime $
715            logoffTime $ kickoffTime $ pwdCanChange $ pwdMustChange $ acctFlags $
716            displayName $ smbHome $ homeDrive $ scriptPath $ profilePath $
717            description $ userWorkstations $ primaryGroupID $ domain ))
718 </programlisting>
719 </para>
720
721                         <para>
722                         The <filename>samba.schema</filename> file has been formatted for OpenLDAP 2.0/2.1.
723                         The OID's are owned by the Samba Team and as such is legal to be openly published.
724                         If you translate the schema to be used with Netscape DS, please
725                         submit the modified schema file as a patch to
726                         <ulink url="mailto:jerry@samba.org">jerry@samba.org</ulink>.
727                         </para>
728
729                         <para>
730                         Just as the smbpasswd file is meant to store information which supplements a
731                         user's <filename>/etc/passwd</filename> entry, so is the sambaAccount object
732                         meant to supplement the UNIX user account information.  A sambaAccount is a
733                         <constant>STRUCTURAL</constant> objectclass so it can be stored individually
734                         in the directory.  However, there are several fields (e.g. uid) which overlap
735                         with the posixAccount objectclass outlined in RFC2307.  This is by design.
736                         </para>
737
738                         <!--olem: we should perhaps have a note about shadowAccounts too as many
739                         systems use them, isn'it ? -->
740
741                         <para>
742                         In order to store all user account information (UNIX and Samba) in the directory,
743                         it is necessary to use the sambaAccount and posixAccount objectclasses in
744                         combination.  However, smbd will still obtain the user's UNIX account
745                         information via the standard C library calls (e.g. getpwnam(), et. al.).
746                         This means that the Samba server must also have the LDAP NSS library installed
747                         and functioning correctly.  This division of information makes it possible to
748                         store all Samba account information in LDAP, but still maintain UNIX account
749                         information in NIS while the network is transitioning to a full LDAP infrastructure.
750                         </para>
751                 </sect3>
752
753                 <sect3>
754                 <title>OpenLDAP configuration</title>
755
756                         <para>
757                         To include support for the sambaAccount object in an OpenLDAP directory
758                         server, first copy the samba.schema file to slapd's configuration directory.
759                         The samba.schema file can be found in the directory <filename>examples/LDAP</filename>
760                         in the samba source distribution.
761                         </para>
762
763 <para>
764 <screen>
765 &rootprompt;<userinput>cp samba.schema /etc/openldap/schema/</userinput>
766 </screen>
767 </para>
768
769                         <para>
770                         Next, include the <filename>samba.schema</filename> file in <filename>slapd.conf</filename>.
771                         The sambaAccount object contains two attributes which depend upon other schema
772                         files.  The 'uid' attribute is defined in <filename>cosine.schema</filename> and
773                         the 'displayName' attribute is defined in the <filename>inetorgperson.schema</filename>
774                         file.  Both of these must be included before the <filename>samba.schema</filename> file.
775                         </para>
776
777 <para>
778 <programlisting>
779 ## /etc/openldap/slapd.conf
780
781 ## schema files (core.schema is required by default)
782 include            /etc/openldap/schema/core.schema
783
784 ## needed for sambaAccount
785 include            /etc/openldap/schema/cosine.schema
786 include            /etc/openldap/schema/inetorgperson.schema
787 include            /etc/openldap/schema/samba.schema
788 include            /etc/openldap/schema/nis.schema
789 ....
790 </programlisting>
791 </para>
792
793                 <para>
794                 It is recommended that you maintain some indices on some of the most usefull attributes,
795                 like in the following example, to speed up searches made on sambaAccount objectclasses
796                 (and possibly posixAccount and posixGroup as well).
797                 </para>
798
799 <para>
800 <screen>
801 # Indices to maintain
802 ## required by OpenLDAP
803 index objectclass             eq
804
805 index cn                      pres,sub,eq
806 index sn                      pres,sub,eq
807 ## required to support pdb_getsampwnam
808 index uid                     pres,sub,eq
809 ## required to support pdb_getsambapwrid()
810 index displayName             pres,sub,eq
811
812 ## uncomment these if you are storing posixAccount and
813 ## posixGroup entries in the directory as well
814 ##index uidNumber               eq
815 ##index gidNumber               eq
816 ##index memberUid               eq
817
818 index   sambaSID              eq
819 index   sambaPrimaryGroupSID  eq
820 index   sambaDomainName       eq
821 index   default               sub
822 </screen>
823 </para>
824
825                 <para>
826                 Create the new index by executing:
827                 </para>
828
829 <para>
830 <screen>
831 ./sbin/slapindex -f slapd.conf
832 </screen>
833 </para>
834
835                 <para>
836                 Remember to restart slapd after making these changes:
837                 </para>
838
839 <para>
840 <screen>
841 &rootprompt;<userinput>/etc/init.d/slapd restart</userinput>
842 </screen>
843 </para>
844
845                 </sect3>
846
847                 <sect3>
848                 <title>Initialise the LDAP database</title>
849
850                 <para>
851                 Before you can add accounts to the LDAP database you must create the account containers
852                 that they will be stored in. The following LDIF file should be modified to match your
853                 needs (ie: Your DNS entries, etc.).
854                 </para>
855                 
856 <para>
857 <screen>
858 # Organization for Samba Base
859 dn: dc=plainjoe,dc=org
860 objectclass: dbObject
861 objectclass: organization
862 dc: plainjoe
863 o: Terpstra Org Network
864 description: The Samba-3 Network LDAP Example
865
866 # Organizational Role for Directory Management
867 db: cn=Manager,dc=plainjoe,dc=org
868 objectclass: organizationalRole
869 cn: Manager
870 description: Directory Manager
871
872 # Setting up container for users
873 dn: ou=People,dc=plainjoe,dc=org
874 objectclass: top
875 objectclass: organizationalUnit
876 ou: People
877
878 # Setting up admin handle for People OU
879 dn: cn=admin,ou=People,dc=plainjoe,dc=org
880 cn: admin
881 objectclass: top
882 objectclass: organizationalRole
883 objectclass: simpleSecurityObject
884 userPassword: {SSHA}c3ZM9tBaBo9autm1dL3waDS21+JSfQVz
885 </screen>
886 </para>
887
888                 <para>
889                 The userPassword shown above should be generated using <command>slappasswd</command>.
890                 </para>
891
892                 <para>
893                 The following command will then load the contents of the LDIF file into the LDAP
894                 database.
895                 </para>
896
897 <para>
898 <screen>
899 <prompt>$ </prompt><userinput>slapadd -v -l initldap.dif</userinput>
900 </screen>
901 </para>
902
903                 <para>
904                 Do not forget to secure your LDAP server with an adequate access control list,
905                 as well as an admin password.
906                 </para>
907
908                 <note>
909                 <para>
910                 Before Samba can access the LDAP server you need to stoe the LDAP admin password
911                 into the Samba-3 <filename>secrets.tdb</filename> database by:
912                 <screen>
913 &rootprompt; <userinput>smbpasswd -w <replaceable>secret</replaceable></userinput>
914                 </screen>
915                 </para>
916                 </note>
917
918                 </sect3>
919
920                 <sect3>
921                 <title>Configuring Samba</title>
922
923                         <para>
924                         The following parameters are available in smb.conf only if your
925                         version of samba was built with LDAP support. Samba automatically builds with LDAP support if the
926                         LDAP libraries are found.
927                         </para>
928
929                 <itemizedlist>
930                         <listitem><para><ulink url="smb.conf.5.html#PASSDBBACKEND">passdb backend = ldapsam:url</ulink></para></listitem>
931                         <listitem><para><ulink url="smb.conf.5.html#LDAPSSL">ldap ssl</ulink></para></listitem>
932                         <listitem><para><ulink url="smb.conf.5.html#LDAPADMINDN">ldap admin dn</ulink></para></listitem>
933                         <listitem><para><ulink url="smb.conf.5.html#LDAPSUFFIX">ldap suffix</ulink></para></listitem>
934                         <listitem><para><ulink url="smb.conf.5.html#LDAPFILTER">ldap filter</ulink></para></listitem>
935                         <listitem><para><ulink url="smb.conf.5.html#LDAPMACHINSUFFIX">ldap machine suffix</ulink></para></listitem>
936                         <listitem><para><ulink url="smb.conf.5.html#LDAPUSERSUFFIX">ldap user suffix</ulink></para></listitem>
937                         <listitem><para><ulink url="smb.conf.5.html#LDAPDELETEDN">ldap delete dn</ulink></para></listitem>
938                         <listitem><para><ulink url="smb.conf.5.html#LDAPPASSWDSYNC">ldap passwd sync</ulink></para></listitem>
939                         <listitem><para><ulink url="smb.conf.5.html#LDAPTRUSTIDS">ldap trust ids</ulink></para></listitem>
940
941                 </itemizedlist>
942
943                         <para>
944                         These are described in the &smb.conf; man
945                         page and so will not be repeated here.  However, a sample smb.conf file for
946                         use with an LDAP directory could appear as
947                         </para>
948
949 <para>
950 <programlisting>
951 ## /usr/local/samba/lib/smb.conf
952 [global]
953      security = user
954      encrypt passwords = yes
955
956      netbios name = TASHTEGO
957      workgroup = NARNIA
958
959      # ldap related parameters
960
961      # define the DN to use when binding to the directory servers
962      # The password for this DN is not stored in smb.conf.  Rather it
963      # must be set by using 'smbpasswd -w <replaceable>secretpw</replaceable>' to store the
964      # passphrase in the secrets.tdb file.  If the "ldap admin dn" values
965      # change, this password will need to be reset.
966      ldap admin dn = "cn=Samba Manager,ou=people,dc=samba,dc=org"
967
968      # Define the SSL option when connecting to the directory
969      # ('off', 'start tls', or 'on' (default))
970      ldap ssl = start tls
971
972      # syntax: passdb backend = ldapsam:ldap://server-name[:port]
973      passdb backend = ldapsam:ldap://funball.samba.org, guest
974
975      # smbpasswd -x delete the entire dn-entry
976      ldap delete dn = no
977
978      # the machine and user suffix added to the base suffix
979      # wrote WITHOUT quotes. NULL siffixes by default
980      ldap user suffix = ou=People
981      ldap machine suffix = ou=Systems
982
983      # Trust unix account information in LDAP
984      #  (see the smb.conf manpage for details)
985      ldap trust ids = Yes
986
987      # specify the base DN to use when searching the directory
988      ldap suffix = "ou=people,dc=samba,dc=org"
989
990      # generally the default ldap search filter is ok
991      # ldap filter = "(&amp;(uid=%u)(objectclass=sambaAccount))"
992 </programlisting>
993 </para>
994
995                 </sect3>
996
997                 <sect3>
998                 <title>Accounts and Groups management</title>
999
1000                         <para>
1001                         As users accounts are managed thru the sambaAccount objectclass, you should
1002                         modify your existing administration tools to deal with sambaAccount attributes.
1003                         </para>
1004
1005                         <para>
1006                         Machines accounts are managed with the sambaAccount objectclass, just
1007                         like users accounts. However, it's up to you to store thoses accounts
1008                         in a different tree of your LDAP namespace: you should use
1009                         "ou=Groups,dc=plainjoe,dc=org" to store groups and
1010                         "ou=People,dc=plainjoe,dc=org" to store users. Just configure your
1011                         NSS and PAM accordingly (usually, in the /etc/ldap.conf configuration
1012                         file).
1013                         </para>
1014
1015                         <para>
1016                         In Samba release 3.0, the group management system is based on posix
1017                         groups. This means that Samba makes usage of the posixGroup objectclass.
1018                         For now, there is no NT-like group system management (global and local
1019                         groups).
1020                         </para>
1021
1022                 </sect3>
1023
1024                 <sect3>
1025                 <title>Security and sambaAccount</title>
1026
1027
1028                         <para>
1029                         There are two important points to remember when discussing the security
1030                         of sambaAccount entries in the directory.
1031                         </para>
1032
1033                         <itemizedlist>
1034                                 <listitem><para><emphasis>Never</emphasis> retrieve the lmPassword or
1035                                 ntPassword attribute values over an unencrypted LDAP session.</para></listitem>
1036                                 <listitem><para><emphasis>Never</emphasis> allow non-admin users to
1037                                 view the lmPassword or ntPassword attribute values.</para></listitem>
1038                         </itemizedlist>
1039
1040                         <para>
1041                         These password hashes are clear text equivalents and can be used to impersonate
1042                         the user without deriving the original clear text strings.  For more information
1043                         on the details of LM/NT password hashes, refer to the
1044                         <link linkend="passdb">Account Information Database</link> section of this chapter.
1045                         </para>
1046
1047                         <para>
1048                         To remedy the first security issue, the "ldap ssl" smb.conf parameter defaults
1049                         to require an encrypted session (<parameter>ldap ssl = on</parameter>) using
1050                         the default port of <constant>636</constant>
1051                         when contacting the directory server.  When using an OpenLDAP server, it
1052                         is possible to use the use the StartTLS LDAP extended  operation in the place of
1053                         LDAPS.  In either case, you are strongly discouraged to disable this security
1054                         (<parameter>ldap ssl = off</parameter>).
1055                         </para>
1056
1057                         <para>
1058                         Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
1059                         extended operation.  However, the OpenLDAP library still provides support for
1060                         the older method of securing communication between clients and servers.
1061                         </para>
1062
1063                         <para>
1064                         The second security precaution is to prevent non-administrative users from
1065                         harvesting password hashes from the directory.  This can be done using the
1066                         following ACL in <filename>slapd.conf</filename>:
1067                         </para>
1068
1069 <para>
1070 <programlisting>
1071 ## allow the "ldap admin dn" access, but deny everyone else
1072 access to attrs=lmPassword,ntPassword
1073      by dn="cn=Samba Admin,ou=people,dc=plainjoe,dc=org" write
1074      by * none
1075 </programlisting>
1076 </para>
1077
1078                 </sect3>
1079
1080                 <sect3>
1081                 <title>LDAP special attributes for sambaAccounts</title>
1082
1083                         <para>
1084                         The sambaAccount objectclass is composed of the following attributes:
1085                         </para>
1086
1087                         <para>
1088                         <table frame="all">
1089                                 <title>Attributes in the sambaAccount objectclass (LDAP)</title>
1090                         <tgroup cols="2" align="left">
1091                         <tbody>
1092                                 <row><entry><constant>lmPassword</constant></entry><entry>the LANMAN password 16-byte hash stored as a character
1093                                                 representation of a hexidecimal string.</entry></row>
1094                                 <row><entry><constant>ntPassword</constant></entry><entry>the NT password hash 16-byte stored as a character
1095                                                 representation of a hexidecimal string.</entry></row>
1096                                 <row><entry><constant>pwdLastSet</constant></entry><entry>The integer time in seconds since 1970 when the
1097                                 <constant>lmPassword</constant> and <constant>ntPassword</constant> attributes were last set.
1098                                 </entry></row>
1099
1100                                 <row><entry><constant>acctFlags</constant></entry><entry>string of 11 characters surrounded by square brackets []
1101                                                 representing account flags such as U (user), W(workstation), X(no password expiration),
1102                                                 I(Domain trust account), H(Home dir required), S(Server trust account),
1103                                                 and D(disabled).</entry></row>
1104
1105                                 <row><entry><constant>logonTime</constant></entry><entry>Integer value currently unused</entry></row>
1106
1107                                 <row><entry><constant>logoffTime</constant></entry><entry>Integer value currently unused</entry></row>
1108
1109                                 <row><entry><constant>kickoffTime</constant></entry><entry>Integer value currently unused</entry></row>
1110
1111                                 <row><entry><constant>pwdCanChange</constant></entry><entry>Integer value currently unused</entry></row>
1112
1113                                 <row><entry><constant>pwdMustChange</constant></entry><entry>Integer value currently unused</entry></row>
1114
1115                                 <row><entry><constant>homeDrive</constant></entry><entry>specifies the drive letter to which to map the
1116                                 UNC path specified by homeDirectory. The drive letter must be specified in the form "X:"
1117                                 where X is the letter of the drive to map. Refer to the "logon drive" parameter in the
1118                                 smb.conf(5) man page for more information.</entry></row>
1119
1120                                 <row><entry><constant>scriptPath</constant></entry><entry>The scriptPath property specifies the path of
1121                                 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
1122                                 is relative to the netlogon share.  Refer to the "logon script" parameter in the
1123                                 smb.conf(5) man page for more information.</entry></row>
1124
1125                                 <row><entry><constant>profilePath</constant></entry><entry>specifies a path to the user's profile.
1126                                 This value can be a null string, a local absolute path, or a UNC path.  Refer to the
1127                                 "logon path" parameter in the smb.conf(5) man page for more information.</entry></row>
1128
1129                                 <row><entry><constant>smbHome</constant></entry><entry>The homeDirectory property specifies the path of
1130                                 the home directory for the user. The string can be null. If homeDrive is set and specifies
1131                                 a drive letter, homeDirectory should be a UNC path. The path must be a network
1132                                 UNC path of the form <filename>\\server\share\directory</filename>. This value can be a null string.
1133                                 Refer to the <command>logon home</command> parameter in the &smb.conf; man page for more information.
1134                                 </entry></row>
1135
1136                                 <row><entry><constant>userWorkstation</constant></entry><entry>character string value currently unused.
1137                                 </entry></row>
1138
1139                                 <row><entry><constant>rid</constant></entry><entry>the integer representation of the user's relative identifier
1140                                 (RID).</entry></row>
1141
1142                                 <row><entry><constant>primaryGroupID</constant></entry><entry>the relative identifier (RID) of the primary group
1143                                 of the user.</entry></row>
1144
1145                                 <row><entry><constant>domain</constant></entry><entry>domain the user is part of.</entry></row>
1146                         </tbody>
1147                         </tgroup></table>
1148                         </para>
1149
1150                         <para>
1151                         The majority of these parameters are only used when Samba is acting as a PDC of
1152                         a domain (refer to the <link linkend="samba-pdc">Samba as a primary domain controller</link> chapter for details on
1153                         how to configure Samba as a Primary Domain Controller). The following four attributes
1154                         are only stored with the sambaAccount entry if the values are non-default values:
1155                         </para>
1156
1157                         <simplelist>
1158                                 <member>smbHome</member>
1159                                 <member>scriptPath</member>
1160                                 <member>logonPath</member>
1161                                 <member>homeDrive</member>
1162                         </simplelist>
1163
1164                         <para>
1165                         These attributes are only stored with the sambaAccount entry if
1166                         the values are non-default values.  For example, assume TASHTEGO has now been
1167                         configured as a PDC and that <parameter>logon home = \\%L\%u</parameter> was defined in
1168                         its &smb.conf; file. When a user named "becky" logons to the domain,
1169                         the <parameter>logon home</parameter> string is expanded to \\TASHTEGO\becky.
1170                         If the smbHome attribute exists in the entry "uid=becky,ou=people,dc=samba,dc=org",
1171                         this value is used.  However, if this attribute does not exist, then the value
1172                         of the <parameter>logon home</parameter> parameter is used in its place.  Samba
1173                         will only write the attribute value to the directory entry if the value is
1174                         something other than the default (e.g. <filename>\\MOBY\becky</filename>).
1175                         </para>
1176
1177                 </sect3>
1178
1179                 <sect3>
1180                 <title>Example LDIF Entries for a sambaAccount</title>
1181
1182                         <para>
1183                         The following is a working LDIF with the inclusion of the posixAccount objectclass:
1184                         </para>
1185
1186         <para>
1187         <programlisting>
1188         dn: uid=guest2, ou=people,dc=plainjoe,dc=org
1189         ntPassword: 878D8014606CDA29677A44EFA1353FC7
1190         pwdMustChange: 2147483647
1191         primaryGroupID: 1201
1192         lmPassword: 552902031BEDE9EFAAD3B435B51404EE
1193         pwdLastSet: 1010179124
1194         logonTime: 0
1195         objectClass: sambaAccount
1196         uid: guest2
1197         kickoffTime: 2147483647
1198         acctFlags: [UX         ]
1199         logoffTime: 2147483647
1200         rid: 19006
1201         pwdCanChange: 0
1202         </programlisting>
1203         </para>
1204
1205                         <para>
1206                         The following is an LDIF entry for using both the sambaAccount and
1207                         posixAccount objectclasses:
1208                         </para>
1209
1210         <para>
1211         <programlisting>
1212         dn: uid=gcarter, ou=people,dc=plainjoe,dc=org
1213         logonTime: 0
1214         displayName: Gerald Carter
1215         lmPassword: 552902031BEDE9EFAAD3B435B51404EE
1216         primaryGroupID: 1201
1217         objectClass: posixAccount
1218         objectClass: sambaAccount
1219         acctFlags: [UX         ]
1220         userPassword: {crypt}BpM2ej8Rkzogo
1221         uid: gcarter
1222         uidNumber: 9000
1223         cn: Gerald Carter
1224         loginShell: /bin/bash
1225         logoffTime: 2147483647
1226         gidNumber: 100
1227         kickoffTime: 2147483647
1228         pwdLastSet: 1010179230
1229         rid: 19000
1230         homeDirectory: /home/tashtego/gcarter
1231         pwdCanChange: 0
1232         pwdMustChange: 2147483647
1233         ntPassword: 878D8014606CDA29677A44EFA1353FC7
1234 </programlisting>
1235         </para>
1236
1237                 </sect3>
1238
1239                 <sect3>
1240                 <title>Password synchronisation</title>
1241
1242                 <para>
1243                 Since version 3.0 samba can update the non-samba (LDAP) password stored with an account. When
1244                 using pam_ldap, this allows changing both unix and windows passwords at once.
1245                 </para>
1246
1247                 <para>The <parameter>ldap passwd sync</parameter> options can have the following values:</para>
1248
1249                 <variablelist>
1250                        <varlistentry>
1251                                <term>yes</term>
1252                                <listitem><para>When the user changes his password, update
1253                                                <constant>ntPassword</constant>, <constant>lmPassword</constant>
1254                                                and the <constant>password</constant> fields.</para></listitem>
1255                        </varlistentry>
1256
1257                        <varlistentry>
1258                                <term>no</term>
1259                                <listitem><para>Only update <constant>ntPassword</constant> and <constant>lmPassword</constant>.</para></listitem>
1260                        </varlistentry>
1261
1262                        <varlistentry>
1263                                <term>only</term>
1264                                <listitem><para>Only update the LDAP password and let the LDAP server worry
1265                                                about the other fields. This option is only available when
1266                                                the LDAP library supports LDAP_EXOP_X_MODIFY_PASSWD. </para></listitem>
1267                        </varlistentry>
1268                 </variablelist>
1269
1270                 <para>More information can be found in the <ulink url="smb.conf.5.html#LDAPPASSWDSYNC">smb.conf</ulink> manpage.
1271                 </para>
1272
1273                 </sect3>
1274
1275                 <sect3>
1276                 <title>ldap trust ids</title>
1277
1278                 <para>
1279                 LDAP Performance can be improved by using the <command>ldap trust ids</command> parameter.
1280                 See the <ulink url="smb.conf.5.html#LDAPTRUSTIDS">smb.conf</ulink> manpage for details.
1281                 </para>
1282
1283                 </sect3>
1284
1285         </sect2>
1286
1287         <sect2>
1288         <title>MySQL</title>
1289
1290         <para>
1291         Every so often someone will come along with a great new idea. Storing of user accounts in an
1292         SQL backend is one of them. Those who want to do this are in the best position to know what the
1293         specific benefits are to them. This may sound like a cop-out, but in truth we can not attempt
1294         to document every nitty little detail why certain things of marginal utility to the bulk of
1295         Samba users might make sense to the rest. In any case, the following instructions should help
1296         the determined SQL user to implement a working system.
1297         </para>
1298
1299                 <sect3>
1300                 <title>Creating the database</title>
1301
1302                         <para>
1303                         You either can set up your own table and specify the field names to pdb_mysql (see below
1304                         for the column names) or use the default table. The file <filename>examples/pdb/mysql/mysql.dump</filename> 
1305                         contains the correct queries to create the required tables. Use the command :
1306
1307                         <screen><prompt>$ </prompt><userinput>mysql -u<replaceable>username</replaceable> -h<replaceable>hostname</replaceable> -p<replaceable>password</replaceable> <replaceable>databasename</replaceable> &gt; <filename>/path/to/samba/examples/pdb/mysql/mysql.dump</filename></userinput></screen>
1308                         </para>
1309                 </sect3>
1310
1311                 <sect3>
1312                 <title>Configuring</title>
1313
1314                         <para>This plugin lacks some good documentation, but here is some short info:</para>
1315
1316                         <para>Add a the following to the <parameter>passdb backend</parameter> variable in your &smb.conf;:
1317                         <programlisting>
1318                         passdb backend = [other-plugins] mysql:identifier [other-plugins]
1319                         </programlisting>
1320                         </para>
1321
1322                         <para>The identifier can be any string you like, as long as it doesn't collide with 
1323                         the identifiers of other plugins or other instances of pdb_mysql. If you 
1324                         specify multiple pdb_mysql.so entries in <parameter>passdb backend</parameter>, you also need to 
1325                         use different identifiers!
1326                         </para>
1327
1328                         <para>
1329                                 Additional options can be given thru the &smb.conf; file in the <parameter>[global]</parameter> section.
1330                         </para>
1331
1332                 <para>
1333                         <table frame="all">
1334                                 <title>Basic smb.conf options for MySQL passdb backend</title>
1335                                 <tgroup cols="2" align="left">
1336                                 <thead>
1337                                         <row><entry>Field</entry><entry>Contents</entry></row>
1338                                 </thead>
1339                                 <tbody>
1340                                         <row><entry>identifier:mysql host</entry><entry>host name, defaults to 'localhost'</entry></row>
1341                                         <row><entry>identifier:mysql password</entry><entry></entry></row>
1342                                         <row><entry>identifier:mysql user</entry><entry>defaults to 'samba'</entry></row>
1343                                         <row><entry>identifier:mysql database</entry><entry>defaults to 'samba'</entry></row>
1344                                         <row><entry>identifier:mysql port</entry><entry>defaults to 3306</entry></row>
1345                                         <row><entry>identifier:table</entry><entry>Name of the table containing users</entry></row>
1346                                 </tbody>
1347                                 </tgroup>
1348                         </table>
1349                 </para>
1350
1351                         <warning>
1352                         <para>
1353                         Since the password for the mysql user is stored in the 
1354                         &smb.conf; file, you should make the the &smb.conf; file 
1355                         readable only to the user that runs samba. This is considered a security 
1356                         bug and will be fixed soon.
1357                         </para>
1358                         </warning>
1359
1360                         <para>Names of the columns in this table(I've added column types those columns should have first):</para>
1361
1362                 <para>
1363                         <table frame="all">
1364                                 <title>MySQL field names for MySQL passdb backend</title>
1365                                 <tgroup cols="3" align="left">
1366                         <thead>         
1367                                 <row><entry>Field</entry><entry>Type</entry><entry>Contents</entry></row>
1368                         </thead>
1369                         <tbody>
1370                                 <row><entry>identifier:logon time column</entry><entry>int(9)</entry><entry></entry></row>
1371                                 <row><entry>identifier:logoff time column</entry><entry>int(9)</entry><entry></entry></row>
1372                                 <row><entry>identifier:kickoff time column</entry><entry>int(9)</entry><entry></entry></row>
1373                                 <row><entry>identifier:pass last set time column</entry><entry>int(9)</entry><entry></entry></row>
1374                                 <row><entry>identifier:pass can change time column</entry><entry>int(9)</entry><entry></entry></row>
1375                                 <row><entry>identifier:pass must change time column</entry><entry>int(9)</entry><entry></entry></row>
1376                                 <row><entry>identifier:username column</entry><entry>varchar(255)</entry><entry>unix username</entry></row>
1377                                 <row><entry>identifier:domain column</entry><entry>varchar(255)</entry><entry>NT domain user is part of</entry></row>
1378                                 <row><entry>identifier:nt username column</entry><entry>varchar(255)</entry><entry>NT username</entry></row>
1379                                 <row><entry>identifier:fullname column</entry><entry>varchar(255)</entry><entry>Full name of user</entry></row>
1380                                 <row><entry>identifier:home dir column</entry><entry>varchar(255)</entry><entry>Unix homedir path</entry></row>
1381                                 <row><entry>identifier:dir drive column</entry><entry>varchar(2)</entry><entry>Directory drive path (eg: 'H:')</entry></row>
1382                                 <row><entry>identifier:logon script column</entry><entry>varchar(255)</entry><entry>Batch file to run on client side when logging on</entry></row>
1383                                 <row><entry>identifier:profile path column</entry><entry>varchar(255)</entry><entry>Path of profile</entry></row>
1384                                 <row><entry>identifier:acct desc column</entry><entry>varchar(255)</entry><entry>Some ASCII NT user data</entry></row>
1385                                 <row><entry>identifier:workstations column</entry><entry>varchar(255)</entry><entry>Workstations user can logon to (or NULL for all)</entry></row>
1386                                 <row><entry>identifier:unknown string column</entry><entry>varchar(255)</entry><entry>unknown string</entry></row>
1387                                 <row><entry>identifier:munged dial column</entry><entry>varchar(255)</entry><entry>?</entry></row>
1388                                 <row><entry>identifier:user sid column</entry><entry>varchar(255)</entry><entry>NT user SID</entry></row>
1389                                 <row><entry>identifier:group sid column</entry><entry>varchar(255)</entry><entry>NT group ID</entry></row>
1390                                 <row><entry>identifier:lanman pass column</entry><entry>varchar(255)</entry><entry>encrypted lanman password</entry></row>
1391                                 <row><entry>identifier:nt pass column</entry><entry>varchar(255)</entry><entry>encrypted nt passwd</entry></row>
1392                                 <row><entry>identifier:plain pass column</entry><entry>varchar(255)</entry><entry>plaintext password</entry></row>
1393                                 <row><entry>identifier:acct control column</entry><entry>int(9)</entry><entry>nt user data</entry></row>
1394                                 <row><entry>identifier:unknown 3 column</entry><entry>int(9)</entry><entry>unknown</entry></row>
1395                                 <row><entry>identifier:logon divs column</entry><entry>int(9)</entry><entry>?</entry></row>
1396                                 <row><entry>identifier:hours len column</entry><entry>int(9)</entry><entry>?</entry></row>
1397                                 <row><entry>identifier:unknown 5 column</entry><entry>int(9)</entry><entry>unknown</entry></row>
1398                                 <row><entry>identifier:unknown 6 column</entry><entry>int(9)</entry><entry>unknown</entry></row>
1399                         </tbody></tgroup>
1400                 </table>
1401                 </para>
1402
1403                         <para>
1404                         Eventually, you can put a colon (:) after the name of each column, which 
1405                         should specify the column to update when updating the table. You can also
1406                         specify nothing behind the colon - then the data from the field will not be 
1407                         updated. 
1408                         </para>
1409
1410                 </sect3>
1411
1412                 <sect3>
1413                 <title>Using plaintext passwords or encrypted password</title>
1414
1415                         <para>
1416                         I strongly discourage the use of plaintext passwords, however, you can use them:
1417                         </para>
1418
1419                         <para>
1420                         If you would like to use plaintext passwords, set
1421                         'identifier:lanman pass column' and 'identifier:nt pass column' to
1422                         'NULL' (without the quotes) and 'identifier:plain pass column' to the
1423                         name of the column containing the plaintext passwords. 
1424                         </para>
1425
1426                         <para>
1427                         If you use encrypted passwords, set the 'identifier:plain pass
1428                         column' to 'NULL' (without the quotes). This is the default.
1429                         </para>
1430
1431                 </sect3>
1432
1433                 <sect3>
1434                 <title>Getting non-column data from the table</title>
1435
1436                         <para>
1437                         It is possible to have not all data in the database and making some 'constant'.
1438                         </para>
1439
1440                         <para>
1441                         For example, you can set 'identifier:fullname column' to : 
1442                         <command>CONCAT(First_name,' ',Sur_name)</command>
1443                         </para>
1444
1445                         <para>
1446                         Or, set 'identifier:workstations column' to :
1447                         <command>NULL</command></para>
1448
1449                         <para>See the MySQL documentation for more language constructs.</para>
1450
1451                 </sect3>
1452         </sect2>
1453
1454         <sect2 id="XMLpassdb">
1455         <title>XML</title>
1456
1457                 <para>This module requires libxml2 to be installed.</para>
1458
1459                 <para>The usage of pdb_xml is pretty straightforward. To export data, use:
1460                 </para>
1461
1462                 <para>
1463                         <prompt>$ </prompt><userinput>pdbedit -e xml:filename</userinput>
1464                 </para>
1465
1466                 <para>
1467                 (where filename is the name of the file to put the data in)
1468                 </para>
1469
1470                 <para>
1471                 To import data, use:
1472                 <prompt>$ </prompt><userinput>pdbedit -i xml:filename</userinput>
1473                 </para>
1474         </sect2>
1475 </sect1>
1476
1477 <sect1>
1478 <title>Common Errors</title>
1479
1480         <sect2>
1481         <title>Users can not logon - Users not in Samba SAM</title>
1482
1483         <para>
1484         People forget to put their users in their backend and then complain samba won't authorize them.
1485         </para>
1486
1487         </sect2>
1488
1489         <sect2>
1490         <title>Users are being added to the wrong backend database</title>
1491
1492         <para>
1493         A few complaints have been recieved from users that just moved to samba-3. The following
1494         &smb.conf; file entries were causing problems, new accounts were being added to the old
1495         smbpasswd file, not to the tdbsam passdb.tdb file:
1496         </para>
1497
1498         <para>
1499         <programlisting>
1500         [globals]
1501                 ...
1502                 passdb backend = smbpasswd, tdbsam, guest
1503                 ...
1504         </programlisting>
1505         </para>
1506
1507         <para>
1508         Samba will add new accounts to the first entry in the <emphasis>passdb backend</emphasis>
1509         parameter entry. If you want to update to the tdbsam, then change the entry to:
1510         </para>
1511
1512         <para>
1513         <programlisting>
1514         [globals]
1515                 ...
1516                 passdb backend = tdbsam, smbpasswd, guest
1517                 ...
1518         </programlisting>
1519         </para>
1520
1521         </sect2>
1522
1523         <sect2>
1524         <title>auth methods does not work</title>
1525
1526         <para>
1527         If you explicitly set an 'auth methods' parameter, guest must be specified as the first
1528         entry on the line. Eg: <parameter>auth methods = guest sam</parameter>.
1529         </para>
1530
1531         <para>
1532         This is the exact opposite of the requirement for the <parameter>passdb backed</parameter>
1533         option, where it must be the <emphasis>LAST</emphasis> parameter on the line.
1534         </para>
1535
1536         </sect2>
1537
1538 </sect1>
1539
1540 </chapter>