trying to get HEAD building again. If you want the code
[gd/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 administrator 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 sandal. 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. Treat it the right way and it can bring great
42 pleasure, but if you are forced upon it and have no time for its 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 its 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>Administrators of Microsoft networks often refer to 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 accurate 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 In the SMB/CIFS networking world, there are 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 it's 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 expects 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 Please note that there are reports that recent MS Windows clients do not like to work
252 with share mode security servers. You are strongly discouraged from using share level security.
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,
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         security = domain
279         workgroup = "name_of_NT_domain"
280 </programlisting></para>
281
282 <para>
283 In order for this method to work, the Samba server needs to join the MS Windows NT
284 security domain. This is done as follows:
285 </para>
286
287 <procedure>
288         <step><para>On the MS Windows NT domain controller, using
289         the Server Manager, add a machine account for the Samba server.
290         </para></step>
291
292         <step><para>Next, on the Unix/Linux system execute:</para>
293         
294                         <para>&rootprompt;<userinput>smbpasswd -j DOMAIN_NAME -r PDC_NAME</userinput> (samba-2.x)</para>
295
296                         <para>&rootprompt;<userinput>net join -U administrator%password</userinput> (samba-3)</para>
297                 </step>
298 </procedure>
299
300 <note><para>
301 As of Samba-2.2.4 the Samba 2.2.x series can auto-join a Windows NT4 style Domain just
302 by executing:
303 <screen>
304 &rootprompt;<userinput>smbpasswd -j <replaceable>DOMAIN_NAME</replaceable> -r <replaceable>PDC_NAME</replaceable> -U Administrator%<replaceable>password</replaceable></userinput>
305 </screen>
306
307 As of Samba-3 the same can be done by executing:
308 <screen>
309 &rootprompt;<userinput>net join -U Administrator%<replaceable>password</replaceable></userinput>
310 </screen>
311 It is not necessary with Samba-3 to specify the <replaceable>DOMAIN_NAME</replaceable> or the <replaceable>PDC_NAME</replaceable> as it
312 figures this out from the &smb.conf; file settings.
313 </para></note>
314
315 <para>
316 Use of this mode of authentication does require there to be a standard Unix account
317 for each user in order to assign a UID once the account has been authenticated by
318 the remote Windows DC.  This account can be blocked to prevent logons by clients other than
319 MS Windows through means such as setting an invalid shell in the
320 <filename>/etc/passwd</filename> entry.
321 </para>
322
323 <para>
324 An alternative to assigning UIDs to Windows users on a Samba member server is
325 presented in the <link linkend="winbind">Winbind Overview</link> chapter
326 in this HOWTO collection.
327 </para>
328
329 <para>
330 For more information of being a domain member, see the <link linkend="domain-member">Domain
331 Member</link> section of this Howto.
332 </para>
333
334 </sect3>
335 </sect2>
336
337 <sect2>
338 <title>ADS Security Mode (User Level Security)</title>
339
340 <para>
341 Both Samba 2.2 and 3.0 can join an Active Directory domain. This is
342 possible even if the domain is run in native mode. Active Directory in
343 native mode perfectly allows NT4-style domain members, contrary to
344 popular belief. The only thing that Active Directory in native mode
345 prohibits is Backup Domain Controllers running NT4.
346 </para>
347
348 <para>
349 If you are running Active Directory starting with Samba 3.0 you can
350 however join as a native AD member. Why would you want to do that?
351 Your security policy might prohibit the use of NT-compatible
352 authentication protocols. All your machines are running Windows 2000
353 and above and all use full Kerberos. In this case Samba as a NT4-style
354 domain would still require NT-compatible authentication data. Samba in
355 AD-member mode can accept Kerberos.
356 </para>
357
358 <sect3>
359 <title>Example Configuration</title>
360
361 <para><programlisting>
362         realm = your.kerberos.REALM
363         security = ADS
364 </programlisting></para>
365
366 <para>
367         The following parameter may be required:
368 </para>
369
370 <para><programlisting>
371         ads server = your.kerberos.server
372 </programlisting></para>
373
374 <para>
375 Please refer to the <link linkend="domain-member">Domain Membership</link> and <link linkend="ads-member">Active Directory
376 Membership</link> sections for more information regarding this configuration option.
377 </para>
378
379 </sect3>
380 </sect2>
381
382 <sect2>
383 <title>Server Security (User Level Security)</title>
384
385 <para>
386 Server security mode is a left over from the time when Samba was not capable of acting
387 as a domain member server. It is highly recommended NOT to use this feature. Server
388 security mode has many draw backs. The draw backs include:
389 </para>
390
391 <simplelist>
392         <member>Potential Account Lockout on MS Windows NT4/200x password servers</member>
393         <member>Lack of assurance that the password server is the one specified</member>
394         <member>Does not work with Winbind, particularly needed when storing profiles remotely</member>
395         <member>This mode may open connections to the password server, and keep them open for extended periods.</member>
396         <member>Security on the Samba server breaks badly when the remote password server suddenly shuts down</member>
397         <member>With this mode there is NO security account in the domain that the password server belongs to for the Samba server.</member>
398 </simplelist>
399
400 <para>
401 In server security mode the Samba server reports to the client that it is in user level
402 security. The client then does a <emphasis>session setup</emphasis> as described earlier.
403 The Samba server takes the username/password that the client sends and attempts to login to the
404 <parameter>password server</parameter> by sending exactly the same username/password that
405 it got from the client. If that server is in user level security and accepts the password,
406 then Samba accepts the clients connection. This allows the Samba server to use another SMB
407 server as the <parameter>password server</parameter>.
408 </para>
409
410 <para>
411 You should also note that at the very start of all this, where the server tells the client
412 what security level it is in, it also tells the client if it supports encryption. If it
413 does then it supplies the client with a random cryptkey. The client will then send all
414 passwords in encrypted form. Samba supports this type of encryption by default.
415 </para>
416
417 <para>
418 The parameter <parameter>security = server</parameter> means that Samba reports to clients that
419 it is running in <emphasis>user mode</emphasis> but actually passes off all authentication
420 requests to another <emphasis>user mode</emphasis> server. This requires an additional
421 parameter <parameter>password server</parameter> that points to the real authentication server.
422 That real authentication server can be another Samba server or can be a Windows NT server,
423 the later natively capable of encrypted password support.
424 </para>
425
426 <note><para>
427 When Samba is running in <emphasis>server security mode</emphasis> it is essential that
428 the parameter <emphasis>password server</emphasis> is set to the precise NetBIOS machine
429 name of the target authentication server. Samba can NOT determine this from NetBIOS name
430 lookups because the choice of the target authentication server is arbitrary and can not
431 be determined from a domain name. In essence, a Samba server that is in
432 <emphasis>server security mode</emphasis> is operating in what used to be known as
433 workgroup mode.
434 </para></note>
435
436 <sect3>
437 <title>Example Configuration</title>
438 <para><emphasis>
439 Using MS Windows NT as an authentication server
440 </emphasis></para>
441
442 <para>
443 This method involves the additions of the following parameters in the &smb.conf; file:
444 </para>
445
446 <para><programlisting>
447         encrypt passwords = Yes
448         security = server
449         password server = "NetBIOS_name_of_a_DC"
450 </programlisting></para>
451
452
453 <para>
454 There are two ways of identifying whether or not a username and password pair was valid.
455 One uses the reply information provided as part of the authentication messaging
456 process, the other uses just an error code.
457 </para>
458
459 <para>
460 The down-side of this mode of configuration is the fact that for security reasons Samba
461 will send the password server a bogus username and a bogus password and if the remote
462 server fails to reject the username and password pair then an alternative mode of
463 identification of validation is used. Where a site uses password lock out after a
464 certain number of failed authentication attempts this will result in user lockouts.
465 </para>
466
467 <para>
468 Use of this mode of authentication does require there to be a standard Unix account
469 for the user, though this account can be blocked to prevent logons by non-SMB/CIFS clients.
470 </para>
471
472 </sect3>
473 </sect2>
474
475 </sect1>
476
477 <sect1>
478 <title>Seamless Windows Network Integration</title>
479
480 <para>
481 MS Windows clients may use encrypted passwords as part of a challenge/response
482 authentication model (a.k.a. NTLMv1 and NTLMv2) or alone, or clear text strings for simple
483 password based authentication. It should be realized that with the SMB protocol,
484 the password is passed over the network either in plain text or encrypted, but
485 not both in the same authentication request.
486 </para>
487
488 <para>
489 When encrypted passwords are used, a password that has been entered by the user
490 is encrypted in two ways:
491 </para>
492
493 <itemizedlist>
494         <listitem><para>An MD4 hash of the UNICODE of the password
495         string.  This is known as the NT hash.
496         </para></listitem>
497
498         <listitem><para>The password is converted to upper case,
499         and then padded or truncated to 14 bytes.  This string is
500         then appended with 5 bytes of NULL characters and split to
501         form two 56 bit DES keys to encrypt a "magic" 8 byte value.
502         The resulting 16 bytes form the LanMan hash.
503         </para></listitem>
504 </itemizedlist>
505
506 <para>
507 MS Windows 95 pre-service pack 1, MS Windows NT versions 3.x and version 4.0
508 pre-service pack 3 will use either mode of password authentication. All
509 versions of MS Windows that follow these versions no longer support plain
510 text passwords by default.
511 </para>
512
513 <para>
514 MS Windows clients have a habit of dropping network mappings that have been idle
515 for 10 minutes or longer. When the user attempts to use the mapped drive
516 connection that has been dropped, the client re-establishes the connection using
517 a cached copy of the password.
518 </para>
519
520 <para>
521 When Microsoft changed the default password mode, support was dropped for caching
522 of the plain text password. This means that when the registry parameter is changed
523 to re-enable use of plain text passwords it appears to work, but when a dropped
524 service connection mapping attempts to revalidate it will fail if the remote
525 authentication server does not support encrypted passwords.  This means that it
526 is definitely not a good idea to re-enable plain text password support in such clients.
527 </para>
528
529 <para>
530 The following parameters can be used to work around the issue of Windows 9x clients
531 upper casing usernames and password before transmitting them to the SMB server
532 when using clear text authentication.
533 </para>
534
535 <para><programlisting>
536         <ulink url="smb.conf.5.html#PASSWORDLEVEL">password level</ulink> = <replaceable>integer</replaceable>
537         <ulink url="smb.conf.5.html#USERNAMELEVEL">username level</ulink> = <replaceable>integer</replaceable>
538 </programlisting></para>
539
540 <para>
541 By default Samba will lower case the username before attempting to lookup the user
542 in the database of local system accounts.  Because UNIX usernames conventionally
543 only contain lower-case characters, the <parameter>username level</parameter> parameter
544 is rarely needed.
545 </para>
546
547 <para>
548 However, passwords on UNIX systems often make use of mixed-case characters.
549 This means that in order for a user on a Windows 9x client to connect to a Samba
550 server using clear text authentication, the <parameter>password level</parameter>
551 must be set to the maximum number of upper case letters which <emphasis>could</emphasis>
552 appear in a password.  Note that the server OS uses the traditional DES version
553 of crypt(), a <parameter>password level</parameter> of 8 will result in case
554 insensitive passwords as seen from Windows users.  This will also result in longer
555 login times as Samba has to compute the permutations of the password string and
556 try them one by one until a match is located (or all combinations fail).
557 </para>
558
559 <para>
560 The best option to adopt is to enable support for encrypted passwords wherever
561 Samba is used. Most attempts to apply the registry change to re-enable plain text
562 passwords will eventually lead to user complaints and unhappiness.
563 </para>
564
565 </sect1>
566
567 <sect1>
568 <title>Common Errors</title>
569
570 <para>
571 We all make mistakes. It is Ok to make mistakes, so long as they are made in the right places
572 and at the right time. A mistake that causes lost productivity is seldom tolerated. A mistake
573 made in a developmental test lab is expected.
574 </para>
575
576 <para>
577 Here we look at common mistakes and misapprehensions that have been the subject of discussions
578 on the Samba mailing lists. Many of these are avoidable by doing you homework before attempting
579 a Samba implementation. Some are the result of misunderstanding of the English language. The
580 English language has many turns of phrase that are potentially vague and may be highly confusing
581 to those for whom English is not their native tongue.
582 </para>
583
584 <sect2>
585 <title>What makes Samba a SERVER?</title>
586
587 <para>
588 To some the nature of the Samba <emphasis>security</emphasis> mode is very obvious, but entirely
589 wrong all the same. It is assumed that <parameter>security = server</parameter> means that Samba
590 will act as a server. Not so! See above - this setting means that Samba will <emphasis>try</emphasis>
591 to use another SMB server as its source of user authentication alone.
592 </para>
593
594 </sect2>
595
596 <sect2>
597 <title>What makes Samba a Domain Controller?</title>
598
599 <para>
600 The &smb.conf; parameter <parameter>security = domain</parameter> does NOT really make Samba behave
601 as a Domain Controller! This setting means we want Samba to be a domain member!
602 </para>
603
604 </sect2>
605
606 <sect2>
607 <title>What makes Samba a Domain Member?</title>
608
609 <para>
610 Guess! So many others do. But whatever you do, do NOT think that <parameter>security = user</parameter>
611 makes Samba act as a domain member. Read the manufacturers manual before the warranty expires! See 
612 the <link linkend="domain-member">Domain Member</link> section of this Howto for more information.
613 </para>
614
615 </sect2>
616
617
618 <sect2>
619 <title>Constantly Losing Connections to Password Server</title>
620
621 <para>
622 Why does server_validate() simply give up rather than re-establishing its connection to the
623 password server?  Though I am not fluent in the SMB protocol, perhaps the cluster server
624 process passes along to its client workstation the session key it receives from the password
625 server, which means the password hashes submitted by the client would not work on a subsequent
626 connection, whose session key would be different.  So server_validate() must give up.
627 </para>
628
629 <para>
630 Indeed. That's why security = server is at best a nasty hack. Please use security = domain.
631 <parameter>security = server</parameter> mode is also known as pass-through authentication.
632 </para>
633
634 </sect2>
635
636 </sect1>
637
638 </chapter>