• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/samba-3.5.8/docs-xml/Samba3-HOWTO/
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>
9
10<title>Server Types and Security Modes</title>
11
12<para>
13<indexterm><primary>migrate</primary></indexterm>
14<indexterm><primary>security mode</primary></indexterm>
15This chapter provides information regarding the types of server that Samba may be configured to be. A
16Microsoft network administrator who wishes to migrate to or use Samba will want to know the meaning, within a
17Samba context, of terms familiar to the MS Windows administrator. This means that it is essential also to
18define how critical security modes function before we get into the details of how to configure the server
19itself.
20</para>
21
22<para>
23This chapter provides an overview of the security modes of which Samba is capable and how they relate to MS
24Windows servers and clients.
25</para>
26
27<para>
28A question often asked is, <quote>Why would I want to use Samba?</quote> Most chapters contain a section that
29highlights features and benefits. We hope that the information provided will help to answer this question. Be
30warned though, we want to be fair and reasonable, so not all features are positive toward Samba. The benefit
31may be on the side of our competition.
32</para>
33
34<sect1>
35<title>Features and Benefits</title>
36
37<para>
38Two men were walking down a dusty road, when one suddenly kicked up a small red stone. It
39hurt his toe and lodged in his sandal. He took the stone out and cursed it with a passion
40and fury befitting his anguish. The other looked at the stone and said, <quote>This is a garnet.
41I can turn that into a precious gem and some day it will make a princess very happy!</quote>
42</para>
43
44<para>
45The moral of this tale: Two men, two very different perspectives regarding the same stone.
46Like it or not, Samba is like that stone. Treat it the right way and it can bring great
47pleasure, but if you are forced to use it and have no time for its secrets, then it can be
48a source of discomfort.
49</para>
50
51<para>
52<indexterm><primary>UNIX</primary><secondary>server</secondary></indexterm>
53<indexterm><primary>interoperability</primary></indexterm>
54Samba started out as a project that sought to provide interoperability for MS Windows 3.x
55clients with a UNIX server. It has grown up a lot since its humble beginnings and now provides
56features and functionality fit for large-scale deployment. It also has some warts. In sections
57like this one, we tell of both.
58</para>
59
60<para>
61So, what are the benefits of the features mentioned in this chapter?
62</para>
63
64<itemizedlist>
65	<listitem><para>
66	<indexterm><primary>domain</primary><secondary>controller</secondary></indexterm>
67	Samba-3 can replace an MS Windows NT4 domain controller.
68	</para></listitem>
69
70	<listitem><para>
71	<indexterm><primary>active directory</primary></indexterm>
72	Samba-3 offers excellent interoperability with MS Windows NT4-style
73	domains as well as natively with Microsoft Active Directory domains.
74	</para></listitem>
75
76	<listitem><para>
77	<indexterm><primary>interdomain</primary><secondary>trustrs</secondary></indexterm>
78	Samba-3 permits full NT4-style interdomain trusts.
79	</para></listitem>
80
81	<listitem><para>
82	<indexterm><primary>authentication</primary></indexterm>
83	<indexterm><primary>security</primary><secondary>modes</secondary></indexterm>
84	Samba has security modes that permit more flexible authentication
85	than is possible with MS Windows NT4 domain controllers.
86	</para></listitem>
87
88	<listitem><para>
89	<indexterm><primary>account</primary><secondary>database</secondary><tertiary>backends</tertiary></indexterm>
90	<indexterm><primary>encrypted</primary></indexterm>
91	Samba-3 permits use of multiple concurrent account database backends.
92	(Encrypted passwords that are stored in the account database are in
93	formats that are unique to Windows networking).
94	</para></listitem>
95
96	<listitem><para>
97	<indexterm><primary>replicated</primary></indexterm>
98	The account database backends can be distributed
99	and replicated using multiple methods. This gives Samba-3
100	greater flexibility than MS Windows NT4 and in many cases a
101	significantly higher utility than Active Directory domains
102	with MS Windows 200x.
103	</para></listitem>
104</itemizedlist>
105
106</sect1>
107
108<sect1>
109<title>Server Types</title>
110
111
112<para>
113<indexterm><primary>Server Type</primary></indexterm>
114Administrators of Microsoft networks often refer to three different types of servers:
115</para>
116
117<itemizedlist>
118	<listitem><para>Domain Controller</para>
119		<itemizedlist>
120			<listitem><para>Primary Domain Controller (PDC)</para></listitem>
121			<listitem><para>Backup Domain Controller (BDC)</para></listitem>
122			<listitem><para>ADS Domain Controller</para></listitem>
123		</itemizedlist>
124	</listitem>
125	<listitem><para>Domain Member Server</para>
126		<itemizedlist>
127			<listitem><para>Active Directory Domain Server</para></listitem>
128			<listitem><para>NT4 Style Domain Domain Server</para></listitem>
129		</itemizedlist>
130	</listitem>
131	<listitem><para>Standalone Server</para></listitem>
132</itemizedlist>
133
134<para>
135<indexterm><primary>domain</primary><secondary>control</secondary></indexterm>
136<indexterm><primary>domain</primary><secondary>member</secondary></indexterm>
137<indexterm><primary>domain control</primary><secondary>primary</secondary></indexterm>
138<indexterm><primary>domain control</primary><secondary>backup</secondary></indexterm>
139The chapters covering domain control (<link linkend="samba-pdc">Domain Control</link>), 
140backup domain control (<link linkend="samba-bdc">Backup Domain Control</link>), and 
141domain membership (<link linkend="domain-member">Domain Membership</link>) provide
142pertinent information regarding Samba configuration for each of these server roles.
143You are strongly encouraged to become intimately familiar with these chapters because
144they lay the foundation for deployment of Samba domain security.
145</para>
146
147<para>
148<indexterm><primary>standalone</primary></indexterm>
149A Standalone server is autonomous in respect of the source of its account backend.
150Refer to <link linkend="StandAloneServer">Standalone Servers</link> to gain a wider appreciation
151of what is meant by a server being configured as a <emphasis>standalone</emphasis> server.
152</para>
153
154</sect1>
155
156<sect1>
157<title>Samba Security Modes</title>
158
159
160<para>
161<indexterm><primary>Security Mode</primary></indexterm>
162<indexterm><primary>security</primary></indexterm>
163In this section, the function and purpose of Samba's security modes are described. An accurate understanding of
164how Samba implements each security mode as well as how to configure MS Windows clients for each mode will
165significantly reduce user complaints and administrator heartache.
166</para>
167
168<para>
169<indexterm><primary>Server Message Block</primary><see>SMB</see></indexterm>
170<indexterm><primary>Common Internet Filesystem</primary><see>CIFS</see></indexterm>
171Microsoft Windows networking uses a protocol that was originally called the Server Message Block (SMB)
172protocol. Since some time around 1996 the protocol has been better known as the Common Internet Filesystem
173(CIFS) protocol.
174</para>
175
176<para>
177<indexterm><primary>security levels</primary></indexterm>
178<indexterm><primary>security modes</primary></indexterm>
179<indexterm><primary>user-level</primary></indexterm>
180<indexterm><primary>share-level</primary></indexterm>
181In the SMB/CIFS networking world, there are only two types of security: <emphasis>user-level</emphasis> and
182<emphasis>share level</emphasis>. We refer to these collectively as <emphasis>security levels</emphasis>.  In
183implementing these two security levels, Samba provides flexibilities that are not available with MS Windows
184NT4/200x servers. In fact, Samba implements <emphasis>share-level</emphasis> security only one way, but has
185four ways of implementing <emphasis>user-level</emphasis> security. Collectively, we call the Samba
186implementations of the security levels <emphasis>security modes</emphasis>. They are known as
187<emphasis>share</emphasis>, <emphasis>user</emphasis>, <emphasis>domain</emphasis>, <emphasis>ADS</emphasis>,
188and <emphasis>server</emphasis> modes.  They are documented in this chapter.
189</para>
190
191<para>
192An SMB server informs the client, at the time of a session setup, the security level the server is running.
193There are two options: share-level and user-level. Which of these two the client receives affects the way the
194client then tries to authenticate itself. It does not directly affect (to any great extent) the way the Samba
195server does security. This may sound strange, but it fits in with the client/server approach of SMB.  In SMB
196everything is initiated and controlled by the client, and the server can only tell the client what is
197available and whether an action is allowed.
198</para>
199
200<para>
201The term <literal>client</literal> refers to all agents whether it is a Windows workstation, a Windows server,
202another Samba server, or any vanilla SMB or CIFS client application (e.g., <command>smbclient</command>) that
203make use of services provided by an SMB/CIFS server.
204</para>
205
206<sect2>
207<title>User Level Security</title>
208
209<para>
210<indexterm><primary>user-level</primary></indexterm>
211We describe user-level security first because its simpler.  In user-level security, the client sends a session
212setup request directly following protocol negotiation.  This request provides a username and password. The
213server can either accept or reject that username/password combination. At this stage the server has no idea
214what share the client will eventually try to connect to, so it can't base the
215<emphasis>accept/reject</emphasis> on anything other than:
216</para>
217
218<orderedlist>
219<listitem><para>the username/password.</para></listitem>
220<listitem><para>the name of the client machine.</para></listitem>
221</orderedlist>
222
223<para>
224<indexterm><primary>credentials</primary></indexterm>
225If the server accepts the username/password credentials, the client expects to be able to mount shares (using
226a <emphasis>tree connection</emphasis>) without further specifying a password. It expects that all access
227rights will be as the username/password credentials set that was specified in the initial <emphasis>session
228setup</emphasis>.
229</para>
230
231<para>
232<indexterm><primary>session setup</primary></indexterm>
233It is also possible for a client to send multiple <emphasis>session setup</emphasis>
234requests. When the server responds, it gives the client a <emphasis>uid</emphasis> to use
235as an authentication tag for that username/password. The client can maintain multiple
236authentication contexts in this way (WinDD is an example of an application that does this).
237</para>
238
239<para>
240<indexterm><primary>LanManager</primary></indexterm>
241<indexterm><primary>case-preserving</primary></indexterm>
242<indexterm><primary>case-insensitive</primary></indexterm>
243<indexterm><primary>upper-case</primary></indexterm>
244<indexterm><primary>lower-case</primary></indexterm>
245Windows networking user account names are case-insensitive, meaning that upper-case and lower-case characters
246in the account name are considered equivalent. They are said to be case-preserving, but not case significant.
247Windows and LanManager systems previous to Windows NT version 3.10 have case-insensitive passwords that were
248not necessarily case-preserving. All Windows NT family systems treat passwords as case-preserving and
249case-sensitive.
250</para>
251
252<sect3>
253<title>Example Configuration</title>
254
255<para>
256The &smb.conf; parameter that sets user-level security is:
257</para>
258
259<para><smbconfblock>
260<smbconfoption name="security">user</smbconfoption>
261</smbconfblock></para>
262
263<para>
264This is the default setting since Samba-2.2.x.
265</para>
266
267</sect3>
268
269</sect2>
270<sect2>
271<title>Share-Level Security</title>
272
273<para>
274<indexterm><primary>share-level</primary></indexterm>
275<indexterm><primary>mount</primary></indexterm>
276In share-level security, the client authenticates itself separately for each share. It sends a password along
277with each tree connection request (share mount), but it does not explicitly send a username with this
278operation. The client expects a password to be associated with each share, independent of the user. This means
279that Samba has to work out what username the client probably wants to use,
280because the username is not explicitly sent to the SMB server. Some commercial SMB servers such as NT actually associate passwords directly with shares
281in share-level security, but Samba always uses the UNIX authentication scheme where it is a username/password
282pair that is authenticated, not a share/password pair.
283</para>
284
285<para>
286To understand the MS Windows networking parallels, think in terms of MS Windows 9x/Me where you can create a
287shared folder that provides read-only or full access, with or without a password.
288</para>
289
290<para>
291Many clients send a session setup request even if the server is in share-level security. They normally send a valid
292username but no password. Samba records this username in a list of possible usernames. When the client then
293issues a tree connection request, it also adds to this list the name of the share they try to connect to (useful for
294home directories) and any users listed in the <smbconfoption name="user"/> parameter in the &smb.conf; file.
295The password is then checked in turn against these possible usernames. If a match is found, then the client is
296authenticated as that user.
297</para>
298
299<para>
300<indexterm><primary>name service switch</primary><see>NSS</see></indexterm>
301<indexterm><primary>/etc/passwd</primary></indexterm>
302<indexterm><primary>nsswitch.conf</primary></indexterm>
303Where the list of possible user names is not provided, Samba makes a UNIX system call to find the user
304account that has a password that matches the one provided from the standard account database. On a system that
305has no name service switch (NSS) facility, such lookups will be from the <filename>/etc/passwd</filename>
306database. On NSS enabled systems, the lookup will go to the libraries that have been specified in the
307<filename>nsswitch.conf</filename> file. The entries in that file in which the libraries are specified are:
308<screen>
309passwd: files nis ldap
310shadow: files nis ldap
311group: files nis ldap
312</screen>
313<indexterm><primary>/etc/passwd</primary></indexterm>
314<indexterm><primary>/etc/group</primary></indexterm>
315<indexterm><primary>NIS</primary></indexterm>
316In the example shown here (not likely to be used in practice) the lookup will check
317<filename>/etc/passwd</filename> and <filename>/etc/group</filename>, if not found it will check NIS, then
318LDAP.
319</para>
320
321<sect3>
322<title>Example Configuration</title>
323
324<para>
325The &smb.conf; parameter that sets share-level security is:
326</para>
327
328<para><smbconfblock>
329<smbconfoption name="security">share</smbconfoption>
330</smbconfblock></para>
331
332</sect3>
333</sect2>
334
335<sect2>
336<title>Domain Security Mode (User-Level Security)</title>
337
338<para>
339<indexterm><primary>domain</primary><secondary>controllers</secondary></indexterm>
340<indexterm><primary>security</primary><secondary>controllers</secondary></indexterm>
341<indexterm><primary>PDC</primary></indexterm>
342<indexterm><primary>BDC</primary></indexterm>
343<indexterm><primary>logon</primary></indexterm>
344<indexterm><primary>authentication</primary></indexterm>
345Domain security provides a mechanism for storing all user and group accounts in a central, shared, account
346repository. The centralized account repository is shared between domain (security) controllers. Servers that
347act as domain controllers provide authentication and validation services to all machines that participate in
348the security context for the domain. A primary domain controller (PDC) is a server that is responsible for
349maintaining the integrity of the security account database. Backup domain controllers (BDCs) provide only domain
350logon and authentication services. Usually, BDCs will answer network logon requests more responsively than
351will a PDC.
352</para>
353
354<para>
355<indexterm><primary>domain member</primary></indexterm>
356<indexterm><primary>trust account</primary></indexterm>
357<indexterm><primary>trust</primary><secondary>account</secondary></indexterm>
358<indexterm><primary>domain</primary><secondary>security</secondary></indexterm>
359<indexterm><primary>domain</primary><secondary>controller</secondary></indexterm>
360When Samba is operating in <smbconfoption name="security">domain</smbconfoption> mode, the Samba server has a
361domain security trust account (a machine account) and causes all authentication requests to be passed through
362to the domain controllers.  In other words, this configuration makes the Samba server a domain member server,
363even when it is in fact acting as a domain controller. All machines that participate in domain security must
364have a machine account in the security database.
365</para>
366
367<para>
368<indexterm><primary>account</primary><secondary>database</secondary></indexterm>
369<indexterm><primary>machine</primary><secondary>account</secondary></indexterm>
370<indexterm><primary>NetBIOS</primary><secondary>name</secondary></indexterm>
371<indexterm><primary>NetBIOS</primary></indexterm>
372Within the domain security environment, the underlying security architecture uses user-level security. Even
373machines that are domain members must authenticate on startup. The machine account consists of an account
374entry in the accounts database, the name of which is the NetBIOS name of the machine and of which the password
375is randomly generated and known to both the domain controllers and the member machine. If the machine account
376cannot be validated during startup, users will not be able to log on to the domain using this machine because
377it cannot be trusted. The machine account is referred to as a machine trust account.
378</para>
379
380<para>
381There are three possible domain member configurations:
382</para>
383
384<orderedlist>
385	<listitem><para>Primary domain controller (PDC) - of which there is one per domain.</para></listitem>
386	<listitem><para>Backup domain controller (BDC) - of which there can be any number per domain.</para></listitem>
387	<listitem><para>Domain member server (DMS) - of which there can be any number per domain.</para></listitem>
388</orderedlist>
389
390<para>
391<indexterm><primary>DMS</primary></indexterm>
392We will discuss each of these in separate chapters. For now, we are most interested in basic DMS
393configuration.
394</para>
395
396<sect3>
397<title>Example Configuration</title>
398<para><emphasis>
399Samba as a Domain Member Server
400</emphasis></para>
401
402
403<para>
404<indexterm><primary>server type</primary><secondary>domain member</secondary></indexterm>
405This method involves addition of the following parameters in the &smb.conf; file:
406<smbconfblock>
407<smbconfoption name="security">domain</smbconfoption>
408<smbconfoption name="workgroup">&example.workgroup;</smbconfoption>
409</smbconfblock>
410</para>
411
412<para>
413In order for this method to work, the Samba server needs to join the MS Windows NT
414security domain. This is done as follows:
415<indexterm><primary>net</primary><secondary>rpc</secondary></indexterm>
416<indexterm><primary>Domain Member</primary><secondary>joining</secondary></indexterm>
417</para>
418
419
420<procedure>
421        <step><para>On the MS Windows NT domain controller, using
422        the Server Manager, add a machine account for the Samba server.
423        </para></step>
424
425        <step><para>On the UNIX/Linux system execute:</para>
426	
427			<para><screen>&rootprompt;<userinput>net rpc join -U administrator%password</userinput></screen></para>
428		</step>
429</procedure>
430
431<note><para>
432<indexterm><primary>smbpasswd</primary></indexterm>
433Samba-2.2.4 and later Samba 2.2.x series releases can autojoin a Windows NT4-style domain just by executing:
434<screen>
435&rootprompt;<userinput>smbpasswd -j <replaceable>DOMAIN_NAME</replaceable> -r <replaceable>PDC_NAME</replaceable> \
436	 -U Administrator%<replaceable>password</replaceable></userinput>
437</screen>
438<indexterm><primary>net</primary><secondary>rpc</secondary><tertiary>join</tertiary></indexterm>
439Samba-3 can do the same by executing:
440<screen>
441&rootprompt;<userinput>net rpc join -U Administrator%<replaceable>password</replaceable></userinput>
442</screen>
443It is not necessary with Samba-3 to specify the <replaceable>DOMAIN_NAME</replaceable> or the
444<replaceable>PDC_NAME</replaceable>, as it figures this out from the &smb.conf; file settings.
445</para></note>
446
447<para>
448<indexterm><primary>invalid shell</primary></indexterm>
449<indexterm><primary>/etc/passwd</primary></indexterm>
450<indexterm><primary>/bin/false</primary></indexterm>
451Use of this mode of authentication requires there to be a standard UNIX account for each user in order to
452assign a UID once the account has been authenticated by the Windows domain controller. This account can be
453blocked to prevent logons by clients other than MS Windows through means such as setting an invalid shell in
454the <filename>/etc/passwd</filename> entry. The best way to allocate an invalid shell to a user account is to
455set the shell to the file <filename>/bin/false</filename>.
456</para>
457
458<para>
459<indexterm><primary>PDC</primary></indexterm>
460<indexterm><primary>BDC</primary></indexterm>
461Domain controllers can be located anywhere that is convenient. The best advice is to have a BDC on every
462physical network segment, and if the PDC is on a remote network segment the use of WINS (see <link
463linkend="NetworkBrowsing">Network Browsing</link> for more information) is almost essential.
464</para>
465
466<para>
467An alternative to assigning UIDs to Windows users on a Samba member server is presented in <link
468linkend="winbind">Winbind</link>, <link linkend="winbind">Winbind: Use of Domain Accounts</link>.
469</para>
470
471<para>
472For more information regarding domain membership, <link linkend="domain-member">Domain Membership</link>.
473</para>
474
475</sect3>
476</sect2>
477
478<sect2>
479<title>ADS Security Mode (User-Level Security)</title>
480
481<para>
482<indexterm><primary>ADS</primary></indexterm>
483<indexterm><primary>native mode</primary></indexterm>
484Both Samba-2.2, and Samba-3 can join an Active Directory domain using NT4 style RPC based security.  This is
485possible if the domain is run in native mode. Active Directory in native mode perfectly allows NT4-style
486domain members. This is contrary to popular belief.
487</para>
488
489<para>
490If you are using Active Directory, starting with Samba-3 you can join as a native AD member. Why would you
491want to do that?  Your security policy might prohibit the use of NT-compatible authentication protocols. All
492your machines are running Windows 2000 and above and all use Kerberos. In this case, Samba, as an NT4-style
493domain, would still require NT-compatible authentication data. Samba in AD-member mode can accept Kerberos
494tickets.
495</para>
496
497<para>
498<indexterm><primary>realm</primary></indexterm>
499<indexterm><primary>mixed mode</primary></indexterm>
500Sites that use Microsoft Windows active directory services (ADS) should be aware of the significance of the
501terms: <literal>native mode</literal> and <literal>mixed mode</literal> ADS operation. The term
502<literal>realm</literal> is used to describe a Kerberos-based security architecture (such as is used by
503Microsoft ADS).
504</para>
505
506<sect3>
507<title>Example Configuration</title>
508
509<para><smbconfblock>
510<smbconfoption name="realm">your.kerberos.REALM</smbconfoption>
511<smbconfoption name="security">ADS</smbconfoption>
512</smbconfblock></para>
513
514<para>
515The following parameter may be required:
516</para>
517
518<para><smbconfblock>
519<smbconfoption name="password server">your.kerberos.server</smbconfoption>
520</smbconfblock></para>
521
522<para>
523Please refer to <link linkend="domain-member">Domain Membership</link>, and <link linkend="ads-member">Samba
524ADS Domain Membership</link> for more information regarding this configuration option.
525</para>
526
527</sect3>
528</sect2>
529
530<sect2>
531<title>Server Security (User Level Security)</title>
532
533<para>
534Server security mode is left over from the time when Samba was not capable of acting
535as a domain member server. It is highly recommended not to use this feature. Server
536security mode has many drawbacks that include:
537</para>
538
539<itemizedlist>
540	<listitem><para>Potential account lockout on MS Windows NT4/200x password servers.</para></listitem>
541	<listitem><para>Lack of assurance that the password server is the one specified.</para></listitem>
542	<listitem><para>Does not work with Winbind, which is particularly needed when storing profiles remotely.</para></listitem>
543	<listitem><para>This mode may open connections to the password server and keep them open for extended periods.</para></listitem>
544	<listitem><para>Security on the Samba server breaks badly when the remote password server suddenly shuts down.</para></listitem>
545	<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>
546</itemizedlist>
547
548<para>
549<indexterm><primary>session setup</primary></indexterm>
550<indexterm><primary>SMB</primary></indexterm>
551In server security mode the Samba server reports to the client that it is in user-level security. The client
552then does a session setup as described earlier.  The Samba server takes the username/password that the client
553sends and attempts to log into the <smbconfoption name="password server"/> by sending exactly the same
554username/password that it got from the client. If that server is in user-level security and accepts the
555password, then Samba accepts the client's connection. This parameter allows the Samba server to use another
556SMB server as the <smbconfoption name="password server"/>.
557</para>
558
559<para>
560<indexterm><primary>security level</primary></indexterm>
561<indexterm><primary>encryption</primary></indexterm>
562You should also note that at the start of all this, when the server tells the client
563what security level it is in, it also tells the client if it supports encryption. If it
564does, it supplies the client with a random cryptkey. The client will then send all
565passwords in encrypted form. Samba supports this type of encryption by default.
566</para>
567
568<para>
569The parameter <smbconfoption name="security">server</smbconfoption> means that Samba reports to clients that
570it is running in <emphasis>user mode</emphasis> but actually passes off all authentication requests to another
571user mode server. This requires an additional parameter <smbconfoption name="password server"/> that points to
572the real authentication server.  The real authentication server can be another Samba server, or it can be a
573Windows NT server, the latter being natively capable of encrypted password support.
574</para>
575
576<note><para>
577<indexterm><primary>password server</primary></indexterm>
578<indexterm><primary>workgroup</primary></indexterm>
579When Samba is running in <emphasis>server security mode</emphasis>, it is essential that the parameter
580<emphasis>password server</emphasis> is set to the precise NetBIOS machine name of the target authentication
581server. Samba cannot determine this from NetBIOS name lookups because the choice of the target authentication
582server is arbitrary and cannot be determined from a domain name. In essence, a Samba server that is in
583<emphasis>server security mode</emphasis> is operating in what used to be known as workgroup mode.
584</para></note>
585
586<sect3>
587<title>Example Configuration</title>
588<para><emphasis>
589Using MS Windows NT as an Authentication Server
590</emphasis></para>
591
592<para>
593This method involves the additions of the following parameters in the &smb.conf; file:
594</para>
595
596<para><smbconfblock>
597<smbconfoption name="encrypt passwords">Yes</smbconfoption>
598<smbconfoption name="security">server</smbconfoption>
599<smbconfoption name="password server">"NetBIOS_name_of_a_DC"</smbconfoption>
600</smbconfblock></para>
601
602
603<para>
604There are two ways of identifying whether or not a username and password pair is valid.
605One uses the reply information provided as part of the authentication messaging
606process, the other uses just an error code.
607</para>
608
609<para>
610<indexterm><primary>bogus</primary></indexterm>
611<indexterm><primary>lockout</primary></indexterm>
612The downside of this mode of configuration is that for security reasons Samba
613will send the password server a bogus username and a bogus password, and if the remote
614server fails to reject the bogus username and password pair, then an alternative mode of
615identification or validation is used. Where a site uses password lockout, after a
616certain number of failed authentication attempts, this will result in user lockouts.
617</para>
618
619<para>
620Use of this mode of authentication requires a standard UNIX account for the user.
621This account can be blocked to prevent logons by non-SMB/CIFS clients.
622</para>
623
624</sect3>
625</sect2>
626
627</sect1>
628
629<sect1>
630<title>Password Checking</title>
631
632<para>
633MS Windows clients may use encrypted passwords as part of a challenge/response
634authentication model (a.k.a. NTLMv1 and NTLMv2) or alone, or clear-text strings for simple
635password-based authentication. It should be realized that with the SMB protocol,
636the password is passed over the network either in plaintext or encrypted, but
637not both in the same authentication request.
638</para>
639
640<para>
641<indexterm><primary>encrypted passwords</primary></indexterm>
642<indexterm><primary>encrypted</primary></indexterm>
643When encrypted passwords are used, a password that has been entered by the user
644is encrypted in two ways:
645</para>
646
647<itemizedlist>
648        <listitem><para>An MD4 hash of the unicode of the password
649        string. This is known as the NT hash.
650        </para></listitem>
651
652        <listitem><para>The password is converted to uppercase,
653        and then padded or truncated to 14 bytes. This string is
654        then appended with 5 bytes of NULL characters and split to
655        form two 56-bit DES keys to encrypt a "magic" 8-byte value.
656        The resulting 16 bytes form the LanMan hash.
657        </para></listitem>
658</itemizedlist>
659
660<para>
661<indexterm><primary>plain-text</primary><secondary>passwords</secondary></indexterm>
662MS Windows 95 pre-service pack 1 and MS Windows NT versions 3.x and version 4.0 pre-service pack 3 will use
663either mode of password authentication. All versions of MS Windows that follow these versions no longer
664support plain-text passwords by default.
665</para>
666
667<para>
668<indexterm><primary>cached</primary><secondary>password</secondary></indexterm>
669MS Windows clients have a habit of dropping network mappings that have been idle
670for 10 minutes or longer. When the user attempts to use the mapped drive
671connection that has been dropped, the client re-establishes the connection using
672a cached copy of the password.
673</para>
674
675<para>
676When Microsoft changed the default password mode, support was dropped for caching
677of the plaintext password. This means that when the registry parameter is changed
678to re-enable use of plaintext passwords, it appears to work, but when a dropped
679service connection mapping attempts to revalidate, this will fail if the remote
680authentication server does not support encrypted passwords. It is definitely not
681a good idea to re-enable plaintext password support in such clients.
682</para>
683
684<para>
685The following parameters can be used to work around the issue of Windows 9x/Me clients
686uppercasing usernames and passwords before transmitting them to the SMB server
687when using clear-text authentication:
688</para>
689
690
691<?latex \newpage ?>
692<smbconfblock>
693<smbconfoption name="password level"><replaceable>integer</replaceable></smbconfoption>
694<smbconfoption name="username level"><replaceable>integer</replaceable></smbconfoption>
695</smbconfblock>
696
697<para>
698By default Samba will convert to lowercase the username before attempting to lookup the user
699in the database of local system accounts. Because UNIX usernames conventionally
700only contain lowercase characters, the <smbconfoption name="username-level"/> parameter
701is rarely needed.
702</para>
703
704<para>
705<indexterm><primary>clear-text</primary></indexterm>
706However, passwords on UNIX systems often make use of mixed-case characters.  This means that in order for a
707user on a Windows 9x/Me client to connect to a Samba server using clear-text authentication, the
708<smbconfoption name="password level"/> must be set to the maximum number of uppercase letters that
709<emphasis>could</emphasis> appear in a password. Note that if the Server OS uses the traditional DES version
710of crypt(), a <smbconfoption name="password level"/> of 8 will result in case-insensitive passwords as seen
711from Windows users. This will also result in longer login times because Samba has to compute the permutations
712of the password string and try them one by one until a match is located (or all combinations fail).
713</para>
714
715<para>
716The best option to adopt is to enable support for encrypted passwords wherever
717Samba is used. Most attempts to apply the registry change to re-enable plaintext
718passwords will eventually lead to user complaints and unhappiness.
719</para>
720
721</sect1>
722
723<sect1>
724<title>Common Errors</title>
725
726<para>
727We all make mistakes. It is okay to make mistakes, as long as they are made in the right places
728and at the right time. A mistake that causes lost productivity is seldom tolerated; however, a mistake
729made in a developmental test lab is expected.
730</para>
731
732<para>
733Here we look at common mistakes and misapprehensions that have been the subject of discussions
734on the Samba mailing lists. Many of these are avoidable by doing your homework before attempting
735a Samba implementation. Some are the result of a misunderstanding of the English language,
736which has many phrases that are potentially vague and may be highly confusing
737to those for whom English is not their native tongue.
738</para>
739
740<sect2>
741<title>What Makes Samba a Server?</title>
742
743<para>
744To some, the nature of the Samba security mode is obvious, but entirely
745wrong all the same. It is assumed that <smbconfoption name="security">server</smbconfoption> means that Samba
746will act as a server. Not so! This setting means that Samba will <emphasis>try</emphasis>
747to use another SMB server as its source for user authentication alone.
748</para>
749
750<para>
751Samba is a server regardless of which security mode is chosen. When Samba is used outside of a domain security
752context, it is best to leave the security mode at the default setting. By default Samba-3 uses user-mode
753security.
754</para>
755
756</sect2>
757
758<sect2>
759<title>What Makes Samba a Domain Controller?</title>
760
761<para>
762<indexterm><primary>server-mode</primary></indexterm>
763The &smb.conf; parameter <smbconfoption name="security">domain</smbconfoption> does not really make Samba behave
764as a domain controller. This setting means we want Samba to be a domain member. See <link
765linkend="samba-pdc">Samba as a PDC</link> for more information.
766</para>
767
768</sect2>
769
770<sect2>
771<title>What Makes Samba a Domain Member?</title>
772
773<para>
774Guess! So many others do. But whatever you do, do not think that <smbconfoption name="security">user</smbconfoption>
775makes Samba act as a domain member. Read the manufacturer's manual before the warranty expires. See 
776<link linkend="domain-member">Domain Membership</link>, for more information.
777</para>
778
779</sect2>
780
781
782<sect2>
783<title>Constantly Losing Connections to Password Server</title>
784
785<para><quote>
786Why does server_validate() simply give up rather than re-establish its connection to the
787password server?  Though I am not fluent in the SMB protocol, perhaps the cluster server
788process passes along to its client workstation the session key it receives from the password
789server, which means the password hashes submitted by the client would not work on a subsequent
790connection whose session key would be different. So server_validate() must give up.
791</quote></para>
792
793<para>
794Indeed. That's why <smbconfoption name="security">server</smbconfoption>
795is at best a nasty hack. Please use <smbconfoption name="security">domain</smbconfoption>;
796<smbconfoption name="security">server</smbconfoption> mode is also known as pass-through authentication.
797</para>
798
799</sect2>
800
801<sect2>
802<title>Stand-alone Server is converted to Domain Controller &smbmdash; Now User accounts don't work</title>
803
804<para><quote>
805When I try to log in to the DOMAIN, the eventlog shows <emphasis>tried credentials DOMAIN/username; effective
806credentials SERVER/username</emphasis>
807</quote></para>
808
809<para>
810Usually this is due to a user or machine account being created before the Samba server is configured to be a
811domain controller. Accounts created before the server becomes a domain controller will be
812<emphasis>local</emphasis> accounts and authenticated as what looks like a member in the SERVER domain, much
813like local user accounts in Windows 2000 and later.  Accounts created after the Samba server becomes a domain
814controller will be <emphasis>domain</emphasis> accounts and will be authenticated as a member of the DOMAIN
815domain.
816</para>
817
818<para>
819This can be verified by issuing the command <command>pdbedit -L -v username</command>.  If this reports DOMAIN
820then the account is a domain account, if it reports SERVER then the account is a local account.
821</para>
822
823<para>
824The easiest way to resolve this is to remove and recreate the account; however this may cause problems with
825established user profiles. You can also use <command>pdbedit -u username -I DOMAIN</command>. You may also
826need to change the User SID and Primary Group SID to match the domain.
827</para>
828
829</sect2>
830
831</sect1>
832
833</chapter>
834