More updates in the reorg.
[Samba.git] / docs / Samba-HOWTO-Collection / ServerType.xml
blobcd7f578cc08be3fed07aaf81c9136227a870efed
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="ServerType">
4 <chapterinfo>
5         &author.tridge;
6         &author.jelmer;
7         &author.jht;
8 </chapterinfo>
10 <title>Server Types and Security Modes</title>
12 <para>
13 This chapter provides information regarding the types of server that Samba may be
14 configured to be. A Microsoft network administrator who wishes to migrate to or
15 use Samba will want to know the meaning, within a Samba context, of terms familiar to MS Windows
16 administrator. This means that it is essential also to define how critical security
17 modes function before we get into the details of how to configure the server itself.
18 </para>
20 <para>
21 The chapter provides an overview of the security modes of which Samba is capable
22 and how they relate to MS Windows servers and clients.
23 </para>
25 <para>
26 A question often asked is, <quote>Why would I want to use Samba?</quote> Most chapters contain a section
27 that highlights features and benefits. We hope that the information provided will help to
28 answer this question. Be warned though, we want to be fair and reasonable, so not all
29 features are positive towards Samba. The benefit may be on the side of our competition.
30 </para>
32 <sect1>
33 <title>Features and Benefits</title>
35 <para>
36 Two men were walking down a dusty road, when one suddenly kicked up a small red stone. It
37 hurt his toe and lodged in his sandal. He took the stone out and cursed it with a passion
38 and fury befitting his anguish. The other looked at the stone and said, <quote>This is a garnet.
39 I can turn that into a precious gem and some day it will make a princess very happy!</quote>
40 </para>
42 <para>
43 The moral of this tale: Two men, two very different perspectives regarding the same stone.
44 Like it or not, Samba is like that stone. Treat it the right way and it can bring great
45 pleasure, but if you are forced to use it and have no time for its secrets, then it can be
46 a source of discomfort.
47 </para>
49 <para>
50 Samba started out as a project that sought to provide interoperability for MS Windows 3.x
51 clients with a UNIX server. It has grown up a lot since its humble beginnings and now provides
52 features and functionality fit for large scale deployment. It also has some warts. In sections
53 like this one we tell of both.
54 </para>
56 <para>
57 So, what are the benefits of features mentioned in this chapter?
58 </para>
60 <itemizedlist>
61         <listitem><para>
62         Samba-3 can replace an MS Windows NT4 Domain Controller.
63         </para></listitem>
65         <listitem><para>
66         Samba-3 offers excellent interoperability with MS Windows NT4-style
67         domains as well as natively with Microsoft Active Directory domains.
68         </para></listitem>
70         <listitem><para>
71         Samba-3 permits full NT4-style Interdomain Trusts.
72         </para></listitem>
74         <listitem><para>
75         Samba has security modes that permit more flexible
76         authentication than is possible with MS Windows NT4 Domain Controllers.
77         </para></listitem>
79         <listitem><para>
80         Samba-3 permits use of multiple account database backends.
81         </para></listitem>
83         <listitem><para>
84         The account (password) database backends can be distributed
85         and replicated using multiple methods. This gives Samba-3
86         greater flexibility than MS Windows NT4 and in many cases a
87         significantly higher utility than Active Directory domains
88         with MS Windows 200x.
89         </para></listitem>
90 </itemizedlist>
92 </sect1>
94 <sect1>
95 <title>Server Types</title>
98 <para>
99 <indexterm><primary>Server Type</primary></indexterm>
100 Administrators of Microsoft networks often refer to three
101 different type of servers:</para>
103 <itemizedlist>
104         <listitem><para>Domain Controller</para>
105                 <itemizedlist>
106                         <listitem><para>Primary Domain Controller</para></listitem>
107                         <listitem><para>Backup Domain Controller</para></listitem>
108                         <listitem><para>ADS Domain Controller</para></listitem>
109                 </itemizedlist>
110         </listitem>
111         <listitem><para>Domain Member Server</para>
112                 <itemizedlist>
113                         <listitem><para>Active Directory Domain Server</para></listitem>
114                         <listitem><para>NT4 Style Domain Domain Server</para></listitem>
115                 </itemizedlist>
116         </listitem>
117         <listitem><para>Stand-alone Server</para></listitem>
118 </itemizedlist>
120 <para>
121 The chapters covering Domain Control, Backup Domain Control and Domain Membership provide
122 pertinent information regarding Samba configuration for each of these server roles.
123 The reader is strongly encouraged to become intimately familiar with the information 
124 presented.
125 </para>
127 </sect1>
129 <sect1>
130 <title>Samba Security Modes</title>
133 <para>
134 <indexterm><primary>Security Mode</primary></indexterm>
135 <indexterm><primary>security</primary></indexterm>
136 In this section the function and purpose of Samba's security
137 modes are described. An accurate understanding of how Samba implements each security
138 mode as well as how to configure MS Windows clients for each mode will significantly
139 reduce user complaints and administrator heartache.
140 </para>
142 <para>
143 In the SMB/CIFS networking world, there are only two types of security: <emphasis>User Level</emphasis>
144 and <emphasis>Share Level</emphasis>. We refer to these collectively as <emphasis>security levels</emphasis>.
145 In implementing these two security levels, Samba provides flexibilities
146 that are not available with Microsoft Windows NT4/200x servers. In actual fact, Samba implements
147 <emphasis>Share Level</emphasis> security only one way, but has four ways of implementing
148 <emphasis>User Level</emphasis> security. Collectively, we call the Samba implementations
149 <emphasis>Security Modes</emphasis>. They are known as: <emphasis>SHARE</emphasis>, <emphasis>USER</emphasis>,
150 <emphasis>DOMAIN</emphasis>, <emphasis>ADS</emphasis>, and <emphasis>SERVER</emphasis> modes.
151 They are documented in this chapter.
152 </para>
154 <para>
155 An SMB server tells the client at startup what security level it is running. There are two options:
156 Share Level and User Level. Which of these two the client receives affects the way the client then
157 tries to authenticate itself. It does not directly affect (to any great extent) the way the Samba
158 server does security. This may sound strange, but it fits in with the client/server approach of SMB.
159 In SMB everything is initiated and controlled by the client, and the server can only tell the client
160 what is available and whether an action is allowed.
161 </para>
163 <sect2>
164 <title>User Level Security</title>
166 <para>
167 We will describe User Level Security first, as its simpler.
168 In User Level Security, the client will send a
169 session setup request directly following protocol negotiation.
170 This request provides a username and password. The server can either accept or reject that
171 username/password combination. At this stage the server has no idea what
172 share the client will eventually try to connect to, so it can't base the
173 <emphasis>accept/reject</emphasis> on anything other than:
174 </para>
176 <orderedlist>
177 <listitem><para>the username/password.</para></listitem>
178 <listitem><para>the name of the client machine.</para></listitem>
179 </orderedlist>
181 <para>
182 If the server accepts the username/password then the client expects to be able to
183 mount shares (using a <emphasis>tree connection</emphasis>) without specifying a
184 password. It expects that all access rights will be as the username/password
185 specified in the <emphasis>session setup</emphasis>.
186 </para>
188 <para>
189 It is also possible for a client to send multiple <emphasis>session setup</emphasis>
190 requests. When the server responds, it gives the client a <emphasis>uid</emphasis> to use
191 as an authentication tag for that username/password. The client can maintain multiple
192 authentication contexts in this way (WinDD is an example of an application that does this).
193 </para>
195 <sect3>
196 <title>Example Configuration</title>
198 <para>
199 The &smb.conf; parameter that sets user level security is:
200 </para>
202 <para><smbconfblock>
203 <smbconfoption name="security">user</smbconfoption>
204 </smbconfblock></para>
206 <para>
207 This is the default setting since Samba-2.2.x.
208 </para>
210 </sect3>
212 </sect2>
213 <sect2>
214 <title>Share Level Security</title>
216 <para>
217 In Share Level security, the client authenticates
218 itself separately for each share. It sends a password along with each 
219 tree connection (share mount). It does not explicitly send a
220 username with this operation. The client expects a password to be associated
221 with each share, independent of the user. This means that Samba has to work out what
222 username the client probably wants to use. It is never explicitly sent the username.
223 Some commercial SMB servers such as NT actually associate passwords directly with
224 shares in Share Level security, but Samba always uses the UNIX authentication scheme
225 where it is a username/password pair that is authenticated, not a share/password pair.
226 </para>
228 <para>
229 To understand the MS Windows networking parallels, one should think
230 in terms of MS Windows 9x/Me where one can create a shared folder that provides read-only
231 or full access, with or without a password.
232 </para>
234 <para>
235 Many clients send a session setup even if the server is in Share Level security. They
236 normally send a valid username but no password. Samba records this username in a list
237 of possible usernames. When the client then does a tree connection it also adds to this list the name
238 of the share they try to connect to (useful for home directories) and any users
239 listed in the <smbconfoption name="user"/> parameter in the &smb.conf; file.
240 The password is then checked in turn against these possible usernames. If a match is found
241 then the client is authenticated as that user.
242 </para>
244 <sect3>
245 <title>Example Configuration</title>
247 <para>
248 The &smb.conf; parameter that sets Share Level security is:
249 </para>
251 <para><smbconfblock>
252 <smbconfoption name="security">share</smbconfoption>
253 </smbconfblock></para>
255 </sect3>
256 </sect2>
258 <sect2>
259 <title>Domain Security Mode (User Level Security)</title>
261 <para>
262 <indexterm><primary>Domain Member</primary></indexterm>
263 When Samba is operating in <smbconfoption name="security">domain</smbconfoption> mode,
264 the Samba server has a domain security trust account (a machine account) and causes
265 all authentication requests to be passed through to the Domain Controllers.
266 In other words, this configuration makes the Samba server a Domain Member server.
267 </para>
269 <sect3>
270 <title>Example Configuration</title>
271 <para><emphasis>
272 Samba as a Domain Member Server
273 </emphasis></para>
276 <para>
277 <indexterm><primary>Server Type</primary><secondary>Domain Member</secondary></indexterm>
278 This method involves addition of the following parameters in the &smb.conf; file:
279 </para>
281 <para><smbconfblock>
282 <smbconfoption name="security">domain</smbconfoption>
283 <smbconfoption name="workgroup">&example.workgroup;</smbconfoption>
284 </smbconfblock></para>
286 <para>
287 In order for this method to work, the Samba server needs to join the MS Windows NT
288 security domain. This is done as follows:
289 <indexterm><primary>net</primary><secondary>rpc</secondary></indexterm>
290 <indexterm><primary>Domain Member</primary><secondary>joining</secondary></indexterm>
291 </para>
294 <procedure>
295         <step><para>On the MS Windows NT Domain Controller, using
296         the Server Manager, add a machine account for the Samba server.
297         </para></step>
299         <step><para>On the UNIX/Linux system execute:</para>
300         
301                         <para><screen>&rootprompt;<userinput>net rpc join -U administrator%password</userinput></screen></para>
302                 </step>
303 </procedure>
305 <note><para>
306 Samba-2.2.4 and later can auto-join a Windows NT4-style Domain just by executing:
307 <screen>
308 &rootprompt;<userinput>smbpasswd -j <replaceable>DOMAIN_NAME</replaceable> -r <replaceable>PDC_NAME</replaceable> \
309          -U Administrator%<replaceable>password</replaceable></userinput>
310 </screen>
312 Samba-3 can do the same by executing:
313 <screen>
314 &rootprompt;<userinput>net rpc join -U Administrator%<replaceable>password</replaceable></userinput>
315 </screen>
316 It is not necessary with Samba-3 to specify the <replaceable>DOMAIN_NAME</replaceable> or the
317 <replaceable>PDC_NAME</replaceable> as it figures this out from the &smb.conf; file settings.
318 </para></note>
320 <para>
321 Use of this mode of authentication does require there to be a standard UNIX account
322 for each user in order to assign a UID once the account has been authenticated by
323 the remote Windows DC. This account can be blocked to prevent logons by clients other than
324 MS Windows through means such as setting an invalid shell in the
325 <filename>/etc/passwd</filename> entry.
326 </para>
328 <para>
329 An alternative to assigning UIDs to Windows users on a Samba member server is
330 presented in <link linkend="winbind">Winbind: Use of Domain Accounts</link>.
331 </para>
333 <para>
334 For more information regarding Domain Membership, see <link linkend="domain-member">Domain Membership</link>.
335 </para>
337 </sect3>
338 </sect2>
340 <sect2>
341 <title>ADS Security Mode (User Level Security)</title>
343 <para>
344 Both Samba-2.2, and Samba-3 can join an Active Directory domain. This is
345 possible if the domain is run in native mode. Active Directory in
346 native mode perfectly allows NT4-style Domain Members. This is contrary to
347 popular belief. Active Directory in native mode prohibits only the use of
348 Backup Domain Controllers running MS Windows NT4.
349 </para>
351 <para>
352 If you are using Active Directory, starting with Samba-3 you can
353 join as a native AD member. Why would you want to do that?
354 Your security policy might prohibit the use of NT-compatible
355 authentication protocols. All your machines are running Windows 2000
356 and above and all use Kerberos. In this case Samba as an NT4-style
357 domain would still require NT-compatible authentication data. Samba in
358 AD-member mode can accept Kerberos tickets.
359 </para>
361 <sect3>
362 <title>Example Configuration</title>
364 <para><smbconfblock>
365 <smbconfoption name="realm">your.kerberos.REALM</smbconfoption>
366 <smbconfoption name="security">ADS</smbconfoption>
367 </smbconfblock></para>
369 <para>
370 The following parameter may be required:
371 </para>
373 <para><smbconfblock>
374 <smbconfoption name="password server">your.kerberos.server</smbconfoption>
375 </smbconfblock></para>
377 <para>
378 Please refer to <link linkend="domain-member">Domain Membership</link> and <link linkend="ads-member">Samba ADS Domain Membership</link>
379 for more information regarding this configuration option.
380 </para>
382 </sect3>
383 </sect2>
385 <sect2>
386 <title>Server Security (User Level Security)</title>
388 <para>
389 Server Security Mode is left over from the time when Samba was not capable of acting
390 as a Domain Member server. It is highly recommended not to use this feature. Server
391 security mode has many drawbacks that include:
392 </para>
394 <itemizedlist>
395         <listitem><para>Potential Account Lockout on MS Windows NT4/200x password servers.</para></listitem>
396         <listitem><para>Lack of assurance that the password server is the one specified.</para></listitem>
397         <listitem><para>Does not work with Winbind, which is particularly needed when storing profiles remotely.</para></listitem>
398         <listitem><para>This mode may open connections to the password server, and keep them open for extended periods.</para></listitem>
399         <listitem><para>Security on the Samba server breaks badly when the remote password server suddenly shuts down.</para></listitem>
400         <listitem><para>With this mode there is NO security account in the domain that the password server belongs to for the Samba server.</para></listitem>
401 </itemizedlist>
403 <para>
404 In Server Security Mode the Samba server reports to the client that it is in User Level
405 security. The client then does a session setup as described earlier.
406 The Samba server takes the username/password that the client sends and attempts to login to the
407 <smbconfoption name="password server"/> by sending exactly the same username/password that
408 it got from the client. If that server is in User Level Security and accepts the password,
409 then Samba accepts the client's connection. This allows the Samba server to use another SMB
410 server as the <smbconfoption name="password server"/>.
411 </para>
413 <para>
414 You should also note that at the start of all this where the server tells the client
415 what security level it is in, it also tells the client if it supports encryption. If it
416 does, it supplies the client with a random cryptkey. The client will then send all
417 passwords in encrypted form. Samba supports this type of encryption by default.
418 </para>
420 <para>
421 The parameter <smbconfoption name="security">server</smbconfoption> means that Samba reports to clients that
422 it is running in <emphasis>user mode</emphasis> but actually passes off all authentication
423 requests to another <emphasis>user mode</emphasis> server. This requires an additional
424 parameter <smbconfoption name="password server"/> that points to the real authentication server.
425 The real authentication server can be another Samba server, or it can be a Windows NT server,
426 the latter being natively capable of encrypted password support.
427 </para>
429 <note><para>
430 When Samba is running in <emphasis>Server Security Mode</emphasis> it is essential that
431 the parameter <emphasis>password server</emphasis> is set to the precise NetBIOS machine
432 name of the target authentication server. Samba cannot determine this from NetBIOS name
433 lookups because the choice of the target authentication server is arbitrary and cannot
434 be determined from a domain name. In essence, a Samba server that is in
435 <emphasis>Server Security Mode</emphasis> is operating in what used to be known as
436 workgroup mode.
437 </para></note>
439 <sect3>
440 <title>Example Configuration</title>
441 <para><emphasis>
442 Using MS Windows NT as an Authentication Server
443 </emphasis></para>
445 <para>
446 This method involves the additions of the following parameters in the &smb.conf; file:
447 </para>
449 <para><smbconfblock>
450 <smbconfoption name="encrypt passwords">Yes</smbconfoption>
451 <smbconfoption name="security">server</smbconfoption>
452 <smbconfoption name="password server">"NetBIOS_name_of_a_DC"</smbconfoption>
453 </smbconfblock></para>
456 <para>
457 There are two ways of identifying whether or not a username and password pair is valid.
458 One uses the reply information provided as part of the authentication messaging
459 process, the other uses just an error code.
460 </para>
462 <para>
463 The downside of this mode of configuration is the fact that for security reasons Samba
464 will send the password server a bogus username and a bogus password and if the remote
465 server fails to reject the username and password pair then an alternative mode of
466 identification of validation is used. Where a site uses password lock out after a
467 certain number of failed authentication attempts this will result in user lockouts.
468 </para>
470 <para>
471 Use of this mode of authentication requires a standard UNIX account for the user.
472 This account can be blocked to prevent logons by non-SMB/CIFS clients.
473 </para>
475 </sect3>
476 </sect2>
478 </sect1>
480 <sect1>
481 <title>Password Checking</title>
483 <para>
484 MS Windows clients may use encrypted passwords as part of a challenge/response
485 authentication model (a.k.a. NTLMv1 and NTLMv2) or alone, or clear-text strings for simple
486 password-based authentication. It should be realized that with the SMB protocol,
487 the password is passed over the network either in plain-text or encrypted, but
488 not both in the same authentication request.
489 </para>
491 <para>
492 When encrypted passwords are used, a password that has been entered by the user
493 is encrypted in two ways:
494 </para>
496 <itemizedlist>
497         <listitem><para>An MD4 hash of the unicode of the password
498         string. This is known as the NT hash.
499         </para></listitem>
501         <listitem><para>The password is converted to upper case,
502         and then padded or truncated to 14 bytes. This string is
503         then appended with 5 bytes of NULL characters and split to
504         form two 56-bit DES keys to encrypt a <quote>magic</quote> 8-byte value.
505         The resulting 16 bytes form the LanMan hash.
506         </para></listitem>
507 </itemizedlist>
509 <para>
510 MS Windows 95 pre-service pack 1, MS Windows NT versions 3.x and version 4.0
511 pre-service pack 3 will use either mode of password authentication. All
512 versions of MS Windows that follow these versions no longer support plain
513 text passwords by default.
514 </para>
516 <para>
517 MS Windows clients have a habit of dropping network mappings that have been idle
518 for 10 minutes or longer. When the user attempts to use the mapped drive
519 connection that has been dropped, the client re-establishes the connection using
520 a cached copy of the password.
521 </para>
523 <para>
524 When Microsoft changed the default password mode, support was dropped for caching
525 of the plain-text password. This means that when the registry parameter is changed
526 to re-enable use of plain-text passwords it appears to work, but when a dropped
527 service connection mapping attempts to revalidate, this will fail if the remote
528 authentication server does not support encrypted passwords. It is definitely not
529 a good idea to re-enable plain-text password support in such clients.
530 </para>
532 <para>
533 The following parameters can be used to work around the issue of Windows 9x/Me clients
534 upper-casing usernames and passwords before transmitting them to the SMB server
535 when using clear-text authentication:
536 </para>
538 <para><smbconfblock>
539 <smbconfoption name="password level"><replaceable>integer</replaceable></smbconfoption>
540 <smbconfoption name="username level"><replaceable>integer</replaceable></smbconfoption>
541 </smbconfblock></para>
543 <para>
544 By default Samba will convert to lower case the username before attempting to lookup the user
545 in the database of local system accounts. Because UNIX usernames conventionally
546 only contain lower-case characters, the <smbconfoption name="username level"/> parameter
547 is rarely needed.
548 </para>
550 <para>
551 However, passwords on UNIX systems often make use of mixed-case characters.
552 This means that in order for a user on a Windows 9x/Me client to connect to a Samba
553 server using clear-text authentication, the <smbconfoption name="password level"/>
554 must be set to the maximum number of upper case letters that <emphasis>could</emphasis>
555 appear in a password. Note that if the server OS uses the traditional DES version
556 of crypt(), a <smbconfoption name="password level"/> of 8 will result in case
557 insensitive passwords as seen from Windows users. This will also result in longer
558 login times as Samba has to compute the permutations of the password string and
559 try them one by one until a match is located (or all combinations fail).
560 </para>
562 <para>
563 The best option to adopt is to enable support for encrypted passwords wherever
564 Samba is used. Most attempts to apply the registry change to re-enable plain-text
565 passwords will eventually lead to user complaints and unhappiness.
566 </para>
568 </sect1>
570 <sect1>
571 <title>Common Errors</title>
573 <para>
574 We all make mistakes. It is okay to make mistakes, as long as they are made in the right places
575 and at the right time. A mistake that causes lost productivity is seldom tolerated, however a mistake
576 made in a developmental test lab is expected.
577 </para>
579 <para>
580 Here we look at common mistakes and misapprehensions that have been the subject of discussions
581 on the Samba mailing lists. Many of these are avoidable by doing your homework before attempting
582 a Samba implementation. Some are the result of a misunderstanding of the English language. The
583 English language, which has many phrases that are potentially vague and may be highly confusing
584 to those for whom English is not their native tongue.
585 </para>
587 <sect2>
588 <title>What Makes Samba a Server?</title>
590 <para>
591 To some the nature of the Samba <emphasis>security</emphasis> mode is obvious, but entirely
592 wrong all the same. It is assumed that <smbconfoption name="security">server</smbconfoption> means that Samba
593 will act as a server. Not so! This setting means that Samba will <emphasis>try</emphasis>
594 to use another SMB server as its source for user authentication alone.
595 </para>
597 </sect2>
599 <sect2>
600 <title>What Makes Samba a Domain Controller?</title>
602 <para>
603 The &smb.conf; parameter <smbconfoption name="security">domain</smbconfoption> does not really make Samba behave
604 as a Domain Controller. This setting means we want Samba to be a Domain Member. See <link linkend="samba-pdc">Samba as a PDC</link> for more information.
605 </para>
607 </sect2>
609 <sect2>
610 <title>What Makes Samba a Domain Member?</title>
612 <para>
613 Guess! So many others do. But whatever you do, do not think that <smbconfoption name="security">user</smbconfoption>
614 makes Samba act as a Domain Member. Read the manufacturer's manual before the warranty expires. See 
615 <link linkend="domain-member">Domain Membership</link> for more information.
616 </para>
618 </sect2>
621 <sect2>
622 <title>Constantly Losing Connections to Password Server</title>
624 <para>
625         <quote>
626 Why does server_validate() simply give up rather than re-establish its connection to the
627 password server?  Though I am not fluent in the SMB protocol, perhaps the cluster server
628 process passes along to its client workstation the session key it receives from the password
629 server, which means the password hashes submitted by the client would not work on a subsequent
630 connection whose session key would be different. So server_validate() must give up.</quote>
631 </para>
633 <para>
634 Indeed. That's why <smbconfoption name="security">server</smbconfoption>
635 is at best a nasty hack. Please use <smbconfoption name="security">domain</smbconfoption>;
636 <smbconfoption name="security">server</smbconfoption> mode is also known as pass-through authentication.
637 </para>
639 </sect2>
641 </sect1>
643 </chapter>