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