Merge over Alexanders' conversion to XML
[Samba/gebeck_regimport.git] / docs / docbook / projdoc / passdb.sgml
blob422cf7b7e7fa689a92411c21d4081dfab7923c38
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>
15 <pubdate>February 2003</pubdate>
16 </chapterinfo>
18 <title>User information database</title>
20 <sect1>
21 <title>Introduction</title>
23 <para>Old windows clients send plain text passwords over the wire.
24 Samba can check these passwords by crypting them and comparing them
25 to the hash stored in the unix user database.
26 </para>
28 <para>
29 Newer windows clients send encrypted passwords (so-called
30 Lanman and NT hashes) over
31 the wire, instead of plain text passwords. The newest clients
32 will only send encrypted passwords and refuse to send plain text
33 passwords, unless their registry is tweaked.
34 </para>
36 <para>These passwords can't be converted to unix style encrypted
37 passwords. Because of that you can't use the standard unix
38 user database, and you have to store the Lanman and NT hashes
39 somewhere else. </para>
41 <para>Next to a differently encrypted passwords,
42 windows also stores certain data for each user
43 that is not stored in a unix user database, e.g.
44 workstations the user may logon from, the location where his/her
45 profile is stored, etc.
46 Samba retrieves and stores this information using a "passdb backend".
47 Commonly
48 available backends are LDAP, plain text file, MySQL and nisplus.
49 For more information, see the documentation about the
50 <command>passdb backend = </command> parameter.
51 </para>
52 </sect1>
54 <sect1>
55 <title>Important Notes About Security</title>
57 <para>The unix and SMB password encryption techniques seem similar
58 on the surface. This similarity is, however, only skin deep. The unix
59 scheme typically sends clear text passwords over the network when
60 logging in. This is bad. The SMB encryption scheme never sends the
61 cleartext password over the network but it does store the 16 byte
62 hashed values on disk. This is also bad. Why? Because the 16 byte hashed
63 values are a "password equivalent". You cannot derive the user's
64 password from them, but they could potentially be used in a modified
65 client to gain access to a server. This would require considerable
66 technical knowledge on behalf of the attacker but is perfectly possible.
67 You should thus treat the data stored in whatever
68 passdb backend you use (smbpasswd file, ldap, mysql) as though it contained the
69 cleartext passwords of all your users. Its contents must be kept
70 secret, and the file should be protected accordingly.</para>
72 <para>Ideally we would like a password scheme which neither requires
73 plain text passwords on the net or on disk. Unfortunately this
74 is not available as Samba is stuck with being compatible with
75 other SMB systems (WinNT, WfWg, Win95 etc). </para>
77 <warning>
78 <para>Note that Windows NT 4.0 Service pack 3 changed the
79 default for permissible authentication so that plaintext
80 passwords are <emphasis>never</emphasis> sent over the wire.
81 The solution to this is either to switch to encrypted passwords
82 with Samba or edit the Windows NT registry to re-enable plaintext
83 passwords. See the document WinNT.txt for details on how to do
84 this.</para>
86 <para>Other Microsoft operating systems which also exhibit
87 this behavior includes</para>
89 <para> These versions of MS Windows do not support full domain
90 security protocols, although they may log onto a domain environment.
91 Of these Only MS Windows XP Home does NOT support domain logons.</para>
93 <simplelist>
94 <member>MS DOS Network client 3.0 with
95 the basic network redirector installed</member>
97 <member>Windows 95 with the network redirector
98 update installed</member>
100 <member>Windows 98 [se]</member>
102 <member>Windows Me</member>
104 <member>Windows XP Home</member>
105 </simplelist>
107 <para> The following versions of MS Windows fully support domain
108 security protocols.</para>
110 <simplelist>
111 <member>Windows NT 3.5x</member>
112 <member>Windows NT 4.0</member>
113 <member>Windows 2000 Professional</member>
114 <member>Windows 200x Server/Advanced Server</member>
115 <member>Windows XP Professional</member>
116 </simplelist>
117 </warning>
119 <note><para>All current release of
120 Microsoft SMB/CIFS clients support authentication via the
121 SMB Challenge/Response mechanism described here. Enabling
122 clear text authentication does not disable the ability
123 of the client to participate in encrypted authentication.</para></note>
125 <para>MS Windows clients will cache the encrypted password alone.
126 Even when plain text passwords are re-enabled, through the appropriate
127 registry change, the plain text password is NEVER cached. This means that
128 in the event that a network connections should become disconnected (broken)
129 only the cached (encrypted) password will be sent to the resource server
130 to affect a auto-reconnect. If the resource server does not support encrypted
131 passwords the auto-reconnect will fail. <emphasis>USE OF ENCRYPTED PASSWORDS
132 IS STRONGLY ADVISED.</emphasis></para>
134 <sect2>
135 <title>Advantages of SMB Encryption</title>
137 <simplelist>
138 <member>Plain text passwords are not passed across
139 the network. Someone using a network sniffer cannot just
140 record passwords going to the SMB server.</member>
142 <member>WinNT doesn't like talking to a server
143 that does not support encrypted passwords. It will refuse
144 to browse the server if the server is also in user level
145 security mode. It will insist on prompting the user for the
146 password on each connection, which is very annoying. The
147 only things you can do to stop this is to use SMB encryption.
148 </member>
150 <member>Encrypted password support allows automatic share
151 (resource) reconnects.</member>
152 </simplelist>
153 </sect2>
156 <sect2>
157 <title>Advantages of non-encrypted passwords</title>
159 <simplelist>
160 <member>Plain text passwords are not kept
161 on disk, and are NOT cached in memory. </member>
163 <member>Uses same password file as other unix
164 services such as login and ftp</member>
166 <member>Use of other services (such as telnet and ftp) which
167 send plain text passwords over the net, so sending them for SMB
168 isn't such a big deal.</member>
169 </simplelist>
170 </sect2>
171 </sect1>
174 <sect1>
175 <title>The smbpasswd Command</title>
177 <para>The smbpasswd utility is a utility similar to the
178 <command>passwd</command> or <command>yppasswd</command> programs.
179 It maintains the two 32 byte password fields in the passdb backend. </para>
181 <para><command>smbpasswd</command> works in a client-server mode
182 where it contacts the local smbd to change the user's password on its
183 behalf. This has enormous benefits - as follows.</para>
185 <para><command>smbpasswd</command> has the capability
186 to change passwords on Windows NT servers (this only works when
187 the request is sent to the NT Primary Domain Controller if you
188 are changing an NT Domain user's password).</para>
190 <para>To run smbpasswd as a normal user just type :</para>
192 <para><prompt>$ </prompt><userinput>smbpasswd</userinput></para>
193 <para><prompt>Old SMB password: </prompt><userinput>&lt;type old value here -
194 or hit return if there was no old password&gt;</userinput></para>
195 <para><prompt>New SMB Password: </prompt><userinput>&lt;type new value&gt;
196 </userinput></para>
197 <para><prompt>Repeat New SMB Password: </prompt><userinput>&lt;re-type new value
198 </userinput></para>
200 <para>If the old value does not match the current value stored for
201 that user, or the two new values do not match each other, then the
202 password will not be changed.</para>
204 <para>If invoked by an ordinary user it will only allow the user
205 to change his or her own Samba password.</para>
207 <para>If run by the root user smbpasswd may take an optional
208 argument, specifying the user name whose SMB password you wish to
209 change. Note that when run as root smbpasswd does not prompt for
210 or check the old password value, thus allowing root to set passwords
211 for users who have forgotten their passwords.</para>
213 <para><command>smbpasswd</command> is designed to work in the same way
214 and be familiar to UNIX users who use the <command>passwd</command> or
215 <command>yppasswd</command> commands.</para>
217 <para>For more details on using <command>smbpasswd</command> refer
218 to the man page which will always be the definitive reference.</para>
219 </sect1>
221 <!--
222 <sect1>
223 <title>The <command>pdbedit</command> command</title>
224 FIXME
225 </sect1>
228 <sect1>
229 <title>Plain text</title>
230 <para>
231 Older versions of samba retrieved user information from the unix user database
232 and eventually some other fields from the file <filename>/etc/samba/smbpasswd</filename>
233 or <filename>/etc/smbpasswd</filename>. When password encryption is disabled, no
234 data is stored at all.
235 </para>
236 </sect1>
238 <sect1>
239 <title>TDB</title>
240 <para>Samba can also store the user data in a "TDB" (Trivial Database). Using this backend
241 doesn't require any additional configuration. This backend is recommended for new installations that
242 don not require LDAP.
243 </para>
244 </sect1>
246 <sect1>
247 <title>LDAP</title>
249 <sect2>
250 <title>Introduction</title>
252 <para>
253 This document describes how to use an LDAP directory for storing Samba user
254 account information traditionally stored in the smbpasswd(5) file. It is
255 assumed that the reader already has a basic understanding of LDAP concepts
256 and has a working directory server already installed. For more information
257 on LDAP architectures and Directories, please refer to the following sites.
258 </para>
260 <itemizedlist>
261 <listitem><para>OpenLDAP - <ulink url="http://www.openldap.org/">http://www.openldap.org/</ulink></para></listitem>
262 <listitem><para>iPlanet Directory Server - <ulink url="http://iplanet.netscape.com/directory">http://iplanet.netscape.com/directory</ulink></para></listitem>
263 </itemizedlist>
265 <para>
266 Note that <ulink url="http://www.ora.com/">O'Reilly Publishing</ulink> is working on
267 a guide to LDAP for System Administrators which has a planned release date of
268 early summer, 2002.
269 </para>
271 <para>
272 Two additional Samba resources which may prove to be helpful are
273 </para>
275 <itemizedlist>
276 <listitem><para>The <ulink url="http://www.unav.es/cti/ldap-smb/ldap-smb-3-howto.html">Samba-PDC-LDAP-HOWTO</ulink>
277 maintained by Ignacio Coupeau.</para></listitem>
279 <listitem><para>The NT migration scripts from <ulink url="http://samba.idealx.org/">IDEALX</ulink> that are
280 geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
281 </para></listitem>
282 </itemizedlist>
284 </sect2>
286 <sect2>
287 <title>Encrypted Password Database</title>
289 <para>
290 Traditionally, when configuring <ulink url="smb.conf.5.html#ENCRYPTPASSWORDS">"encrypt
291 passwords = yes"</ulink> in Samba's <filename>smb.conf</filename> file, user account
292 information such as username, LM/NT password hashes, password change times, and account
293 flags have been stored in the <filename>smbpasswd(5)</filename> file. There are several
294 disadvantages to this approach for sites with very large numbers of users (counted
295 in the thousands).
296 </para>
298 <itemizedlist>
299 <listitem><para>
300 The first is that all lookups must be performed sequentially. Given that
301 there are approximately two lookups per domain logon (one for a normal
302 session connection such as when mapping a network drive or printer), this
303 is a performance bottleneck for large sites. What is needed is an indexed approach
304 such as is used in databases.
305 </para></listitem>
307 <listitem><para>
308 The second problem is that administrators who desired to replicate a
309 smbpasswd file to more than one Samba server were left to use external
310 tools such as <command>rsync(1)</command> and <command>ssh(1)</command>
311 and wrote custom, in-house scripts.
312 </para></listitem>
314 <listitem><para>
315 And finally, the amount of information which is stored in an
316 smbpasswd entry leaves no room for additional attributes such as
317 a home directory, password expiration time, or even a Relative
318 Identified (RID).
319 </para></listitem>
320 </itemizedlist>
322 <para>
323 As a result of these defeciencies, a more robust means of storing user attributes
324 used by smbd was developed. The API which defines access to user accounts
325 is commonly referred to as the samdb interface (previously this was called the passdb
326 API, and is still so named in the CVS trees).
327 </para>
329 <para>
330 There are a few points to stress about that the ldapsam
331 does not provide. The LDAP support referred to in the this documentation does not
332 include:
333 </para>
335 <itemizedlist>
336 <listitem><para>A means of retrieving user account information from
337 an Windows 2000 Active Directory server.</para></listitem>
338 <listitem><para>A means of replacing /etc/passwd.</para></listitem>
339 </itemizedlist>
341 <para>
342 The second item can be accomplished by using LDAP NSS and PAM modules. LGPL
343 versions of these libraries can be obtained from PADL Software
344 (<ulink url="http://www.padl.com/">http://www.padl.com/</ulink>). More
345 information about the configuration of these packages may be found at "LDAP,
346 System Administration; Gerald Carter, O'Reilly; Chapter 6: Replacing NIS".
347 </para>
349 </sect2>
351 <sect2>
352 <title>Supported LDAP Servers</title>
354 <!-- FIXME: This is outdated for 3.0 -->
356 <para>
357 The LDAP samdb code in 2.2.3 (and later) has been developed and tested
358 using the OpenLDAP 2.0 server and client libraries.
359 The same code should be able to work with Netscape's Directory Server
360 and client SDK. However, due to lack of testing so far, there are bound
361 to be compile errors and bugs. These should not be hard to fix.
362 If you are so inclined, please be sure to forward all patches to
363 <ulink url="mailto:samba-patches@samba.org">samba-patches@samba.org</ulink> and
364 <ulink url="mailto:jerry@samba.org">jerry@samba.org</ulink>.
365 </para>
367 </sect2>
369 <sect2>
370 <title>Schema and Relationship to the RFC 2307 posixAccount</title>
373 <para>
374 Samba 3.0 includes the necessary schema file for OpenLDAP 2.0 in
375 <filename>examples/LDAP/samba.schema</filename>. The sambaAccount objectclass is given here:
376 </para>
378 <para><programlisting>
379 objectclass ( 1.3.1.5.1.4.1.7165.2.2.2 NAME 'sambaAccount' SUP top AUXILIARY
380 DESC 'Samba Account'
381 MUST ( uid $ rid )
382 MAY ( cn $ lmPassword $ ntPassword $ pwdLastSet $ logonTime $
383 logoffTime $ kickoffTime $ pwdCanChange $ pwdMustChange $ acctFlags $
384 displayName $ smbHome $ homeDrive $ scriptPath $ profilePath $
385 description $ userWorkstations $ primaryGroupID $ domain ))
386 </programlisting></para>
388 <para>
389 The samba.schema file has been formatted for OpenLDAP 2.0. The OID's are
390 owned by the Samba Team and as such is legal to be openly published.
391 If you translate the schema to be used with Netscape DS, please
392 submit the modified schema file as a patch to <ulink
393 url="mailto:jerry@samba.org">jerry@samba.org</ulink>
394 </para>
396 <para>
397 Just as the smbpasswd file is meant to store information which supplements a
398 user's <filename>/etc/passwd</filename> entry, so is the sambaAccount object
399 meant to supplement the UNIX user account information. A sambaAccount is a
400 <constant>STRUCTURAL</constant> objectclass so it can be stored individually
401 in the directory. However, there are several fields (e.g. uid) which overlap
402 with the posixAccount objectclass outlined in RFC2307. This is by design.
403 </para>
405 <!--olem: we should perhaps have a note about shadowAccounts too as many
406 systems use them, isn'it ? -->
408 <para>
409 In order to store all user account information (UNIX and Samba) in the directory,
410 it is necessary to use the sambaAccount and posixAccount objectclasses in
411 combination. However, smbd will still obtain the user's UNIX account
412 information via the standard C library calls (e.g. getpwnam(), et. al.).
413 This means that the Samba server must also have the LDAP NSS library installed
414 and functioning correctly. This division of information makes it possible to
415 store all Samba account information in LDAP, but still maintain UNIX account
416 information in NIS while the network is transitioning to a full LDAP infrastructure.
417 </para>
418 </sect2>
420 <sect2>
421 <title>Configuring Samba with LDAP</title>
424 <sect3>
425 <title>OpenLDAP configuration</title>
427 <para>
428 To include support for the sambaAccount object in an OpenLDAP directory
429 server, first copy the samba.schema file to slapd's configuration directory.
430 </para>
432 <para>
433 <prompt>root# </prompt><userinput>cp samba.schema /etc/openldap/schema/</userinput>
434 </para>
436 <para>
437 Next, include the <filename>samba.schema</filename> file in <filename>slapd.conf</filename>.
438 The sambaAccount object contains two attributes which depend upon other schema
439 files. The 'uid' attribute is defined in <filename>cosine.schema</filename> and
440 the 'displayName' attribute is defined in the <filename>inetorgperson.schema</filename>
441 file. Both of these must be included before the <filename>samba.schema</filename> file.
442 </para>
444 <para><programlisting>
445 ## /etc/openldap/slapd.conf
447 ## schema files (core.schema is required by default)
448 include /etc/openldap/schema/core.schema
450 ## needed for sambaAccount
451 include /etc/openldap/schema/cosine.schema
452 include /etc/openldap/schema/inetorgperson.schema
453 include /etc/openldap/schema/samba.schema
454 include /etc/openldap/schema/nis.schema
456 ....
457 </programlisting></para>
459 <para>
460 It is recommended that you maintain some indices on some of the most usefull attributes,
461 like in the following example, to speed up searches made on sambaAccount objectclasses
462 (and possibly posixAccount and posixGroup as well).
463 </para>
464 <para><programlisting>
465 # Indices to maintain
466 ## required by OpenLDAP 2.0
467 index objectclass eq
469 ## support pb_getsampwnam()
470 index uid pres,eq
471 ## support pdb_getsambapwrid()
472 index rid eq
474 ## uncomment these if you are storing posixAccount and
475 ## posixGroup entries in the directory as well
476 ##index uidNumber eq
477 ##index gidNumber eq
478 ##index cn eq
479 ##index memberUid eq
481 # (both fetched via ldapsearch):
482 index primaryGroupID eq
483 index displayName pres,eq
485 </programlisting></para>
486 </sect3>
489 <sect3>
490 <title>Configuring Samba</title>
492 <para>
493 The following parameters are available in smb.conf only with <parameter>--with-ldapsam</parameter>
494 was included when compiling Samba.
495 </para>
497 <itemizedlist>
498 <listitem><para><ulink url="smb.conf.5.html#PASSDBBACKEND">passdb backend [ldapsam|ldapsam_nua]:url</ulink></para></listitem>
499 <listitem><para><ulink url="smb.conf.5.html#LDAPSSL">ldap ssl</ulink></para></listitem>
500 <listitem><para><ulink url="smb.conf.5.html#LDAPADMINDN">ldap admin dn</ulink></para></listitem>
501 <listitem><para><ulink url="smb.conf.5.html#LDAPSUFFIX">ldap suffix</ulink></para></listitem>
502 <listitem><para><ulink url="smb.conf.5.html#LDAPFILTER">ldap filter</ulink></para></listitem>
503 <listitem><para><ulink url="smb.conf.5.html#LDAPPORT">ldap port</ulink></para></listitem>
504 <listitem><para><ulink url="smb.conf.5.html#LDAPMACHINSUFFIX">ldap machine suffix</ulink></para></listitem>
505 <listitem><para><ulink url="smb.conf.5.html#LDAPUSERSUFFIX">ldap user suffix</ulink></para></listitem>
506 <listitem><para><ulink url="smb.conf.5.html#LDAPDELETEDN">ldap delete dn</ulink></para></listitem>
508 </itemizedlist>
510 <para>
511 These are described in the <ulink url="smb.conf.5.html">smb.conf(5)</ulink> man
512 page and so will not be repeated here. However, a sample smb.conf file for
513 use with an LDAP directory could appear as
514 </para>
516 <para><programlisting>
517 ## /usr/local/samba/lib/smb.conf
518 [global]
519 security = user
520 encrypt passwords = yes
522 netbios name = TASHTEGO
523 workgroup = NARNIA
525 # ldap related parameters
527 # define the DN to use when binding to the directory servers
528 # The password for this DN is not stored in smb.conf. Rather it
529 # must be set by using 'smbpasswd -w <replaceable>secretpw</replaceable>' to store the
530 # passphrase in the secrets.tdb file. If the "ldap admin dn" values
531 # change, this password will need to be reset.
532 ldap admin dn = "cn=Samba Manager,ou=people,dc=samba,dc=org"
534 # Define the SSL option when connecting to the directory
535 # ('off', 'start tls', or 'on' (default))
536 ldap ssl = start tls
538 passdb backend ldapsam:ldap://ahab.samba.org
540 # smbpasswd -x delete the entire dn-entry
541 ldap delete dn = no
543 # the machine and user suffix added to the base suffix
544 # wrote WITHOUT quotes. NULL siffixes by default
545 ldap user suffix = ou=People
546 ldap machine suffix = ou=Systems
548 # define the port to use in the LDAP session (defaults to 636 when
549 # "ldap ssl = on")
550 ldap port = 389
552 # specify the base DN to use when searching the directory
553 ldap suffix = "ou=people,dc=samba,dc=org"
555 # generally the default ldap search filter is ok
556 # ldap filter = "(&amp;(uid=%u)(objectclass=sambaAccount))"
557 </programlisting></para>
560 </sect3>
561 </sect2>
564 <sect2>
565 <title>Accounts and Groups management</title>
567 <para>
568 As users accounts are managed thru the sambaAccount objectclass, you should
569 modify your existing administration tools to deal with sambaAccount attributes.
570 </para>
572 <para>
573 Machines accounts are managed with the sambaAccount objectclass, just
574 like users accounts. However, it's up to you to store thoses accounts
575 in a different tree of you LDAP namespace: you should use
576 "ou=Groups,dc=plainjoe,dc=org" to store groups and
577 "ou=People,dc=plainjoe,dc=org" to store users. Just configure your
578 NSS and PAM accordingly (usually, in the /etc/ldap.conf configuration
579 file).
580 </para>
582 <para>
583 In Samba release 3.0, the group management system is based on posix
584 groups. This means that Samba makes usage of the posixGroup objectclass.
585 For now, there is no NT-like group system management (global and local
586 groups).
587 </para>
589 </sect2>
591 <sect2>
592 <title>Security and sambaAccount</title>
595 <para>
596 There are two important points to remember when discussing the security
597 of sambaAccount entries in the directory.
598 </para>
600 <itemizedlist>
601 <listitem><para><emphasis>Never</emphasis> retrieve the lmPassword or
602 ntPassword attribute values over an unencrypted LDAP session.</para></listitem>
603 <listitem><para><emphasis>Never</emphasis> allow non-admin users to
604 view the lmPassword or ntPassword attribute values.</para></listitem>
605 </itemizedlist>
607 <para>
608 These password hashes are clear text equivalents and can be used to impersonate
609 the user without deriving the original clear text strings. For more information
610 on the details of LM/NT password hashes, refer to the <link
611 linkend="passdb">User Database</link> of the Samba-HOWTO-Collection.
612 </para>
614 <para>
615 To remedy the first security issue, the "ldap ssl" smb.conf parameter defaults
616 to require an encrypted session (<command>ldap ssl = on</command>) using
617 the default port of 636
618 when contacting the directory server. When using an OpenLDAP 2.0 server, it
619 is possible to use the use the StartTLS LDAP extended operation in the place of
620 LDAPS. In either case, you are strongly discouraged to disable this security
621 (<command>ldap ssl = off</command>).
622 </para>
624 <para>
625 Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
626 extended operation. However, the OpenLDAP library still provides support for
627 the older method of securing communication between clients and servers.
628 </para>
630 <para>
631 The second security precaution is to prevent non-administrative users from
632 harvesting password hashes from the directory. This can be done using the
633 following ACL in <filename>slapd.conf</filename>:
634 </para>
636 <para><programlisting>
637 ## allow the "ldap admin dn" access, but deny everyone else
638 access to attrs=lmPassword,ntPassword
639 by dn="cn=Samba Admin,ou=people,dc=plainjoe,dc=org" write
640 by * none
641 </programlisting></para>
644 </sect2>
648 <sect2>
649 <title>LDAP specials attributes for sambaAccounts</title>
651 <para>
652 The sambaAccount objectclass is composed of the following attributes:
653 </para>
655 <itemizedlist>
657 <listitem><para><constant>lmPassword</constant>: the LANMAN password 16-byte hash stored as a character
658 representation of a hexidecimal string.</para></listitem>
660 <listitem><para><constant>ntPassword</constant>: the NT password hash 16-byte stored as a character
661 representation of a hexidecimal string.</para></listitem>
663 <listitem><para><constant>pwdLastSet</constant>: The integer time in seconds since 1970 when the
664 <constant>lmPassword</constant> and <constant>ntPassword</constant> attributes were last set.
665 </para></listitem>
667 <listitem><para><constant>acctFlags</constant>: string of 11 characters surrounded by square brackets []
668 representing account flags such as U (user), W(workstation), X(no password expiration), and
669 D(disabled).</para></listitem>
671 <listitem><para><constant>logonTime</constant>: Integer value currently unused</para></listitem>
673 <listitem><para><constant>logoffTime</constant>: Integer value currently unused</para></listitem>
675 <listitem><para><constant>kickoffTime</constant>: Integer value currently unused</para></listitem>
677 <listitem><para><constant>pwdCanChange</constant>: Integer value currently unused</para></listitem>
679 <listitem><para><constant>pwdMustChange</constant>: Integer value currently unused</para></listitem>
681 <listitem><para><constant>homeDrive</constant>: specifies the drive letter to which to map the
682 UNC path specified by homeDirectory. The drive letter must be specified in the form "X:"
683 where X is the letter of the drive to map. Refer to the "logon drive" parameter in the
684 smb.conf(5) man page for more information.</para></listitem>
686 <listitem><para><constant>scriptPath</constant>: The scriptPath property specifies the path of
687 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
688 is relative to the netlogon share. Refer to the "logon script" parameter in the
689 smb.conf(5) man page for more information.</para></listitem>
691 <listitem><para><constant>profilePath</constant>: specifies a path to the user's profile.
692 This value can be a null string, a local absolute path, or a UNC path. Refer to the
693 "logon path" parameter in the smb.conf(5) man page for more information.</para></listitem>
695 <listitem><para><constant>smbHome</constant>: The homeDirectory property specifies the path of
696 the home directory for the user. The string can be null. If homeDrive is set and specifies
697 a drive letter, homeDirectory should be a UNC path. The path must be a network
698 UNC path of the form \\server\share\directory. This value can be a null string.
699 Refer to the "logon home" parameter in the smb.conf(5) man page for more information.
700 </para></listitem>
702 <listitem><para><constant>userWorkstation</constant>: character string value currently unused.
703 </para></listitem>
705 <listitem><para><constant>rid</constant>: the integer representation of the user's relative identifier
706 (RID).</para></listitem>
708 <listitem><para><constant>primaryGroupID</constant>: the relative identifier (RID) of the primary group
709 of the user.</para></listitem>
711 </itemizedlist>
713 <para>
714 The majority of these parameters are only used when Samba is acting as a PDC of
715 a domain (refer to the <ulink url="Samba-PDC-HOWTO.html">Samba-PDC-HOWTO</ulink> for details on
716 how to configure Samba as a Primary Domain Controller). The following four attributes
717 are only stored with the sambaAccount entry if the values are non-default values:
718 </para>
720 <itemizedlist>
721 <listitem><para>smbHome</para></listitem>
722 <listitem><para>scriptPath</para></listitem>
723 <listitem><para>logonPath</para></listitem>
724 <listitem><para>homeDrive</para></listitem>
725 </itemizedlist>
727 <para>
728 These attributes are only stored with the sambaAccount entry if
729 the values are non-default values. For example, assume TASHTEGO has now been
730 configured as a PDC and that <command>logon home = \\%L\%u</command> was defined in
731 its <filename>smb.conf</filename> file. When a user named "becky" logons to the domain,
732 the <parameter>logon home</parameter> string is expanded to \\TASHTEGO\becky.
733 If the smbHome attribute exists in the entry "uid=becky,ou=people,dc=samba,dc=org",
734 this value is used. However, if this attribute does not exist, then the value
735 of the <parameter>logon home</parameter> parameter is used in its place. Samba
736 will only write the attribute value to the directory entry if the value is
737 something other than the default (e.g. \\MOBY\becky).
738 </para>
741 </sect2>
745 <sect2>
746 <title>Example LDIF Entries for a sambaAccount</title>
749 <para>
750 The following is a working LDIF with the inclusion of the posixAccount objectclass:
751 </para>
753 <para><programlisting>
754 dn: uid=guest2, ou=people,dc=plainjoe,dc=org
755 ntPassword: 878D8014606CDA29677A44EFA1353FC7
756 pwdMustChange: 2147483647
757 primaryGroupID: 1201
758 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
759 pwdLastSet: 1010179124
760 logonTime: 0
761 objectClass: sambaAccount
762 uid: guest2
763 kickoffTime: 2147483647
764 acctFlags: [UX ]
765 logoffTime: 2147483647
766 rid: 19006
767 pwdCanChange: 0
768 </programlisting></para>
770 <para>
771 The following is an LDIF entry for using both the sambaAccount and
772 posixAccount objectclasses:
773 </para>
775 <para><programlisting>
776 dn: uid=gcarter, ou=people,dc=plainjoe,dc=org
777 logonTime: 0
778 displayName: Gerald Carter
779 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
780 primaryGroupID: 1201
781 objectClass: posixAccount
782 objectClass: sambaAccount
783 acctFlags: [UX ]
784 userPassword: {crypt}BpM2ej8Rkzogo
785 uid: gcarter
786 uidNumber: 9000
787 cn: Gerald Carter
788 loginShell: /bin/bash
789 logoffTime: 2147483647
790 gidNumber: 100
791 kickoffTime: 2147483647
792 pwdLastSet: 1010179230
793 rid: 19000
794 homeDirectory: /home/tashtego/gcarter
795 pwdCanChange: 0
796 pwdMustChange: 2147483647
797 ntPassword: 878D8014606CDA29677A44EFA1353FC7
798 </programlisting></para>
800 </sect2>
801 </sect1>
803 <sect1>
804 <title>MySQL</title>
806 <sect2>
807 <title>Creating the database</title>
809 <para>
810 You either can set up your own table and specify the field names to pdb_mysql (see below
811 for the column names) or use the default table. The file <filename>examples/pdb/mysql/mysql.dump</filename>
812 contains the correct queries to create the required tables. Use the command :
814 <command>mysql -u<replaceable>username</replaceable> -h<replaceable>hostname</replaceable> -p<replaceable>password</replaceable> <replaceable>databasename</replaceable> < <filename>/path/to/samba/examples/pdb/mysql/mysql.dump</filename></command>
816 </para>
817 </sect2>
819 <sect2>
820 <title>Configuring</title>
822 <para>This plugin lacks some good documentation, but here is some short info:</para>
824 <para>Add a the following to the <command>passdb backend</command> variable in your <filename>smb.conf</filename>:
825 <programlisting>
826 passdb backend = [other-plugins] mysql:identifier [other-plugins]
827 </programlisting>
828 </para>
830 <para>The identifier can be any string you like, as long as it doesn't collide with
831 the identifiers of other plugins or other instances of pdb_mysql. If you
832 specify multiple pdb_mysql.so entries in 'passdb backend', you also need to
833 use different identifiers!
834 </para>
836 <para>
837 Additional options can be given thru the smb.conf file in the [global] section.
838 </para>
840 <para><programlisting>
841 identifier:mysql host - host name, defaults to 'localhost'
842 identifier:mysql password
843 identifier:mysql user - defaults to 'samba'
844 identifier:mysql database - defaults to 'samba'
845 identifier:mysql port - defaults to 3306
846 identifier:table - Name of the table containing users
847 </programlisting></para>
849 <warning>
850 <para>
851 Since the password for the mysql user is stored in the
852 smb.conf file, you should make the the smb.conf file
853 readable only to the user that runs samba. This is considered a security
854 bug and will be fixed soon.
855 </para>
856 </warning>
858 <para>Names of the columns in this table(I've added column types those columns should have first):</para>
860 <para><programlisting>
861 identifier:logon time column - int(9)
862 identifier:logoff time column - int(9)
863 identifier:kickoff time column - int(9)
864 identifier:pass last set time column - int(9)
865 identifier:pass can change time column - int(9)
866 identifier:pass must change time column - int(9)
867 identifier:username column - varchar(255) - unix username
868 identifier:domain column - varchar(255) - NT domain user is part of
869 identifier:nt username column - varchar(255) - NT username
870 identifier:fullname column - varchar(255) - Full name of user
871 identifier:home dir column - varchar(255) - Unix homedir path
872 identifier:dir drive column - varchar(2) - Directory drive path (eg: 'H:')
873 identifier:logon script column - varchar(255)
874 - Batch file to run on client side when logging on
875 identifier:profile path column - varchar(255) - Path of profile
876 identifier:acct desc column - varchar(255) - Some ASCII NT user data
877 identifier:workstations column - varchar(255)
878 - Workstations user can logon to (or NULL for all)
879 identifier:unknown string column - varchar(255) - unknown string
880 identifier:munged dial column - varchar(255) - ?
881 identifier:uid column - int(9) - Unix user ID (uid)
882 identifier:gid column - int(9) - Unix user group (gid)
883 identifier:user sid column - varchar(255) - NT user SID
884 identifier:group sid column - varchar(255) - NT group ID
885 identifier:lanman pass column - varchar(255) - encrypted lanman password
886 identifier:nt pass column - varchar(255) - encrypted nt passwd
887 identifier:plain pass column - varchar(255) - plaintext password
888 identifier:acct control column - int(9) - nt user data
889 identifier:unknown 3 column - int(9) - unknown
890 identifier:logon divs column - int(9) - ?
891 identifier:hours len column - int(9) - ?
892 identifier:unknown 5 column - int(9) - unknown
893 identifier:unknown 6 column - int(9) - unknown
894 </programlisting></para>
896 <para>
897 Eventually, you can put a colon (:) after the name of each column, which
898 should specify the column to update when updating the table. You can also
899 specify nothing behind the colon - then the data from the field will not be
900 updated.
901 </para>
903 </sect2>
905 <sect2>
906 <title>Using plaintext passwords or encrypted password</title>
908 <para>
909 I strongly discourage the use of plaintext passwords, however, you can use them:
910 </para>
912 <para>
913 If you would like to use plaintext passwords, set
914 'identifier:lanman pass column' and 'identifier:nt pass column' to
915 'NULL' (without the quotes) and 'identifier:plain pass column' to the
916 name of the column containing the plaintext passwords.
917 </para>
919 <para>
920 If you use encrypted passwords, set the 'identifier:plain pass
921 column' to 'NULL' (without the quotes). This is the default.
922 </para>
924 </sect2>
926 <sect2>
927 <title>Getting non-column data from the table</title>
929 <para>
930 It is possible to have not all data in the database and making some 'constant'.
931 </para>
933 <para>
934 For example, you can set 'identifier:fullname column' to :
935 <command>CONCAT(First_name,' ',Sur_name)</command>
936 </para>
938 <para>
939 Or, set 'identifier:workstations column' to :
940 <command>NULL</command></para>
942 <para>See the MySQL documentation for more language constructs.</para>
944 </sect2>
945 </sect1>
947 <sect1>
948 <title>XML</title>
950 <para>This module requires libxml2 to be installed.</para>
952 <para>The usage of pdb_xml is pretty straightforward. To export data, use:
953 </para>
955 <para>
956 <userinput>pdbedit -e xml:filename</userinput>
957 </para>
959 <para>
960 (where filename is the name of the file to put the data in)
961 </para>
963 <para>
964 To import data, use:
965 <userinput>pdbedit -i xml:filename -e current-pdb</userinput>
966 </para>
967 <para>
968 Where filename is the name to read the data from and current-pdb to put it in.
969 </para>
970 </sect1>
972 </chapter>