1 <chapter id="ServerType">
8 <title>Server Types and Security Modes</title>
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.
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.
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.
30 <title>Features and Benefits</title>
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!
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.
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.
54 So now, what are the benefits of features mentioned in this chapter?
59 Samba-3 can replace an MS Windows NT4 Domain Controller
63 Samba-3 offers excellent interoperability with MS Windows NT4
64 style domains as well as natively with Microsoft Active
69 Samba-3 permits full NT4 style Interdomain Trusts
73 Samba has security modes that permit more flexible
74 authentication than is possible with MS Windows NT4 Domain Controllers.
78 Samba-3 permits use of multiple account database backends
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
93 <title>Server Types</title>
95 <para>Administrators of Microsoft networks often refer to three
96 different type of servers:</para>
99 <listitem><para>Domain Controller</para>
101 <member>Primary Domain Controller</member>
102 <member>Backup Domain Controller</member>
103 <member>ADS Domain Controller</member>
106 <listitem><para>Domain Member Server</para>
108 <member>Active Directory Member Server</member>
109 <member>NT4 Style Domain Member Server</member>
112 <listitem><para>Stand Alone Server</para></listitem>
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
125 <title>Samba Security Modes</title>
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.
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.
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.
158 <title>User Level Security</title>
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:
171 <listitem><para>The username/password</para></listitem>
172 <listitem><para>The name of the client machine</para></listitem>
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>.
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).
190 <title>Example Configuration</title>
193 The &smb.conf; parameter that sets <emphasis>User Level Security</emphasis> is:
196 <para><programlisting>
198 </programlisting></para>
201 This is the default setting since samba-2.2.x.
208 <title>Share Level Security</title>
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.
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.
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.
240 <title>Example Configuration</title>
243 The &smb.conf; parameter that sets <emphasis>Share Level Security</emphasis> is:
246 <para><programlisting>
248 </programlisting></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.
259 <title>Domain Security Mode (User Level Security)</title>
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.
268 <title>Example Configuration</title>
270 Samba as a Domain Member Server
274 This method involves addition of the following parameters in the &smb.conf; file:
277 <para><programlisting>
279 workgroup = "name_of_NT_domain"
280 </programlisting></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:
288 <step><para>On the MS Windows NT domain controller, using
289 the Server Manager, add a machine account for the Samba server.
292 <step><para>Next, on the Unix/Linux system execute:</para>
294 <para>&rootprompt;<userinput>smbpasswd -j DOMAIN_NAME -r PDC_NAME</userinput> (samba-2.x)</para>
296 <para>&rootprompt;<userinput>net join -U administrator%password</userinput> (samba-3)</para>
301 As of Samba-2.2.4 the Samba 2.2.x series can auto-join a Windows NT4 style Domain just
304 &rootprompt;<userinput>smbpasswd -j <replaceable>DOMAIN_NAME</replaceable> -r <replaceable>PDC_NAME</replaceable> -U Administrator%<replaceable>password</replaceable></userinput>
307 As of Samba-3 the same can be done by executing:
309 &rootprompt;<userinput>net join -U Administrator%<replaceable>password</replaceable></userinput>
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.
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.
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.
330 For more information of being a domain member, see the <link linkend="domain-member">Domain
331 Member</link> section of this Howto.
338 <title>ADS Security Mode (User Level Security)</title>
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.
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.
359 <title>Example Configuration</title>
361 <para><programlisting>
362 realm = your.kerberos.REALM
364 </programlisting></para>
367 The following parameter may be required:
370 <para><programlisting>
371 ads server = your.kerberos.server
372 </programlisting></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.
383 <title>Server Security (User Level Security)</title>
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:
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>
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>.
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.
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.
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
437 <title>Example Configuration</title>
439 Using MS Windows NT as an authentication server
443 This method involves the additions of the following parameters in the &smb.conf; file:
446 <para><programlisting>
447 encrypt passwords = Yes
449 password server = "NetBIOS_name_of_a_DC"
450 </programlisting></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.
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.
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.
478 <title>Seamless Windows Network Integration</title>
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.
489 When encrypted passwords are used, a password that has been entered by the user
490 is encrypted in two ways:
494 <listitem><para>An MD4 hash of the UNICODE of the password
495 string. This is known as the NT hash.
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.
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.
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.
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.
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.
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>
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
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).
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.
568 <title>Common Errors</title>
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.
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.
585 <title>What makes Samba a SERVER?</title>
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.
597 <title>What makes Samba a Domain Controller?</title>
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!
607 <title>What makes Samba a Domain Member?</title>
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.
619 <title>Constantly Losing Connections to Password Server</title>
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.
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.