4 <firstname>Jelmer</firstname><surname>Vernooij</surname>
6 <orgname>The Samba Team</orgname>
7 <address><email>jelmer@samba.org</email></address>
11 <firstname>Gerald (Jerry)</firstname><surname>Carter</surname>
13 <orgname>Samba Team</orgname>
14 <address><email>jerry@samba.org</email></address>
18 <firstname>Olivier (lem)</firstname><surname>Lemaire</surname>
20 <orgname>IDEALX</orgname>
21 <address><email>olem@IDEALX.org</email></address>
25 <firstname>Jeremy</firstname><surname>Allison</surname>
27 <orgname>Samba Team</orgname>
29 <email>jra@samba.org</email>
34 <firstname>John H</firstname><surname>Terpstra</surname>
36 <orgname>Samba Team</orgname>
38 <email>jht@samba.org</email>
43 <pubdate>February 2003</pubdate>
46 <title>User information database</title>
49 <title>Introduction</title>
51 <para>Old windows clients send plain text passwords over the wire.
52 Samba can check these passwords by crypting them and comparing them
53 to the hash stored in the unix user database.
57 Newer windows clients send encrypted passwords (so-called
58 Lanman and NT hashes) over
59 the wire, instead of plain text passwords. The newest clients
60 will only send encrypted passwords and refuse to send plain text
61 passwords, unless their registry is tweaked.
64 <para>These passwords can't be converted to unix style encrypted
65 passwords. Because of that you can't use the standard unix
66 user database, and you have to store the Lanman and NT hashes
67 somewhere else. </para>
69 <para>Next to a differently encrypted passwords,
70 windows also stores certain data for each user
71 that is not stored in a unix user database, e.g.
72 workstations the user may logon from, the location where his/her
73 profile is stored, etc.
74 Samba retrieves and stores this information using a "passdb backend".
76 available backends are LDAP, plain text file, MySQL and nisplus.
77 For more information, see the documentation about the
78 <command>passdb backend = </command> parameter.
83 <title>Important Notes About Security</title>
85 <para>The unix and SMB password encryption techniques seem similar
86 on the surface. This similarity is, however, only skin deep. The unix
87 scheme typically sends clear text passwords over the network when
88 logging in. This is bad. The SMB encryption scheme never sends the
89 cleartext password over the network but it does store the 16 byte
90 hashed values on disk. This is also bad. Why? Because the 16 byte hashed
91 values are a "password equivalent". You cannot derive the user's
92 password from them, but they could potentially be used in a modified
93 client to gain access to a server. This would require considerable
94 technical knowledge on behalf of the attacker but is perfectly possible.
95 You should thus treat the data stored in whatever
96 passdb backend you use (smbpasswd file, ldap, mysql) as though it contained the
97 cleartext passwords of all your users. Its contents must be kept
98 secret, and the file should be protected accordingly.</para>
100 <para>Ideally we would like a password scheme which neither requires
101 plain text passwords on the net or on disk. Unfortunately this
102 is not available as Samba is stuck with being compatible with
103 other SMB systems (WinNT, WfWg, Win95 etc). </para>
106 <para>Note that Windows NT 4.0 Service pack 3 changed the
107 default for permissible authentication so that plaintext
108 passwords are <emphasis>never</emphasis> sent over the wire.
109 The solution to this is either to switch to encrypted passwords
110 with Samba or edit the Windows NT registry to re-enable plaintext
111 passwords. See the document WinNT.txt for details on how to do
114 <para>Other Microsoft operating systems which also exhibit
115 this behavior includes</para>
117 <para> These versions of MS Windows do not support full domain
118 security protocols, although they may log onto a domain environment.
119 Of these Only MS Windows XP Home does NOT support domain logons.</para>
122 <member>MS DOS Network client 3.0 with
123 the basic network redirector installed</member>
125 <member>Windows 95 with the network redirector
126 update installed</member>
128 <member>Windows 98 [se]</member>
130 <member>Windows Me</member>
132 <member>Windows XP Home</member>
135 <para> The following versions of MS Windows fully support domain
136 security protocols.</para>
139 <member>Windows NT 3.5x</member>
141 <member>Windows NT 4.0</member>
143 <member>Windows 2000 Professional</member>
145 <member>Windows 200x Server/Advanced Server</member>
147 <member>Windows XP Professional</member>
150 <para><emphasis>Note :</emphasis>All current release of
151 Microsoft SMB/CIFS clients support authentication via the
152 SMB Challenge/Response mechanism described here. Enabling
153 clear text authentication does not disable the ability
154 of the client to participate in encrypted authentication.</para>
157 <para>MS Windows clients will cache the encrypted password alone.
158 Even when plain text passwords are re-enabled, through the appropriate
159 registry change, the plain text password is NEVER cached. This means that
160 in the event that a network connections should become disconnected (broken)
161 only the cached (encrypted) password will be sent to the resource server
162 to affect a auto-reconnect. If the resource server does not support encrypted
163 passwords the auto-reconnect will fail. <emphasis>USE OF ENCRYPTED PASSWORDS
164 IS STRONGLY ADVISED.</emphasis></para>
168 <title>Advantages of SMB Encryption</title>
171 <member>Plain text passwords are not passed across
172 the network. Someone using a network sniffer cannot just
173 record passwords going to the SMB server.</member>
175 <member>WinNT doesn't like talking to a server
176 that SM not support encrypted passwords. It will refuse
177 to browse the server if the server is also in user level
178 security mode. It will insist on prompting the user for the
179 password on each connection, which is very annoying. The
180 only things you can do to stop this is to use SMB encryption.
183 <member>Encrypted password support allows auto-matic share
184 (resource) reconnects.</member>
190 <title>Advantages of non-encrypted passwords</title>
193 <member>Plain text passwords are not kept
194 on disk, and are NOT cached in memory. </member>
196 <member>Uses same password file as other unix
197 services such as login and ftp</member>
199 <member>Use of other services (such as telnet and ftp) which
200 send plain text passwords over the net, so sending them for SMB
201 isn't such a big deal.</member>
208 <title>The smbpasswd Command</title>
210 <para>The smbpasswd utility is a utility similar to the
211 <command>passwd</command> or <command>yppasswd</command> programs.
212 It maintains the two 32 byte password fields in the passdb backend. </para>
214 <para><command>smbpasswd</command> works in a client-server mode
215 where it contacts the local smbd to change the user's password on its
216 behalf. This has enormous benefits - as follows.</para>
218 <para><command>smbpasswd</command> has the capability
219 to change passwords on Windows NT servers (this only works when
220 the request is sent to the NT Primary Domain Controller if you
221 are changing an NT Domain user's password).</para>
223 <para>To run smbpasswd as a normal user just type :</para>
225 <para><prompt>$ </prompt><userinput>smbpasswd</userinput></para>
226 <para><prompt>Old SMB password: </prompt><userinput><type old value here -
227 or hit return if there was no old password></userinput></para>
228 <para><prompt>New SMB Password: </prompt><userinput><type new value>
230 <para><prompt>Repeat New SMB Password: </prompt><userinput><re-type new value
233 <para>If the old value does not match the current value stored for
234 that user, or the two new values do not match each other, then the
235 password will not be changed.</para>
237 <para>If invoked by an ordinary user it will only allow the user
238 to change his or her own Samba password.</para>
240 <para>If run by the root user smbpasswd may take an optional
241 argument, specifying the user name whose SMB password you wish to
242 change. Note that when run as root smbpasswd does not prompt for
243 or check the old password value, thus allowing root to set passwords
244 for users who have forgotten their passwords.</para>
246 <para><command>smbpasswd</command> is designed to work in the same way
247 and be familiar to UNIX users who use the <command>passwd</command> or
248 <command>yppasswd</command> commands.</para>
250 <para>For more details on using <command>smbpasswd</command> refer
251 to the man page which will always be the definitive reference.</para>
256 <title>The <command>pdbedit</command> command</title>
262 <title>Plain text</title>
264 Older versions of samba retrieved user information from the unix user database
265 and eventually some other fields from the file <filename>/etc/samba/smbpasswd</filename>
266 or <filename>/etc/smbpasswd</filename>. When password encryption is disabled, no
267 data is stored at all.
273 <para>Samba can also store the user data in a "TDB" (Trivial Database). Using this backend
274 doesn't require any additional configuration. This backend is recommended for new installations who
283 <title>Introduction</title>
286 This document describes how to use an LDAP directory for storing Samba user
287 account information traditionally stored in the smbpasswd(5) file. It is
288 assumed that the reader already has a basic understanding of LDAP concepts
289 and has a working directory server already installed. For more information
290 on LDAP architectures and Directories, please refer to the following sites.
294 <listitem><para>OpenLDAP - <ulink url="http://www.openldap.org/">http://www.openldap.org/</ulink></para></listitem>
295 <listitem><para>iPlanet Directory Server - <ulink url="http://iplanet.netscape.com/directory">http://iplanet.netscape.com/directory</ulink></para></listitem>
299 Note that <ulink url="http://www.ora.com/">O'Reilly Publishing</ulink> is working on
300 a guide to LDAP for System Administrators which has a planned release date of
305 Two additional Samba resources which may prove to be helpful are
309 <listitem><para>The <ulink url="http://www.unav.es/cti/ldap-smb/ldap-smb-3-howto.html">Samba-PDC-LDAP-HOWTO</ulink>
310 maintained by Ignacio Coupeau.</para></listitem>
312 <listitem><para>The NT migration scripts from <ulink url="http://samba.idealx.org/">IDEALX</ulink> that are
313 geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
320 <title>Introduction</title>
323 Traditionally, when configuring <ulink url="smb.conf.5.html#ENCRYPTPASSWORDS">"encrypt
324 passwords = yes"</ulink> in Samba's <filename>smb.conf</filename> file, user account
325 information such as username, LM/NT password hashes, password change times, and account
326 flags have been stored in the <filename>smbpasswd(5)</filename> file. There are several
327 disadvantages to this approach for sites with very large numbers of users (counted
333 The first is that all lookups must be performed sequentially. Given that
334 there are approximately two lookups per domain logon (one for a normal
335 session connection such as when mapping a network drive or printer), this
336 is a performance bottleneck for lareg sites. What is needed is an indexed approach
337 such as is used in databases.
341 The second problem is that administrators who desired to replicate a
342 smbpasswd file to more than one Samba server were left to use external
343 tools such as <command>rsync(1)</command> and <command>ssh(1)</command>
344 and wrote custom, in-house scripts.
348 And finally, the amount of information which is stored in an
349 smbpasswd entry leaves no room for additional attributes such as
350 a home directory, password expiration time, or even a Relative
356 As a result of these defeciencies, a more robust means of storing user attributes
357 used by smbd was developed. The API which defines access to user accounts
358 is commonly referred to as the samdb interface (previously this was called the passdb
359 API, and is still so named in the CVS trees). In Samba 2.2.3, enabling support
360 for a samdb backend (e.g. <parameter>--with-ldapsam</parameter> or
361 <parameter>--with-tdbsam</parameter>) requires compile time support.
365 When compiling Samba to include the <parameter>--with-ldapsam</parameter> autoconf
366 option, smbd (and associated tools) will store and lookup user accounts in
367 an LDAP directory. In reality, this is very easy to understand. If you are
368 comfortable with using an smbpasswd file, simply replace "smbpasswd" with
369 "LDAP directory" in all the documentation.
373 There are a few points to stress about what the <parameter>--with-ldapsam</parameter>
374 does not provide. The LDAP support referred to in the this documentation does not
379 <listitem><para>A means of retrieving user account information from
380 an Windows 2000 Active Directory server.</para></listitem>
381 <listitem><para>A means of replacing /etc/passwd.</para></listitem>
385 The second item can be accomplished by using LDAP NSS and PAM modules. LGPL
386 versions of these libraries can be obtained from PADL Software
387 (<ulink url="http://www.padl.com/">http://www.padl.com/</ulink>). However,
388 the details of configuring these packages are beyond the scope of this document.
394 <title>Supported LDAP Servers</title>
397 The LDAP samdb code in 2.2.3 (and later) has been developed and tested
398 using the OpenLDAP 2.0 server and client libraries.
399 The same code should be able to work with Netscape's Directory Server
400 and client SDK. However, due to lack of testing so far, there are bound
401 to be compile errors and bugs. These should not be hard to fix.
402 If you are so inclined, please be sure to forward all patches to
403 <ulink url="samba-patches@samba.org">samba-patches@samba.org</ulink> and
404 <ulink url="jerry@samba.org">jerry@samba.org</ulink>.
410 <title>Schema and Relationship to the RFC 2307 posixAccount</title>
414 Samba 3.0 includes the necessary schema file for OpenLDAP 2.0 in
415 <filename>examples/LDAP/samba.schema</filename>. The sambaAccount objectclass is given here:
418 <para><programlisting>
419 objectclass ( 1.3.1.5.1.4.1.7165.2.2.2 NAME 'sambaAccount' SUP top STRUCTURAL
422 MAY ( cn $ lmPassword $ ntPassword $ pwdLastSet $ logonTime $
423 logoffTime $ kickoffTime $ pwdCanChange $ pwdMustChange $ acctFlags $
424 displayName $ smbHome $ homeDrive $ scriptPath $ profilePath $
425 description $ userWorkstations $ primaryGroupID $ domain ))
426 </programlisting></para>
429 The samba.schema file has been formatted for OpenLDAP 2.0. The OID's are
430 owned by the Samba Team and as such is legal to be openly published.
431 If you translate the schema to be used with Netscape DS, please
432 submit the modified schema file as a patch to <ulink
433 url="jerry@samba.org">jerry@samba.org</ulink>
437 Just as the smbpasswd file is mean to store information which supplements a
438 user's <filename>/etc/passwd</filename> entry, so is the sambaAccount object
439 meant to supplement the UNIX user account information. A sambaAccount is a
440 <constant>STRUCTURAL</constant> objectclass so it can be stored individually
441 in the directory. However, there are several fields (e.g. uid) which overlap
442 with the posixAccount objectclass outlined in RFC2307. This is by design.
445 <!--olem: we should perhaps have a note about shadowAccounts too as many
446 systems use them, isn'it ? -->
449 In order to store all user account information (UNIX and Samba) in the directory,
450 it is necessary to use the sambaAccount and posixAccount objectclasses in
451 combination. However, smbd will still obtain the user's UNIX account
452 information via the standard C library calls (e.g. getpwnam(), et. al.).
453 This means that the Samba server must also have the LDAP NSS library installed
454 and functioning correctly. This division of information makes it possible to
455 store all Samba account information in LDAP, but still maintain UNIX account
456 information in NIS while the network is transitioning to a full LDAP infrastructure.
461 <title>Configuring Samba with LDAP</title>
465 <title>OpenLDAP configuration</title>
468 To include support for the sambaAccount object in an OpenLDAP directory
469 server, first copy the samba.schema file to slapd's configuration directory.
473 <prompt>root# </prompt><command>cp samba.schema /etc/openldap/schema/</command>
477 Next, include the <filename>samba.schema</filename> file in <filename>slapd.conf</filename>.
478 The sambaAccount object contains two attributes which depend upon other schema
479 files. The 'uid' attribute is defined in <filename>cosine.schema</filename> and
480 the 'displayName' attribute is defined in the <filename>inetorgperson.schema</filename>
481 file. Both of these must be included before the <filename>samba.schema</filename> file.
484 <para><programlisting>
485 ## /etc/openldap/slapd.conf
487 ## schema files (core.schema is required by default)
488 include /etc/openldap/schema/core.schema
490 ## needed for sambaAccount
491 include /etc/openldap/schema/cosine.schema
492 include /etc/openldap/schema/inetorgperson.schema
493 include /etc/openldap/schema/samba.schema
495 ## uncomment this line if you want to support the RFC2307 (NIS) schema
496 ## include /etc/openldap/schema/nis.schema
499 </programlisting></para>
502 It is recommended that you maintain some indices on some of the most usefull attributes,
503 like in the following example, to speed up searches made on sambaAccount objectclasses
504 (and possibly posixAccount and posixGroup as well).
506 <para><programlisting>
507 # Indices to maintain
508 ## required by OpenLDAP 2.0
511 ## support pb_getsampwnam()
513 ## support pdb_getsambapwrid()
516 ## uncomment these if you are storing posixAccount and
517 ## posixGroup entries in the directory as well
522 </programlisting></para>
527 <title>Configuring Samba</title>
528 <!--lem: <title>smb.conf LDAP parameters</title> -->
531 The following parameters are available in smb.conf only with <parameter>--with-ldapsam</parameter>
532 was included with compiling Samba.
536 <listitem><para><ulink url="smb.conf.5.html#LDAPSSL">ldap ssl</ulink></para></listitem>
537 <listitem><para><ulink url="smb.conf.5.html#LDAPSERVER">ldap server</ulink></para></listitem>
538 <listitem><para><ulink url="smb.conf.5.html#LDAPADMINDN">ldap admin dn</ulink></para></listitem>
539 <listitem><para><ulink url="smb.conf.5.html#LDAPSUFFIX">ldap suffix</ulink></para></listitem>
540 <listitem><para><ulink url="smb.conf.5.html#LDAPFILTER">ldap filter</ulink></para></listitem>
541 <listitem><para><ulink url="smb.conf.5.html#LDAPPORT">ldap port</ulink></para></listitem>
545 These are described in the <ulink url="smb.conf.5.html">smb.conf(5)</ulink> man
546 page and so will not be repeated here. However, a sample smb.conf file for
547 use with an LDAP directory could appear as
550 <para><programlisting>
551 ## /usr/local/samba/lib/smb.conf
554 encrypt passwords = yes
556 netbios name = TASHTEGO
559 # ldap related parameters
561 # define the DN to use when binding to the directory servers
562 # The password for this DN is not stored in smb.conf. Rather it
563 # must be set by using 'smbpasswd -w <replaceable>secretpw</replaceable>' to store the
564 # passphrase in the secrets.tdb file. If the "ldap admin dn" values
565 # changes, this password will need to be reset.
566 ldap admin dn = "cn=Samba Manager,ou=people,dc=samba,dc=org"
568 # specify the LDAP server's hostname (defaults to locahost)
569 ldap server = ahab.samba.org
571 # Define the SSL option when connecting to the directory
572 # ('off', 'start tls', or 'on' (default))
575 # define the port to use in the LDAP session (defaults to 636 when
579 # specify the base DN to use when searching the directory
580 ldap suffix = "ou=people,dc=samba,dc=org"
582 # generally the default ldap search filter is ok
583 # ldap filter = "(&(uid=%u)(objectclass=sambaAccount))"
584 </programlisting></para>
592 <title>Accounts and Groups management</title>
595 As users accounts are managed thru the sambaAccount objectclass, you should
596 modify you existing administration tools to deal with sambaAccount attributes.
600 Machines accounts are managed with the sambaAccount objectclass, just
601 like users accounts. However, it's up to you to stored thoses accounts
602 in a different tree of you LDAP namespace: you should use
603 "ou=Groups,dc=plainjoe,dc=org" to store groups and
604 "ou=People,dc=plainjoe,dc=org" to store users. Just configure your
605 NSS and PAM accordingly (usually, in the /etc/ldap.conf configuration
610 In Samba release 3.0, the group management system is based on posix
611 groups. This means that Samba make usage of the posixGroup objectclass.
612 For now, there is no NT-like group system management (global and local
619 <title>Security and sambaAccount</title>
623 There are two important points to remember when discussing the security
624 of sambaAccount entries in the directory.
628 <listitem><para><emphasis>Never</emphasis> retrieve the lmPassword or
629 ntPassword attribute values over an unencrypted LDAP session.</para></listitem>
630 <listitem><para><emphasis>Never</emphasis> allow non-admin users to
631 view the lmPassword or ntPassword attribute values.</para></listitem>
635 These password hashes are clear text equivalents and can be used to impersonate
636 the user without deriving the original clear text strings. For more information
637 on the details of LM/NT password hashes, refer to the <ulink
638 url="ENCRYPTION.html">ENCRYPTION chapter</ulink> of the Samba-HOWTO-Collection.
642 To remedy the first security issue, the "ldap ssl" smb.conf parameter defaults
643 to require an encrypted session (<command>ldap ssl = on</command>) using
644 the default port of 636
645 when contacting the directory server. When using an OpenLDAP 2.0 server, it
646 is possible to use the use the StartTLS LDAP extended operation in the place of
647 LDAPS. In either case, you are strongly discouraged to disable this security
648 (<command>ldap ssl = off</command>).
652 Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
653 extended operation. However, the OpenLDAP library still provides support for
654 the older method of securing communication between clients and servers.
658 The second security precaution is to prevent non-administrative users from
659 harvesting password hashes from the directory. This can be done using the
660 following ACL in <filename>slapd.conf</filename>:
663 <para><programlisting>
664 ## allow the "ldap admin dn" access, but deny everyone else
665 access to attrs=lmPassword,ntPassword
666 by dn="cn=Samba Admin,ou=people,dc=plainjoe,dc=org" write
668 </programlisting></para>
676 <title>LDAP specials attributes for sambaAccounts</title>
679 The sambaAccount objectclass is composed of the following attributes:
684 <listitem><para><constant>lmPassword</constant>: the LANMAN password 16-byte hash stored as a character
685 representation of a hexidecimal string.</para></listitem>
687 <listitem><para><constant>ntPassword</constant>: the NT password hash 16-byte stored as a character
688 representation of a hexidecimal string.</para></listitem>
690 <listitem><para><constant>pwdLastSet</constant>: The integer time in seconds since 1970 when the
691 <constant>lmPassword</constant> and <constant>ntPassword</constant> attributes were last set.
694 <listitem><para><constant>acctFlags</constant>: string of 11 characters surrounded by square brackets []
695 representing account flags such as U (user), W(workstation), X(no password expiration), and
696 D(disabled).</para></listitem>
698 <listitem><para><constant>logonTime</constant>: Integer value currently unused</para></listitem>
700 <listitem><para><constant>logoffTime</constant>: Integer value currently unused</para></listitem>
702 <listitem><para><constant>kickoffTime</constant>: Integer value currently unused</para></listitem>
704 <listitem><para><constant>pwdCanChange</constant>: Integer value currently unused</para></listitem>
706 <listitem><para><constant>pwdMustChange</constant>: Integer value currently unused</para></listitem>
708 <listitem><para><constant>homeDrive</constant>: specifies the drive letter to which to map the
709 UNC path specified by homeDirectory. The drive letter must be specified in the form "X:"
710 where X is the letter of the drive to map. Refer to the "logon drive" parameter in the
711 smb.conf(5) man page for more information.</para></listitem>
713 <listitem><para><constant>scriptPath</constant>: The scriptPath property specifies the path of
714 the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
715 is relative to the netlogon share. Refer to the "logon script" parameter in the
716 smb.conf(5) man page for more information.</para></listitem>
718 <listitem><para><constant>profilePath</constant>: specifies a path to the user's profile.
719 This value can be a null string, a local absolute path, or a UNC path. Refer to the
720 "logon path" parameter in the smb.conf(5) man page for more information.</para></listitem>
722 <listitem><para><constant>smbHome</constant>: The homeDirectory property specifies the path of
723 the home directory for the user. The string can be null. If homeDrive is set and specifies
724 a drive letter, homeDirectory should be a UNC path. The path must be a network
725 UNC path of the form \\server\share\directory. This value can be a null string.
726 Refer to the "logon home" parameter in the smb.conf(5) man page for more information.
729 <listitem><para><constant>userWorkstation</constant>: character string value currently unused.
732 <listitem><para><constant>rid</constant>: the integer representation of the user's relative identifier
733 (RID).</para></listitem>
735 <listitem><para><constant>primaryGroupID</constant>: the relative identifier (RID) of the primary group
736 of the user.</para></listitem>
741 The majority of these parameters are only used when Samba is acting as a PDC of
742 a domain (refer to the <ulink url="Samba-PDC-HOWTO.html">Samba-PDC-HOWTO</ulink> for details on
743 how to configure Samba as a Primary Domain Controller). The following four attributes
744 are only stored with the sambaAccount entry if the values are non-default values:
748 <listitem><para>smbHome</para></listitem>
749 <listitem><para>scriptPath</para></listitem>
750 <listitem><para>logonPath</para></listitem>
751 <listitem><para>homeDrive</para></listitem>
755 These attributes are only stored with the sambaAccount entry if
756 the values are non-default values. For example, assume TASHTEGO has now been
757 configured as a PDC and that <command>logon home = \\%L\%u</command> was defined in
758 its <filename>smb.conf</filename> file. When a user named "becky" logons to the domain,
759 the <parameter>logon home</parameter> string is expanded to \\TASHTEGO\becky.
760 If the smbHome attribute exists in the entry "uid=becky,ou=people,dc=samba,dc=org",
761 this value is used. However, if this attribute does not exist, then the value
762 of the <parameter>logon home</parameter> parameter is used in its place. Samba
763 will only write the attribute value to the directory entry is the value is
764 something other than the default (e.g. \\MOBY\becky).
773 <title>Example LDIF Entries for a sambaAccount</title>
777 The following is a working LDIF with the inclusion of the posixAccount objectclass:
780 <para><programlisting>
781 dn: uid=guest2, ou=people,dc=plainjoe,dc=org
782 ntPassword: 878D8014606CDA29677A44EFA1353FC7
783 pwdMustChange: 2147483647
785 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
786 pwdLastSet: 1010179124
788 objectClass: sambaAccount
790 kickoffTime: 2147483647
792 logoffTime: 2147483647
795 </programlisting></para>
798 The following is an LDIF entry for using both the sambaAccount and
799 posixAccount objectclasses:
802 <para><programlisting>
803 dn: uid=gcarter, ou=people,dc=plainjoe,dc=org
805 displayName: Gerald Carter
806 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
808 objectClass: posixAccount
809 objectClass: sambaAccount
811 userPassword: {crypt}BpM2ej8Rkzogo
815 loginShell: /bin/bash
816 logoffTime: 2147483647
818 kickoffTime: 2147483647
819 pwdLastSet: 1010179230
821 homeDirectory: /home/tashtego/gcarter
823 pwdMustChange: 2147483647
824 ntPassword: 878D8014606CDA29677A44EFA1353FC7
825 </programlisting></para>
834 <title>Building</title>
836 <para>To build the plugin, run <command>make bin/pdb_mysql.so</command>
837 in the <filename>source/</filename> directory of samba distribution.
840 <para>Next, copy pdb_mysql.so to any location you want. I
841 strongly recommend installing it in $PREFIX/lib or /usr/lib/samba/</para>
846 <title>Creating the database</title>
849 You either can set up your own table and specify the field names to pdb_mysql (see below
850 for the column names) or use the default table. The file <filename>examples/pdb/mysql/mysql.dump</filename>
851 contains the correct queries to create the required tables. Use the command :
853 <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>
859 <title>Configuring</title>
861 <para>This plugin lacks some good documentation, but here is some short info:</para>
863 <para>Add a the following to the <command>passdb backend</command> variable in your <filename>smb.conf</filename>:
865 passdb backend = [other-plugins] plugin:/location/to/pdb_mysql.so:identifier [other-plugins]
869 <para>The identifier can be any string you like, as long as it doesn't collide with
870 the identifiers of other plugins or other instances of pdb_mysql. If you
871 specify multiple pdb_mysql.so entries in 'passdb backend', you also need to
872 use different identifiers!
876 Additional options can be given thru the smb.conf file in the [global] section.
879 <para><programlisting>
880 identifier:mysql host - host name, defaults to 'localhost'
881 identifier:mysql password
882 identifier:mysql user - defaults to 'samba'
883 identifier:mysql database - defaults to 'samba'
884 identifier:mysql port - defaults to 3306
885 identifier:table - Name of the table containing users
886 </programlisting></para>
890 Since the password for the mysql user is stored in the
891 smb.conf file, you should make the the smb.conf file
892 readable only to the user that runs samba. This is considered a security
893 bug and will be fixed soon.
897 <para>Names of the columns in this table(I've added column types those columns should have first):</para>
899 <para><programlisting>
900 identifier:logon time column - int(9)
901 identifier:logoff time column - int(9)
902 identifier:kickoff time column - int(9)
903 identifier:pass last set time column - int(9)
904 identifier:pass can change time column - int(9)
905 identifier:pass must change time column - int(9)
906 identifier:username column - varchar(255) - unix username
907 identifier:domain column - varchar(255) - NT domain user is part of
908 identifier:nt username column - varchar(255) - NT username
909 identifier:fullname column - varchar(255) - Full name of user
910 identifier:home dir column - varchar(255) - Unix homedir path
911 identifier:dir drive column - varchar(2) - Directory drive path (eg: 'H:')
912 identifier:logon script column - varchar(255) - Batch file to run on client side when logging on
913 identifier:profile path column - varchar(255) - Path of profile
914 identifier:acct desc column - varchar(255) - Some ASCII NT user data
915 identifier:workstations column - varchar(255) - Workstations user can logon to (or NULL for all)
916 identifier:unknown string column - varchar(255) - unknown string
917 identifier:munged dial column - varchar(255) - ?
918 identifier:uid column - int(9) - Unix user ID (uid)
919 identifier:gid column - int(9) - Unix user group (gid)
920 identifier:user sid column - varchar(255) - NT user SID
921 identifier:group sid column - varchar(255) - NT group ID
922 identifier:lanman pass column - varchar(255) - encrypted lanman password
923 identifier:nt pass column - varchar(255) - encrypted nt passwd
924 identifier:plain pass column - varchar(255) - plaintext password
925 identifier:acct control column - int(9) - nt user data
926 identifier:unknown 3 column - int(9) - unknown
927 identifier:logon divs column - int(9) - ?
928 identifier:hours len column - int(9) - ?
929 identifier:unknown 5 column - int(9) - unknown
930 identifier:unknown 6 column - int(9) - unknown
931 </programlisting></para>
934 Eventually, you can put a colon (:) after the name of each column, which
935 should specify the column to update when updating the table. You can also
936 specify nothing behind the colon - then the data from the field will not be
943 <title>Using plaintext passwords or encrypted password</title>
946 I strongly discourage the use of plaintext passwords, however, you can use them:
950 If you would like to use plaintext passwords, set 'identifier:lanman pass column' and 'identifier:nt pass column' to 'NULL' (without the quotes) and 'identifier:plain pass column' to the name of the column containing the plaintext passwords.
954 If you use encrypted passwords, set the 'identifier:plain pass column' to 'NULL' (without the quotes). This is the default.
960 <title>Getting non-column data from the table</title>
963 It is possible to have not all data in the database and making some 'constant'.
967 For example, you can set 'identifier:fullname column' to :
968 <command>CONCAT(First_name,' ',Sur_name)</command>
972 Or, set 'identifier:workstations column' to :
973 <command>NULL</command></para>
975 <para>See the MySQL documentation for more language constructs.</para>
981 <title>Passdb XML plugin</title>
984 <title>Building</title>
986 <para>This module requires libxml2 to be installed.</para>
988 <para>To build pdb_xml, run: <command>make bin/pdb_xml.so</command> in
989 the directory <filename>source/</filename>. </para>
996 <para>The usage of pdb_xml is pretty straightforward. To export data, use:
998 <command>pdbedit -e plugin:/usr/lib/samba/pdb_xml.so:filename</command>
1000 (where filename is the name of the file to put the data in)
1004 To import data, use:
1005 <command>pdbedit -i plugin:/usr/lib/samba/pdb_xml.so:filename -e current-pdb</command>
1007 Where filename is the name to read the data from and current-pdb to put it in.