This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[ira/wip.git] / docs / htmldocs / passdb.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 10. User information database</title><link rel="stylesheet" href="samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.59.1"><link rel="home" href="index.html" title="SAMBA Project Documentation"><link rel="up" href="optional.html" title="Part III. Advanced Configuration"><link rel="previous" href="NetworkBrowsing.html" title="Chapter 9. Samba / MS Windows Network Browsing Guide"><link rel="next" href="unix-permissions.html" title="Chapter 11. UNIX Permission Bits and Windows NT Access Control Lists"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 10. User information database</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="NetworkBrowsing.html">Prev</a> </td><th width="60%" align="center">Part III. Advanced Configuration</th><td width="20%" align="right"> <a accesskey="n" href="unix-permissions.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="passdb"></a>Chapter 10. User information database</h2></div><div><div class="author"><h3 class="author">Jelmer R. Vernooij</h3><div class="affiliation"><span class="orgname">The Samba Team<br></span><div class="address"><p><tt>&lt;<a href="mailto:jelmer@samba.org">jelmer@samba.org</a>&gt;</tt></p></div></div></div></div><div><div class="author"><h3 class="author">Gerald (Jerry) Carter</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt>&lt;<a href="mailto:jerry@samba.org">jerry@samba.org</a>&gt;</tt></p></div></div></div></div><div><div class="author"><h3 class="author">Jeremy Allison</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt>&lt;<a href="mailto:jra@samba.org">jra@samba.org</a>&gt;</tt></p></div></div></div></div><div><div class="author"><h3 class="author">John H. Terpstra</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt>&lt;<a href="mailto:jht@samba.org">jht@samba.org</a>&gt;</tt></p></div></div></div></div><div><div class="author"><h3 class="author">Olivier (lem) Lemaire</h3><div class="affiliation"><span class="orgname">IDEALX<br></span><div class="address"><p><tt>&lt;<a href="mailto:olem@IDEALX.org">olem@IDEALX.org</a>&gt;</tt></p></div></div></div></div><div><p class="pubdate">February 2003</p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="passdb.html#id2882995">Introduction</a></dt><dt><a href="passdb.html#id2883048">Important Notes About Security</a></dt><dd><dl><dt><a href="passdb.html#id2883210">Advantages of SMB Encryption</a></dt><dt><a href="passdb.html#id2883249">Advantages of non-encrypted passwords</a></dt></dl></dd><dt><a href="passdb.html#id2883283">The smbpasswd Command</a></dt><dt><a href="passdb.html#id2883464">Plain text</a></dt><dt><a href="passdb.html#id2883493">TDB</a></dt><dt><a href="passdb.html#id2883509">LDAP</a></dt><dd><dl><dt><a href="passdb.html#id2883516">Introduction</a></dt><dt><a href="passdb.html#id2883617">Encrypted Password Database</a></dt><dt><a href="passdb.html#id2883756">Supported LDAP Servers</a></dt><dt><a href="passdb.html#id2883794">Schema and Relationship to the RFC 2307 posixAccount</a></dt><dt><a href="passdb.html#id2883904">Configuring Samba with LDAP</a></dt><dt><a href="passdb.html#id2884200">Accounts and Groups management</a></dt><dt><a href="passdb.html#id2884237">Security and sambaAccount</a></dt><dt><a href="passdb.html#id2884352">LDAP specials attributes for sambaAccounts</a></dt><dt><a href="passdb.html#id2884633">Example LDIF Entries for a sambaAccount</a></dt></dl></dd><dt><a href="passdb.html#id2884689">MySQL</a></dt><dd><dl><dt><a href="passdb.html#id2884696">Creating the database</a></dt><dt><a href="passdb.html#id2884750">Configuring</a></dt><dt><a href="passdb.html#id2884895">Using plaintext passwords or encrypted password</a></dt><dt><a href="passdb.html#id2884925">Getting non-column data from the table</a></dt></dl></dd><dt><a href="passdb.html#id2884968">XML</a></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2882995"></a>Introduction</h2></div></div><p>Old windows clients send plain text passwords over the wire. 
3         Samba can check these passwords by crypting them and comparing them 
4         to the hash stored in the unix user database.
5         </p><p>
6         Newer windows clients send encrypted passwords (so-called 
7         Lanman and NT hashes) over 
8         the wire, instead of plain text passwords. The newest clients 
9         will only send encrypted passwords and refuse to send plain text 
10         passwords, unless their registry is tweaked.
11         </p><p>These passwords can't be converted to unix style encrypted 
12         passwords. Because of that you can't use the standard unix 
13         user database, and you have to store the Lanman and NT hashes 
14         somewhere else. </p><p>Next to a differently encrypted passwords, 
15         windows also stores certain data for each user 
16         that is not stored in a unix user database, e.g. 
17         workstations the user may logon from, the location where his/her 
18         profile is stored, etc.
19         Samba retrieves and stores this information using a &quot;passdb backend&quot;.
20         Commonly
21         available backends are LDAP, plain text file, MySQL and nisplus.
22         For more information, see the documentation about the 
23         <b>passdb backend = </b> parameter.
24         </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2883048"></a>Important Notes About Security</h2></div></div><p>The unix and SMB password encryption techniques seem similar 
25         on the surface. This similarity is, however, only skin deep. The unix 
26         scheme typically sends clear text passwords over the network when 
27         logging in. This is bad. The SMB encryption scheme never sends the 
28         cleartext password over the network but it does store the 16 byte 
29         hashed values on disk. This is also bad. Why? Because the 16 byte hashed 
30         values are a &quot;password equivalent&quot;. You cannot derive the user's 
31         password from them, but they could potentially be used in a modified 
32         client to gain access to a server. This would require considerable 
33         technical knowledge on behalf of the attacker but is perfectly possible. 
34         You should thus treat the data stored in whatever 
35         passdb backend you use (smbpasswd file, ldap, mysql) as though it contained the 
36         cleartext passwords of all your users. Its contents must be kept 
37         secret, and the file should be protected accordingly.</p><p>Ideally we would like a password scheme which neither requires 
38         plain text passwords on the net or on disk. Unfortunately this 
39         is not available as Samba is stuck with being compatible with 
40         other SMB systems (WinNT, WfWg, Win95 etc). </p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Note that Windows NT 4.0 Service pack 3 changed the 
41                 default for permissible authentication so that plaintext 
42                 passwords are <span class="emphasis"><em>never</em></span> sent over the wire. 
43                 The solution to this is either to switch to encrypted passwords 
44                 with Samba or edit the Windows NT registry to re-enable plaintext 
45                 passwords. See the document WinNT.txt for details on how to do 
46                 this.</p><p>Other Microsoft operating systems which also exhibit 
47                 this behavior includes</p><p> These versions of MS Windows do not support full domain
48                 security protocols, although they may log onto a domain environment.
49                 Of these Only MS Windows XP Home does NOT support domain logons.</p><table class="simplelist" border="0" summary="Simple list"><tr><td>MS DOS Network client 3.0 with 
50                         the basic network redirector installed</td></tr><tr><td>Windows 95 with the network redirector 
51                         update installed</td></tr><tr><td>Windows 98 [se]</td></tr><tr><td>Windows Me</td></tr><tr><td>Windows XP Home</td></tr></table><p> The following versions of MS Windows fully support domain
52                 security protocols.</p><table class="simplelist" border="0" summary="Simple list"><tr><td>Windows NT 3.5x</td></tr><tr><td>Windows NT 4.0</td></tr><tr><td>Windows 2000 Professional</td></tr><tr><td>Windows 200x Server/Advanced Server</td></tr><tr><td>Windows XP Professional</td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>All current release of 
53         Microsoft SMB/CIFS clients support authentication via the
54         SMB Challenge/Response mechanism described here.  Enabling
55         clear text authentication does not disable the ability
56         of the client to participate in encrypted authentication.</p></div><p>MS Windows clients will cache the encrypted password alone.
57         Even when plain text passwords are re-enabled, through the appropriate
58         registry change, the plain text password is NEVER cached. This means that
59         in the event that a network connections should become disconnected (broken)
60         only the cached (encrypted) password will be sent to the resource server
61         to affect a auto-reconnect. If the resource server does not support encrypted
62         passwords the auto-reconnect will fail. <span class="emphasis"><em>USE OF ENCRYPTED PASSWORDS
63         IS STRONGLY ADVISED.</em></span></p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2883210"></a>Advantages of SMB Encryption</h3></div></div><table class="simplelist" border="0" summary="Simple list"><tr><td>Plain text passwords are not passed across 
64                         the network. Someone using a network sniffer cannot just 
65                         record passwords going to the SMB server.</td></tr><tr><td>WinNT doesn't like talking to a server 
66                         that does not support encrypted passwords. It will refuse 
67                         to browse the server if the server is also in user level 
68                         security mode. It will insist on prompting the user for the 
69                         password on each connection, which is very annoying. The
70                         only things you can do to stop this is to use SMB encryption.
71                         </td></tr><tr><td>Encrypted password support allows automatic share
72                         (resource) reconnects.</td></tr></table></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2883249"></a>Advantages of non-encrypted passwords</h3></div></div><table class="simplelist" border="0" summary="Simple list"><tr><td>Plain text passwords are not kept 
73                         on disk, and are NOT cached in memory. </td></tr><tr><td>Uses same password file as other unix 
74                         services such as login and ftp</td></tr><tr><td>Use of other services (such as telnet and ftp) which
75                         send plain text passwords over the net, so sending them for SMB
76                         isn't such a big deal.</td></tr></table></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2883283"></a>The smbpasswd Command</h2></div></div><p>The smbpasswd utility is a utility similar to the 
77         <b>passwd</b> or <b>yppasswd</b> programs.
78         It maintains the two 32 byte password fields in the passdb backend. </p><p><b>smbpasswd</b> works in a client-server mode 
79         where it contacts the local smbd to change the user's password on its 
80         behalf. This has enormous benefits - as follows.</p><p><b>smbpasswd</b> has the capability 
81         to change passwords on Windows NT servers (this only works when 
82         the request is sent to the NT Primary Domain Controller if you 
83         are changing an NT Domain user's password).</p><p>To run smbpasswd as a normal user just type :</p><p><tt>$ </tt><b><tt>smbpasswd</tt></b></p><p><tt>Old SMB password: </tt><b><tt>&lt;type old value here - 
84         or hit return if there was no old password&gt;</tt></b></p><p><tt>New SMB Password: </tt><b><tt>&lt;type new value&gt;
85         </tt></b></p><p><tt>Repeat New SMB Password: </tt><b><tt>&lt;re-type new value
86         </tt></b></p><p>If the old value does not match the current value stored for 
87         that user, or the two new values do not match each other, then the 
88         password will not be changed.</p><p>If invoked by an ordinary user it will only allow the user 
89         to change his or her own Samba password.</p><p>If run by the root user smbpasswd may take an optional 
90         argument, specifying the user name whose SMB password you wish to 
91         change.  Note that when run as root smbpasswd does not prompt for 
92         or check the old password value, thus allowing root to set passwords 
93         for users who have forgotten their passwords.</p><p><b>smbpasswd</b> is designed to work in the same way 
94         and be familiar to UNIX users who use the <b>passwd</b> or 
95         <b>yppasswd</b> commands.</p><p>For more details on using <b>smbpasswd</b> refer 
96         to the man page which will always be the definitive reference.</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2883464"></a>Plain text</h2></div></div><p>
97 Older versions of samba retrieved user information from the unix user database 
98 and eventually some other fields from the file <tt>/etc/samba/smbpasswd</tt>
99 or <tt>/etc/smbpasswd</tt>. When password encryption is disabled, no 
100 data is stored at all.
101 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2883493"></a>TDB</h2></div></div><p>Samba can also store the user data in a &quot;TDB&quot; (Trivial Database). Using this backend 
102 doesn't require any additional configuration. This backend is recommended for new installations that 
103 don not require LDAP.
104 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2883509"></a>LDAP</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2883516"></a>Introduction</h3></div></div><p>
105 This document describes how to use an LDAP directory for storing Samba user
106 account information traditionally stored in the smbpasswd(5) file.  It is
107 assumed that the reader already has a basic understanding of LDAP concepts
108 and has a working directory server already installed.  For more information
109 on LDAP architectures and Directories, please refer to the following sites.
110 </p><div class="itemizedlist"><ul type="disc"><li><p>OpenLDAP - <a href="http://www.openldap.org/" target="_top">http://www.openldap.org/</a></p></li><li><p>iPlanet Directory Server - <a href="http://iplanet.netscape.com/directory" target="_top">http://iplanet.netscape.com/directory</a></p></li></ul></div><p>
111 Note that <a href="http://www.ora.com/" target="_top">O'Reilly Publishing</a> is working on
112 a guide to LDAP for System Administrators which has a planned release date of
113 early summer, 2002.
114 </p><p>
115 Two additional Samba resources which may prove to be helpful are
116 </p><div class="itemizedlist"><ul type="disc"><li><p>The <a href="http://www.unav.es/cti/ldap-smb/ldap-smb-3-howto.html" target="_top">Samba-PDC-LDAP-HOWTO</a>
117         maintained by Ignacio Coupeau.</p></li><li><p>The NT migration scripts from <a href="http://samba.idealx.org/" target="_top">IDEALX</a> that are
118         geared to manage users and group in such a Samba-LDAP Domain Controller configuration.
119         </p></li></ul></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2883617"></a>Encrypted Password Database</h3></div></div><p>
120 Traditionally, when configuring <a href="smb.conf.5.html#ENCRYPTPASSWORDS" target="_top">&quot;encrypt
121 passwords = yes&quot;</a> in Samba's <tt>smb.conf</tt> file, user account
122 information such as username, LM/NT password hashes, password change times, and account
123 flags have been stored in the <tt>smbpasswd(5)</tt> file.  There are several
124 disadvantages to this approach for sites with very large numbers of users (counted
125 in the thousands).
126 </p><div class="itemizedlist"><ul type="disc"><li><p>
127 The first is that all lookups must be performed sequentially.  Given that
128 there are approximately two lookups per domain logon (one for a normal
129 session connection such as when mapping a network drive or printer), this
130 is a performance bottleneck for large sites.  What is needed is an indexed approach
131 such as is used in databases.
132 </p></li><li><p>
133 The second problem is that administrators who desired to replicate a
134 smbpasswd file to more than one Samba server were left to use external
135 tools such as <b>rsync(1)</b> and <b>ssh(1)</b>
136 and wrote custom, in-house scripts.
137 </p></li><li><p>
138 And finally, the amount of information which is stored in an
139 smbpasswd entry leaves no room for additional attributes such as
140 a home directory, password expiration time, or even a Relative
141 Identified (RID).
142 </p></li></ul></div><p>
143 As a result of these defeciencies, a more robust means of storing user attributes
144 used by smbd was developed.  The API which defines access to user accounts
145 is commonly referred to as the samdb interface (previously this was called the passdb
146 API, and is still so named in the CVS trees). 
147 </p><p>
148 There are a few points to stress about that the ldapsam
149 does not provide.  The LDAP support referred to in the this documentation does not
150 include:
151 </p><div class="itemizedlist"><ul type="disc"><li><p>A means of retrieving user account information from
152         an Windows 2000 Active Directory server.</p></li><li><p>A means of replacing /etc/passwd.</p></li></ul></div><p>
153 The second item can be accomplished by using LDAP NSS and PAM modules.  LGPL
154 versions of these libraries can be obtained from PADL Software
155 (<a href="http://www.padl.com/" target="_top">http://www.padl.com/</a>). More
156 information about the configuration of these packages may be found at &quot;LDAP,
157 System Administration; Gerald Carter, O'Reilly; Chapter 6: Replacing NIS&quot;.
158 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2883756"></a>Supported LDAP Servers</h3></div></div><p>
159 The LDAP samdb code in 2.2.3 (and later) has been developed and tested
160 using the OpenLDAP 2.0 server and client libraries. 
161 The same code should be able to work with Netscape's Directory Server
162 and client SDK. However, due to lack of testing so far, there are bound
163 to be compile errors and bugs.  These should not be hard to fix.
164 If you are so inclined, please be sure to forward all patches to
165 <a href="mailto:samba-patches@samba.org" target="_top">samba-patches@samba.org</a> and
166 <a href="mailto:jerry@samba.org" target="_top">jerry@samba.org</a>.
167 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2883794"></a>Schema and Relationship to the RFC 2307 posixAccount</h3></div></div><p>
168 Samba 3.0 includes the necessary schema file for OpenLDAP 2.0 in
169 <tt>examples/LDAP/samba.schema</tt>.  The sambaAccount objectclass is given here:
170 </p><pre class="programlisting">
171 objectclass ( 1.3.1.5.1.4.1.7165.2.2.2 NAME 'sambaAccount' SUP top AUXILIARY
172      DESC 'Samba Account'
173      MUST ( uid $ rid )
174      MAY  ( cn $ lmPassword $ ntPassword $ pwdLastSet $ logonTime $
175             logoffTime $ kickoffTime $ pwdCanChange $ pwdMustChange $ acctFlags $
176             displayName $ smbHome $ homeDrive $ scriptPath $ profilePath $
177             description $ userWorkstations $ primaryGroupID $ domain ))
178 </pre><p>
179 The samba.schema file has been formatted for OpenLDAP 2.0.  The OID's are
180 owned by the Samba Team and as such is legal to be openly published.
181 If you translate the schema to be used with Netscape DS, please
182 submit the modified schema file as a patch to <a href="mailto:jerry@samba.org" target="_top">jerry@samba.org</a>
183 </p><p>
184 Just as the smbpasswd file is meant to store information which supplements a
185 user's <tt>/etc/passwd</tt> entry, so is the sambaAccount object
186 meant to supplement the UNIX user account information.  A sambaAccount is a
187 <tt>STRUCTURAL</tt> objectclass so it can be stored individually
188 in the directory.  However, there are several fields (e.g. uid) which overlap
189 with the posixAccount objectclass outlined in RFC2307.  This is by design.
190 </p><p>
191 In order to store all user account information (UNIX and Samba) in the directory,
192 it is necessary to use the sambaAccount and posixAccount objectclasses in
193 combination.  However, smbd will still obtain the user's UNIX account
194 information via the standard C library calls (e.g. getpwnam(), et. al.).
195 This means that the Samba server must also have the LDAP NSS library installed
196 and functioning correctly.  This division of information makes it possible to
197 store all Samba account information in LDAP, but still maintain UNIX account
198 information in NIS while the network is transitioning to a full LDAP infrastructure.
199 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2883904"></a>Configuring Samba with LDAP</h3></div></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2883912"></a>OpenLDAP configuration</h4></div></div><p>
200 To include support for the sambaAccount object in an OpenLDAP directory
201 server, first copy the samba.schema file to slapd's configuration directory.
202 </p><p>
203 <tt>root# </tt><b><tt>cp samba.schema /etc/openldap/schema/</tt></b>
204 </p><p>
205 Next, include the <tt>samba.schema</tt> file in <tt>slapd.conf</tt>.
206 The sambaAccount object contains two attributes which depend upon other schema
207 files.  The 'uid' attribute is defined in <tt>cosine.schema</tt> and
208 the 'displayName' attribute is defined in the <tt>inetorgperson.schema</tt>
209 file.  Both of these must be included before the <tt>samba.schema</tt> file.
210 </p><pre class="programlisting">
211 ## /etc/openldap/slapd.conf
212
213 ## schema files (core.schema is required by default)
214 include            /etc/openldap/schema/core.schema
215
216 ## needed for sambaAccount
217 include            /etc/openldap/schema/cosine.schema
218 include            /etc/openldap/schema/inetorgperson.schema
219 include            /etc/openldap/schema/samba.schema
220 include            /etc/openldap/schema/nis.schema
221
222 ....
223 </pre><p>
224 It is recommended that you maintain some indices on some of the most usefull attributes,
225 like in the following example, to speed up searches made on sambaAccount objectclasses
226 (and possibly posixAccount and posixGroup as well).
227 </p><pre class="programlisting">
228 # Indices to maintain
229 ## required by OpenLDAP 2.0
230 index objectclass   eq
231
232 ## support pb_getsampwnam()
233 index uid           pres,eq
234 ## support pdb_getsambapwrid()
235 index rid           eq
236
237 ## uncomment these if you are storing posixAccount and
238 ## posixGroup entries in the directory as well
239 ##index uidNumber     eq
240 ##index gidNumber     eq
241 ##index cn            eq
242 ##index memberUid     eq
243
244 # (both fetched via ldapsearch):
245 index   primaryGroupID  eq
246 index   displayName     pres,eq
247
248 </pre></div><div class="sect3" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2884030"></a>Configuring Samba</h4></div></div><p>
249 The following parameters are available in smb.conf only with <i><tt>--with-ldapsam</tt></i>
250 was included when compiling Samba.
251 </p><div class="itemizedlist"><ul type="disc"><li><p><a href="smb.conf.5.html#PASSDBBACKEND" target="_top">passdb backend [ldapsam|ldapsam_nua]:url</a></p></li><li><p><a href="smb.conf.5.html#LDAPSSL" target="_top">ldap ssl</a></p></li><li><p><a href="smb.conf.5.html#LDAPADMINDN" target="_top">ldap admin dn</a></p></li><li><p><a href="smb.conf.5.html#LDAPSUFFIX" target="_top">ldap suffix</a></p></li><li><p><a href="smb.conf.5.html#LDAPFILTER" target="_top">ldap filter</a></p></li><li><p><a href="smb.conf.5.html#LDAPPORT" target="_top">ldap port</a></p></li><li><p><a href="smb.conf.5.html#LDAPMACHINSUFFIX" target="_top">ldap machine suffix</a></p></li><li><p><a href="smb.conf.5.html#LDAPUSERSUFFIX" target="_top">ldap user suffix</a></p></li><li><p><a href="smb.conf.5.html#LDAPDELETEDN" target="_top">ldap delete dn</a></p></li></ul></div><p>
252 These are described in the <a href="smb.conf.5.html" target="_top">smb.conf(5)</a> man
253 page and so will not be repeated here.  However, a sample smb.conf file for
254 use with an LDAP directory could appear as
255 </p><pre class="programlisting">
256 ## /usr/local/samba/lib/smb.conf
257 [global]
258      security = user
259      encrypt passwords = yes
260
261      netbios name = TASHTEGO
262      workgroup = NARNIA
263
264      # ldap related parameters
265
266      # define the DN to use when binding to the directory servers
267      # The password for this DN is not stored in smb.conf.  Rather it
268      # must be set by using 'smbpasswd -w <i><tt>secretpw</tt></i>' to store the
269      # passphrase in the secrets.tdb file.  If the &quot;ldap admin dn&quot; values
270      # change, this password will need to be reset.
271      ldap admin dn = &quot;cn=Samba Manager,ou=people,dc=samba,dc=org&quot;
272
273      # Define the SSL option when connecting to the directory
274      # ('off', 'start tls', or 'on' (default))
275      ldap ssl = start tls
276
277      passdb backend ldapsam:ldap://ahab.samba.org
278
279      # smbpasswd -x delete the entire dn-entry
280      ldap delete dn = no
281
282      # the machine and user suffix added to the base suffix
283      # wrote WITHOUT quotes. NULL siffixes by default
284      ldap user suffix = ou=People
285      ldap machine suffix = ou=Systems
286
287      # define the port to use in the LDAP session (defaults to 636 when
288      # &quot;ldap ssl = on&quot;)
289      ldap port = 389
290
291      # specify the base DN to use when searching the directory
292      ldap suffix = &quot;ou=people,dc=samba,dc=org&quot;
293
294      # generally the default ldap search filter is ok
295      # ldap filter = &quot;(&amp;(uid=%u)(objectclass=sambaAccount))&quot;
296 </pre></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2884200"></a>Accounts and Groups management</h3></div></div><p>
297 As users accounts are managed thru the sambaAccount objectclass, you should
298 modify your existing administration tools to deal with sambaAccount attributes.
299 </p><p>
300 Machines accounts are managed with the sambaAccount objectclass, just
301 like users accounts. However, it's up to you to store thoses accounts
302 in a different tree of you LDAP namespace: you should use
303 &quot;ou=Groups,dc=plainjoe,dc=org&quot; to store groups and
304 &quot;ou=People,dc=plainjoe,dc=org&quot; to store users. Just configure your
305 NSS and PAM accordingly (usually, in the /etc/ldap.conf configuration
306 file).
307 </p><p>
308 In Samba release 3.0, the group management system is based on posix
309 groups. This means that Samba makes usage of the posixGroup objectclass.
310 For now, there is no NT-like group system management (global and local
311 groups).
312 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2884237"></a>Security and sambaAccount</h3></div></div><p>
313 There are two important points to remember when discussing the security
314 of sambaAccount entries in the directory.
315 </p><div class="itemizedlist"><ul type="disc"><li><p><span class="emphasis"><em>Never</em></span> retrieve the lmPassword or
316         ntPassword attribute values over an unencrypted LDAP session.</p></li><li><p><span class="emphasis"><em>Never</em></span> allow non-admin users to
317         view the lmPassword or ntPassword attribute values.</p></li></ul></div><p>
318 These password hashes are clear text equivalents and can be used to impersonate
319 the user without deriving the original clear text strings.  For more information
320 on the details of LM/NT password hashes, refer to the <a href="passdb.html" title="Chapter 10. User information database">User Database</a> of the Samba-HOWTO-Collection.
321 </p><p>
322 To remedy the first security issue, the &quot;ldap ssl&quot; smb.conf parameter defaults
323 to require an encrypted session (<b>ldap ssl = on</b>) using
324 the default port of 636
325 when contacting the directory server.  When using an OpenLDAP 2.0 server, it
326 is possible to use the use the StartTLS LDAP extended  operation in the place of
327 LDAPS.  In either case, you are strongly discouraged to disable this security
328 (<b>ldap ssl = off</b>).
329 </p><p>
330 Note that the LDAPS protocol is deprecated in favor of the LDAPv3 StartTLS
331 extended operation.  However, the OpenLDAP library still provides support for
332 the older method of securing communication between clients and servers.
333 </p><p>
334 The second security precaution is to prevent non-administrative users from
335 harvesting password hashes from the directory.  This can be done using the
336 following ACL in <tt>slapd.conf</tt>:
337 </p><pre class="programlisting">
338 ## allow the &quot;ldap admin dn&quot; access, but deny everyone else
339 access to attrs=lmPassword,ntPassword
340      by dn=&quot;cn=Samba Admin,ou=people,dc=plainjoe,dc=org&quot; write
341      by * none
342 </pre></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2884352"></a>LDAP specials attributes for sambaAccounts</h3></div></div><p>
343 The sambaAccount objectclass is composed of the following attributes:
344 </p><div class="itemizedlist"><ul type="disc"><li><p><tt>lmPassword</tt>: the LANMAN password 16-byte hash stored as a character
345         representation of a hexidecimal string.</p></li><li><p><tt>ntPassword</tt>: the NT password hash 16-byte stored as a character
346         representation of a hexidecimal string.</p></li><li><p><tt>pwdLastSet</tt>: The integer time in seconds since 1970 when the
347         <tt>lmPassword</tt> and <tt>ntPassword</tt> attributes were last set.
348         </p></li><li><p><tt>acctFlags</tt>: string of 11 characters surrounded by square brackets []
349         representing account flags such as U (user), W(workstation), X(no password expiration), and
350         D(disabled).</p></li><li><p><tt>logonTime</tt>: Integer value currently unused</p></li><li><p><tt>logoffTime</tt>: Integer value currently unused</p></li><li><p><tt>kickoffTime</tt>: Integer value currently unused</p></li><li><p><tt>pwdCanChange</tt>: Integer value currently unused</p></li><li><p><tt>pwdMustChange</tt>: Integer value currently unused</p></li><li><p><tt>homeDrive</tt>: specifies the drive letter to which to map the
351         UNC path specified by homeDirectory. The drive letter must be specified in the form &quot;X:&quot;
352         where X is the letter of the drive to map. Refer to the &quot;logon drive&quot; parameter in the
353         smb.conf(5) man page for more information.</p></li><li><p><tt>scriptPath</tt>: The scriptPath property specifies the path of
354         the user's logon script, .CMD, .EXE, or .BAT file. The string can be null. The path
355         is relative to the netlogon share.  Refer to the &quot;logon script&quot; parameter in the
356         smb.conf(5) man page for more information.</p></li><li><p><tt>profilePath</tt>: specifies a path to the user's profile.
357         This value can be a null string, a local absolute path, or a UNC path.  Refer to the
358         &quot;logon path&quot; parameter in the smb.conf(5) man page for more information.</p></li><li><p><tt>smbHome</tt>: The homeDirectory property specifies the path of
359         the home directory for the user. The string can be null. If homeDrive is set and specifies
360         a drive letter, homeDirectory should be a UNC path. The path must be a network
361         UNC path of the form \\server\share\directory. This value can be a null string.
362         Refer to the &quot;logon home&quot; parameter in the smb.conf(5) man page for more information.
363         </p></li><li><p><tt>userWorkstation</tt>: character string value currently unused.
364         </p></li><li><p><tt>rid</tt>: the integer representation of the user's relative identifier
365         (RID).</p></li><li><p><tt>primaryGroupID</tt>: the relative identifier (RID) of the primary group
366         of the user.</p></li></ul></div><p>
367 The majority of these parameters are only used when Samba is acting as a PDC of
368 a domain (refer to the <a href="Samba-PDC-HOWTO.html" target="_top">Samba-PDC-HOWTO</a> for details on
369 how to configure Samba as a Primary Domain Controller). The following four attributes
370 are only stored with the sambaAccount entry if the values are non-default values:
371 </p><div class="itemizedlist"><ul type="disc"><li><p>smbHome</p></li><li><p>scriptPath</p></li><li><p>logonPath</p></li><li><p>homeDrive</p></li></ul></div><p>
372 These attributes are only stored with the sambaAccount entry if
373 the values are non-default values.  For example, assume TASHTEGO has now been
374 configured as a PDC and that <b>logon home = \\%L\%u</b> was defined in
375 its <tt>smb.conf</tt> file. When a user named &quot;becky&quot; logons to the domain,
376 the <i><tt>logon home</tt></i> string is expanded to \\TASHTEGO\becky.
377 If the smbHome attribute exists in the entry &quot;uid=becky,ou=people,dc=samba,dc=org&quot;,
378 this value is used.  However, if this attribute does not exist, then the value
379 of the <i><tt>logon home</tt></i> parameter is used in its place.  Samba
380 will only write the attribute value to the directory entry if the value is
381 something other than the default (e.g. \\MOBY\becky).
382 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2884633"></a>Example LDIF Entries for a sambaAccount</h3></div></div><p>
383 The following is a working LDIF with the inclusion of the posixAccount objectclass:
384 </p><pre class="programlisting">
385 dn: uid=guest2, ou=people,dc=plainjoe,dc=org
386 ntPassword: 878D8014606CDA29677A44EFA1353FC7
387 pwdMustChange: 2147483647
388 primaryGroupID: 1201
389 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
390 pwdLastSet: 1010179124
391 logonTime: 0
392 objectClass: sambaAccount
393 uid: guest2
394 kickoffTime: 2147483647
395 acctFlags: [UX         ]
396 logoffTime: 2147483647
397 rid: 19006
398 pwdCanChange: 0
399 </pre><p>
400 The following is an LDIF entry for using both the sambaAccount and
401 posixAccount objectclasses:
402 </p><pre class="programlisting">
403 dn: uid=gcarter, ou=people,dc=plainjoe,dc=org
404 logonTime: 0
405 displayName: Gerald Carter
406 lmPassword: 552902031BEDE9EFAAD3B435B51404EE
407 primaryGroupID: 1201
408 objectClass: posixAccount
409 objectClass: sambaAccount
410 acctFlags: [UX         ]
411 userPassword: {crypt}BpM2ej8Rkzogo
412 uid: gcarter
413 uidNumber: 9000
414 cn: Gerald Carter
415 loginShell: /bin/bash
416 logoffTime: 2147483647
417 gidNumber: 100
418 kickoffTime: 2147483647
419 pwdLastSet: 1010179230
420 rid: 19000
421 homeDirectory: /home/tashtego/gcarter
422 pwdCanChange: 0
423 pwdMustChange: 2147483647
424 ntPassword: 878D8014606CDA29677A44EFA1353FC7
425 </pre></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2884689"></a>MySQL</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2884696"></a>Creating the database</h3></div></div><p>
426 You either can set up your own table and specify the field names to pdb_mysql (see below
427 for the column names) or use the default table. The file <tt>examples/pdb/mysql/mysql.dump</tt> 
428 contains the correct queries to create the required tables. Use the command :
429
430 <b>mysql -u<i><tt>username</tt></i> -h<i><tt>hostname</tt></i> -p<i><tt>password</tt></i> <i><tt>databasename</tt></i> &gt; <tt>/path/to/samba/examples/pdb/mysql/mysql.dump</tt></b>
431
432 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2884750"></a>Configuring</h3></div></div><p>This plugin lacks some good documentation, but here is some short info:</p><p>Add a the following to the <b>passdb backend</b> variable in your <tt>smb.conf</tt>:
433 </p><pre class="programlisting">
434 passdb backend = [other-plugins] mysql:identifier [other-plugins]
435 </pre><p>
436 </p><p>The identifier can be any string you like, as long as it doesn't collide with 
437 the identifiers of other plugins or other instances of pdb_mysql. If you 
438 specify multiple pdb_mysql.so entries in 'passdb backend', you also need to 
439 use different identifiers!
440 </p><p>
441 Additional options can be given thru the smb.conf file in the [global] section.
442 </p><pre class="programlisting">
443 identifier:mysql host                     - host name, defaults to 'localhost'
444 identifier:mysql password
445 identifier:mysql user                     - defaults to 'samba'
446 identifier:mysql database                 - defaults to 'samba'
447 identifier:mysql port                     - defaults to 3306
448 identifier:table                          - Name of the table containing users
449 </pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>
450 Since the password for the mysql user is stored in the 
451 smb.conf file, you should make the the smb.conf file 
452 readable only to the user that runs samba. This is considered a security 
453 bug and will be fixed soon.
454 </p></div><p>Names of the columns in this table(I've added column types those columns should have first):</p><pre class="programlisting">
455 identifier:logon time column             - int(9)
456 identifier:logoff time column            - int(9)
457 identifier:kickoff time column           - int(9)
458 identifier:pass last set time column     - int(9)
459 identifier:pass can change time column   - int(9)
460 identifier:pass must change time column  - int(9)
461 identifier:username column               - varchar(255) - unix username
462 identifier:domain column                 - varchar(255) - NT domain user is part of
463 identifier:nt username column            - varchar(255) - NT username
464 identifier:fullname column               - varchar(255) - Full name of user
465 identifier:home dir column               - varchar(255) - Unix homedir path
466 identifier:dir drive column              - varchar(2)   - Directory drive path (eg: 'H:')
467 identifier:logon script column           - varchar(255)
468                                          - Batch file to run on client side when logging on
469 identifier:profile path column           - varchar(255) - Path of profile
470 identifier:acct desc column              - varchar(255) - Some ASCII NT user data
471 identifier:workstations column           - varchar(255)
472                                          - Workstations user can logon to (or NULL for all)
473 identifier:unknown string column         - varchar(255) - unknown string
474 identifier:munged dial column            - varchar(255) - ?
475 identifier:user sid column               - varchar(255) - NT user SID
476 identifier:group sid column              - varchar(255) - NT group ID
477 identifier:lanman pass column            - varchar(255) - encrypted lanman password
478 identifier:nt pass column                - varchar(255) - encrypted nt passwd
479 identifier:plain pass column             - varchar(255) - plaintext password
480 identifier:acct control column           - int(9) - nt user data
481 identifier:unknown 3 column              - int(9) - unknown
482 identifier:logon divs column             - int(9) - ?
483 identifier:hours len column              - int(9) - ?
484 identifier:unknown 5 column              - int(9) - unknown
485 identifier:unknown 6 column              - int(9) - unknown
486 </pre><p>
487 Eventually, you can put a colon (:) after the name of each column, which 
488 should specify the column to update when updating the table. You can also
489 specify nothing behind the colon - then the data from the field will not be 
490 updated. 
491 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2884895"></a>Using plaintext passwords or encrypted password</h3></div></div><p>
492 I strongly discourage the use of plaintext passwords, however, you can use them:
493 </p><p>
494 If you would like to use plaintext passwords, set
495 'identifier:lanman pass column' and 'identifier:nt pass column' to
496 'NULL' (without the quotes) and 'identifier:plain pass column' to the
497 name of the column containing the plaintext passwords. 
498 </p><p>
499 If you use encrypted passwords, set the 'identifier:plain pass
500 column' to 'NULL' (without the quotes). This is the default.
501 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2884925"></a>Getting non-column data from the table</h3></div></div><p>
502 It is possible to have not all data in the database and making some 'constant'.
503 </p><p>
504 For example, you can set 'identifier:fullname column' to : 
505 <b>CONCAT(First_name,' ',Sur_name)</b>
506 </p><p>
507 Or, set 'identifier:workstations column' to :
508 <b>NULL</b></p><p>See the MySQL documentation for more language constructs.</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2884968"></a>XML</h2></div></div><p>This module requires libxml2 to be installed.</p><p>The usage of pdb_xml is pretty straightforward. To export data, use:
509 </p><p>
510         <b><tt>pdbedit -e xml:filename</tt></b>
511 </p><p>
512 (where filename is the name of the file to put the data in)
513 </p><p>
514 To import data, use:
515 <b><tt>pdbedit -i xml:filename -e current-pdb</tt></b>
516 </p><p>
517 Where filename is the name to read the data from and current-pdb to put it in.
518 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="NetworkBrowsing.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="optional.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="unix-permissions.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 9. Samba / MS Windows Network Browsing Guide </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 11. UNIX Permission Bits and Windows NT Access Control Lists</td></tr></table></div></body></html>