Better conformance to DocBook standards
[Samba.git] / docs / Samba-HOWTO-Collection / DomainMember.xml
blobd1f2386d54b4f03b9a983060b9efef7555c90898
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3                 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
5   <!-- entities files to use -->
6   <!ENTITY % global_entities SYSTEM '../entities/global.entities'>
7   %global_entities;
9 ]>
11 <chapter id="domain-member">
13 <chapterinfo>
14         &author.jht;
15         &author.jeremy;
16         &author.jerry;
17         &author.tridge;
18         &author.jelmer;
19         <author>&person.gd;<contrib>LDAP updates</contrib></author>
20 </chapterinfo>
22 <title>Domain Membership</title>
24 <para>
25 Domain Membership is a subject of vital concern. Samba must be able to
26 participate as a member server in a Microsoft Domain Security context, and
27 Samba must be capable of providing Domain machine member trust accounts,
28 otherwise it would not be able to offer a viable option for many users.
29 </para>
31 <para>
32 This chapter covers background information pertaining to Domain Membership,
33 the Samba configuration for it, and MS Windows client procedures for joining a
34 domain. Why is this necessary? Because both are areas in which there exists
35 within the current MS Windows networking world and particularly in the
36 UNIX/Linux networking and administration world, a considerable level of
37 misinformation, incorrect understanding and a lack of knowledge. Hopefully
38 this chapter will fill the voids.
39 </para>
41 <sect1>
42 <title>Features and Benefits</title>
44 <para>
45 MS Windows workstations and servers that want to participate in Domain Security need to
46 be made Domain Members. Participating in Domain Security is often called 
47 <emphasis>Single Sign On</emphasis> or <acronym>SSO</acronym> for short. This
48 chapter describes the process that must be followed to make a workstation
49 (or another server &smbmdash; be it an <application>MS Windows NT4 / 200x</application>
50 server) or a Samba server a member of an MS Windows Domain Security context.
51 </para>
53 <para>
54 <indexterm><primary>Server Type</primary><secondary>Domain Member</secondary></indexterm>
55 Samba-3 can join an MS Windows NT4-style domain as a native member server, an 
56 MS Windows Active Directory Domain as a native member server, or a Samba Domain
57 Control network. Domain Membership has many advantages:
58 </para>
60 <itemizedlist>
61         <listitem><para>
62 <indexterm><primary>SAM</primary></indexterm>
63         MS Windows workstation users get the benefit of SSO.
64         </para></listitem>
66         <listitem><para>
67         Domain user access rights and file ownership/access controls can be set
68         from the single Domain Security Account Manager (SAM) database 
69         (works with Domain Member servers as well as with MS Windows workstations
70         that are Domain Members).
71         </para></listitem>
73         <listitem><para>
74         Only <application>MS Windows NT4/200x/XP Professional</application>
75         workstations that are Domain Members can use network logon facilities.
76         </para></listitem>
78         <listitem><para>
79         Domain Member workstations can be better controlled through the use of
80         Policy files (<filename>NTConfig.POL</filename>) and Desktop Profiles.
81         </para></listitem>
83         <listitem><para>
84         Through the use of logon scripts, users can be given transparent access to network
85         applications that run off application servers.
86         </para></listitem>
88         <listitem><para>
89         Network administrators gain better application and user access management
90         abilities because there is no need to maintain user accounts on any network
91         client or server, other than the central Domain database 
92         (either NT4/Samba SAM style Domain, NT4 Domain that is backend-ed with an
93         LDAP directory, or via an Active Directory infrastructure).
94         </para></listitem>
95 </itemizedlist>
97 </sect1>
99 <sect1 id="machine-trust-accounts">
100 <title>MS Windows Workstation/Server Machine Trust Accounts</title>
102 <para>
103 <indexterm><primary>Machine Trust Accounts</primary></indexterm>
104 A Machine Trust Account is an account that is used to authenticate a client
105 machine (rather than a user) to the Domain Controller server. In Windows terminology,
106 this is known as a <quote>Computer Account.</quote> The purpose of the machine account
107 is to prevent a rogue user and Domain Controller from colluding to gain access to a 
108 domain member workstation.
109 </para>
111 <para>
112 The password of a Machine Trust Account acts as the shared secret for
113 secure communication with the Domain Controller. This is a security
114 feature to prevent an unauthorized machine with the same NetBIOS name
115 from joining the domain and gaining access to domain user/group
116 accounts. Windows NT/200x/XP Professional clients use machine trust
117 accounts, but Windows 9x/Me/XP Home clients do not. Hence, a
118 Windows 9x/Me/XP Home client is never a true member of a Domain
119 because it does not possess a Machine Trust Account, and, thus, has no
120 shared secret with the Domain Controller.
121 </para>
123 <para>
124 A Windows NT4 PDC stores each Machine Trust Account in the Windows Registry.
125 The introduction of MS Windows 2000 saw the introduction of Active Directory,
126 the new repository for Machine Trust Accounts. A Samba PDC, however, stores
127 each Machine Trust Account in two parts,
128 as follows:
130 <itemizedlist>
131         <listitem><para>
132         A Domain Security Account (stored in the 
133         <smbconfoption><name>passdb backend</name></smbconfoption> that has been configured in the
134         &smb.conf; file. The precise nature of the account information that is
135         stored depends on the type of backend database that has been chosen.
136         </para>
138         <para>
139         The older format of this data is the <filename>smbpasswd</filename> database
140         that contains the UNIX login ID, the UNIX user identifier (UID), and the
141         LanMan and NT encrypted passwords. There is also some other information in
142         this file that we do not need to concern ourselves with here.
143         </para>
145         <para>
146         The two newer database types are called ldapsam, and
147         tdbsam. Both store considerably more data than the
148         older <filename>smbpasswd</filename> file did. The extra information
149         enables new user account controls to be implemented.
150         </para></listitem>
152         <listitem><para>
153         A corresponding UNIX account, typically stored in
154         <filename>/etc/passwd</filename>. Work is in progress to allow a
155         simplified mode of operation that does not require UNIX user accounts, but
156         this may not be a feature of the early releases of Samba-3.
157         </para></listitem>
158 </itemizedlist>
159 </para>
161 <para>
162 <indexterm><primary>Machine Trust Accounts</primary><secondary>creating</secondary></indexterm>
163 There are three ways to create Machine Trust Accounts:
164 </para>
166 <itemizedlist>
167         <listitem><para>
168         Manual creation from the UNIX/Linux command line. Here, both the Samba and
169         corresponding UNIX account are created by hand.
170         </para></listitem>
172         <listitem><para>
173         <indexterm><primary>Server Manager</primary></indexterm>
174         Using the MS Windows NT4 Server Manager, either from an NT4 Domain Member
175         server, or using the Nexus toolkit available from the Microsoft Web site.
176         This tool can be run from any MS Windows machine as long as the user is
177         logged on as the administrator account.
178         </para></listitem>
179         
180         <listitem><para>
181         <quote>On-the-fly</quote> creation. The Samba Machine Trust Account is automatically
182         created by Samba at the time the client is joined to the domain.
183         (For security, this is the recommended method.) The corresponding UNIX
184         account may be created automatically or manually. 
185         </para></listitem>
186 </itemizedlist>
188 <sect2>
189 <title>Manual Creation of Machine Trust Accounts</title>
191 <para>
192 The first step in manually creating a Machine Trust Account is to manually
193 create the corresponding UNIX account in <filename>/etc/passwd</filename>. 
194 This can be done using <command>vipw</command> or another <quote>add user</quote> command
195 that is normally used to create new UNIX accounts. The following is an example for
196 a Linux-based Samba server:
197 </para>
199 <para>
200 <indexterm><primary>useradd</primary></indexterm>
201 <indexterm><primary>vipw</primary></indexterm>
202 <screen>
203 &rootprompt;<userinput>/usr/sbin/useradd -g machines -d /dev/null -c <replaceable>"machine nickname"</replaceable> \
204    -s /bin/false <replaceable>machine_name</replaceable>$ </userinput>
206 &rootprompt;<userinput>passwd -l <replaceable>machine_name</replaceable>$</userinput>
207 </screen>
208 </para>
210 <para>In the above example above there is an existing system group <quote>machines</quote> which is used
211 as the primary group for all machine accounts. In the following examples the <quote>machines</quote> group has
212 numeric GID equal 100.</para>
214 <para>
215 <indexterm><primary>chpass</primary></indexterm>
216 On *BSD systems, this can be done using the <command>chpass</command> utility:
217 </para>
219 <para>
220 <screen>
221 &rootprompt;<userinput>chpass -a \
222 '<replaceable>machine_name</replaceable>$:*:101:100::0:0:Windows <replaceable>machine_name</replaceable>:/dev/null:/sbin/nologin'</userinput>
223 </screen>
224 </para>
226 <para>
227 The <filename>/etc/passwd</filename> entry will list the machine name 
228 with a <quote>$</quote> appended, will not have a password, will have a null shell and no 
229 home directory. For example, a machine named <quote>doppy</quote> would have an 
230 <filename>/etc/passwd</filename> entry like this:
231 </para>
233 <programlisting>
234 doppy$:x:505:100:<replaceable>machine_nickname</replaceable>:/dev/null:/bin/false
235 </programlisting>
237 <para>
238 Above, <replaceable>machine_nickname</replaceable> can be any
239 descriptive name for the client, i.e., BasementComputer.
240 <replaceable>machine_name</replaceable> absolutely must be the NetBIOS
241 name of the client to be joined to the domain. The <quote>$</quote> must be
242 appended to the NetBIOS name of the client or Samba will not recognize
243 this as a Machine Trust Account.
244 </para>
246 <para>
247 Now that the corresponding UNIX account has been created, the next step is to create 
248 the Samba account for the client containing the well-known initial 
249 Machine Trust Account password. This can be done using the 
250 <command>smbpasswd</command> command 
251 as shown here:
252 </para>
254 <para>
255 <screen>
256 &rootprompt;<userinput>smbpasswd -a -m <replaceable>machine_name</replaceable></userinput>
257 </screen>
258 </para>
260 <para>
261 where <replaceable>machine_name</replaceable> is the machine's NetBIOS
262 name. The RID of the new machine account is generated from the UID of 
263 the corresponding UNIX account.
264 </para>
266 <warning>
267 <title>Join the client to the domain immediately</title>
269 <para>
270 Manually creating a Machine Trust Account using this method is the 
271 equivalent of creating a Machine Trust Account on a Windows NT PDC using 
272 <indexterm><primary>Server Manager</primary></indexterm>
273 the <application>Server Manager</application>. From the time at which the 
274 account is created to the time the client joins the domain and 
275 changes the password, your domain is vulnerable to an intruder joining 
276 your domain using a machine with the same NetBIOS name. A PDC inherently 
277 trusts members of the domain and will serve out a large degree of user 
278 information to such clients. You have been warned!
279 </para>
280 </warning>
281 </sect2>
283 <sect2>
284 <title>Managing Domain Machine Accounts using NT4 Server Manager</title>
286 <para>
287 A working <smbconfoption><name>add machine script</name></smbconfoption> script is essential
288 for machine trust accounts to be automatically created. This applies no matter whether
289 one uses automatic account creation, or if one wishes to use the NT4 Domain Server Manager.
290 </para>
292 <para>
293 <indexterm><primary>SRVTOOLS.EXE</primary></indexterm>
294 If the machine from which you are trying to manage the domain is an 
295 <application>MS Windows NT4 workstation or MS Windows 200x/XP Professional</application>,
296 the tool of choice is the package called <command>SRVTOOLS.EXE</command>. 
297 When executed in the target directory it will unpack <command>SrvMgr.exe</command>
298 and <command>UsrMgr.exe</command> (both are domain management tools for MS Windows NT4 workstation).
299 </para>
301 <para>
302 <indexterm><primary>Nexus.exe</primary></indexterm>
303 If your workstation is a <application>Microsoft Windows 9x/Me</application> family product
304  you should download the <command>Nexus.exe</command> package from the Microsoft web site.
305 When executed from the target directory this will unpack the same tools but for use on 
306 this platform.
307 </para>
309 <para>
310 Further information about these tools may be obtained from the following locations:
311 </para>
313 <para>
314 <simplelist>
315 <member><ulink noescape="1" url="http://support.microsoft.com/default.aspx?scid=kb;en-us;173673"/></member>
316 <member><ulink noescape="1" url="http://support.microsoft.com/default.aspx?scid=kb;en-us;172540"/></member>
317 </simplelist>
318 </para>
320 <para>
321 Launch the <command>srvmgr.exe</command> (Server Manager for Domains) and follow these steps:
322 </para>
324 <procedure>
325 <title>Server Manager Account Machine Account Management</title>
326         <step><para>
327         From the menu select <guimenu>Computer</guimenu>.
328         </para></step>
330         <step><para>
331         Click <guimenuitem>Select Domain</guimenuitem>.
332         </para></step>
334         <step><para>
335         Click the name of the domain you wish to administer in the
336         <guilabel>Select Domain</guilabel> panel and then click 
337         <guibutton>OK</guibutton>.
338         </para></step>
340         <step><para>
341         Again from the menu select <guimenu>Computer</guimenu>.
342         </para></step>
344         <step><para>
345         Select <guimenuitem>Add to Domain</guimenuitem>.
346         </para></step>
348         <step><para>
349         In the dialog box, click the radio button to 
350         <guilabel>Add NT Workstation of Server</guilabel>, then
351         enter the machine name in the field provided, and click the 
352         <guibutton>Add</guibutton> button.
353         </para></step>
354 </procedure>
356 </sect2>
358 <sect2>
359 <title>On-the-Fly Creation of Machine Trust Accounts</title>
361 <para>
362 The second (and recommended) way of creating Machine Trust Accounts is
363 simply to allow the Samba server to create them as needed when the client
364 is joined to the domain.
365 </para>
367 <para>Since each Samba Machine Trust Account requires a corresponding UNIX account, a method
368 for automatically creating the UNIX account is usually supplied; this requires configuration of the
369 add machine script option in &smb.conf;. This method is not required, however, corresponding UNIX
370 accounts may also be created manually.
371 </para>
374 <para>
375 Here is an example for a Red Hat Linux system.
376 </para>
378 <para><smbconfblock>
379 <smbconfsection>[global]</smbconfsection>
380 <smbconfcomment>&lt;...remainder of parameters...&gt;</smbconfcomment>
381 <smbconfoption><name>add machine script</name><value>/usr/sbin/useradd -d /dev/null -g 100 \</value></smbconfoption>
382 <member><parameter>  -s /bin/false -M %u</parameter></member>
383 </smbconfblock></para>
386 </sect2>
389 <sect2><title>Making an MS Windows Workstation or Server a Domain Member</title>
391 <para>
392 The procedure for making an MS Windows workstation or server a member of the domain varies
393 with the version of Windows.
394 </para>
396 <sect3>
397         <title>Windows 200x/XP Professional Client</title>
399         <para>
400         When the user elects to make the client a Domain Member, Windows 200x prompts for
401         an account and password that has privileges to create  machine accounts in the domain.
402         A Samba Administrator Account (i.e., a Samba account that has <constant>root</constant> privileges on the
403         Samba server) must be entered here; the operation will fail if an ordinary user
404         account is given. 
405         </para>
407         <para>
408         For security reasons, the password for this Administrator Account should be set
409         to a password that is other than that used for the root user in <filename>/etc/passwd</filename>.
410         </para>
412         <para>
413         The name of the account that is used to create Domain Member machine accounts can be
414         anything the network administrator may choose. If it is other than <constant>root</constant>
415         then this is easily mapped to <constant>root</constant> in the file named in the &smb.conf; parameter
416         <smbconfoption><name>username map</name><value>/etc/samba/smbusers</value></smbconfoption>.
417         </para>
419         <para>
420         The session key of the Samba Administrator Account acts as an encryption key for setting the password of the machine trust
421         account. The Machine Trust Account will be created on-the-fly, or updated if it already exists.
422         </para>
423 </sect3>
425 <sect3>
426         <title>Windows NT4 Client</title>
428         <para>
429         If the Machine Trust Account was created manually, on the
430         Identification Changes menu enter the domain name, but do not
431         check the box <guilabel>Create a Computer Account in the Domain</guilabel>.
432         In this case, the existing Machine Trust Account is used to join the machine 
433         to the domain.
434         </para>
436         <para>
437         If the Machine Trust Account is to be created on-the-fly, on the Identification Changes menu enter the domain
438         name and check the box <guilabel>Create a Computer Account in the Domain</guilabel>. In this case, joining
439         the domain proceeds as above for Windows 2000 (i.e., you must supply a Samba Administrator Account when
440         prompted).
441         </para>
442 </sect3>
444 <sect3>
445         <title>Samba Client</title>
447         <para>Joining a Samba client to a domain is documented in 
448         <link linkend="domain-member-server">Domain Member Server</link>.
449         </para>
450 </sect3>
452 </sect2>
453 </sect1>
455 <sect1 id="domain-member-server">
456 <title>Domain Member Server</title>
458 <para>
459 This mode of server operation involves the Samba machine being made a member
460 of a domain security context. This means by definition that all user
461 authentication will be done from a centrally defined authentication regime. 
462 The authentication regime may come from an NT3/4-style (old domain technology)
463 server, or it may be provided from an Active Directory server (ADS) running on
464 MS Windows 2000 or later.
465 </para>
467 <para>
468 <emphasis>
469 Of course it should be clear that the authentication backend itself could be
470 from any distributed directory architecture server that is supported by Samba.
471 This can be LDAP (from OpenLDAP), or Sun's iPlanet, or NetWare Directory
472 Server, and so on.
473 </emphasis>
474 </para>
476 <para><note>
477 When Samba is configured to use an LDAP, or other identity management and/or
478 directory service, it is Samba that continues to perform user and machine
479 authentication. It should be noted that the LDAP server does not perform
480 authentication handling in place of what Samba is designed to do.
481 </note></para>
483 <para>
484 Please refer to <link linkend="samba-pdc">Domain Control</link>, for more information regarding
485 how to create a domain machine account for a Domain Member server as well as for
486 information on how to enable the Samba Domain Member machine to join the domain
487 and be fully trusted by it.
488 </para>
490 <sect2>
491 <title>Joining an NT4-type Domain with Samba-3</title>
493 <para><link linkend="assumptions">Next table</link> lists names that have been used in the remainder of this chapter.</para>
495 <table frame="all" id="assumptions"><title>Assumptions</title>
496         <tgroup cols="2">
497                 <colspec align="right"/>
498                 <colspec align="left"/>
499         <tbody>
500                         <row>
501                                 <entry>NetBIOS name:</entry><entry>SERV1</entry>
502                         </row>
503                         <row>
504                                 <entry>Windows 200x/NT domain name:</entry><entry>&example.workgroup;</entry>
505                         </row>
506                         <row>
507                                 <entry>Domain's PDC NetBIOS name:</entry><entry>DOMPDC</entry>
508                         </row>
509                         <row>
510                                 <entry>Domain's BDC NetBIOS names:</entry><entry>DOMBDC1 and DOMBDC2</entry>
511                         </row>
512         </tbody>
513         </tgroup>
514 </table>
516 <para>
517 First, you must edit your &smb.conf; file to tell Samba it should now use domain security.
518 </para>
520 <para>
521         Change (or add) your 
522         <smbconfoption><name>security</name></smbconfoption> line in the [global] section 
523 of your &smb.conf; to read:
524 </para>
526 <para>
527 <smbconfblock>
528 <smbconfoption><name>security</name><value>domain</value></smbconfoption>
529 </smbconfblock>
530 </para>
532 <para>
533 Next change the <smbconfoption><name>workgroup</name></smbconfoption> line in the <smbconfsection>[global]</smbconfsection>
534 section to read: 
535 </para>
537 <para>
538 <smbconfblock>
539 <smbconfoption><name>workgroup</name><value>&example.workgroup;</value></smbconfoption>
540 </smbconfblock>
541 </para>
543 <para>
544 This is the name of the domain we are joining.
545 </para>
547 <para>
548 You must also have the parameter <smbconfoption><name>encrypt passwords</name></smbconfoption>
549 set to <constant>yes</constant> in order for your users to authenticate to the NT PDC.
550 This is the default setting if this parameter is not specified. There is no need to specify this
551 parameter, but if it is specified in the &smb.conf; file, it must be set to <constant>Yes</constant>.
552 </para>
554 <para>
555 Finally, add (or modify) a <smbconfoption><name>password server</name></smbconfoption> line in the [global]
556 section to read: 
557 </para>
559 <para>
560 <smbconfblock>
561 <smbconfoption><name>password server</name><value>DOMPDC DOMBDC1 DOMBDC2</value></smbconfoption>
562 </smbconfblock>
563 </para>
565 <para>
566 These are the primary and backup Domain Controllers Samba 
567 will attempt to contact in order to authenticate users. Samba will 
568 try to contact each of these servers in order, so you may want to 
569 rearrange this list in order to spread out the authentication load 
570 among Domain Controllers.
571 </para>
573 <para>
574 Alternately, if you want smbd to automatically determine 
575 the list of Domain Controllers to use for authentication, you may 
576 set this line to be:
577 </para>
579 <para>
580 <smbconfblock>
581 <smbconfoption><name>password server</name><value>*</value></smbconfoption>
582 </smbconfblock>
583 </para>
585 <para>
586 This method allows Samba to use exactly the same mechanism that NT does. The 
587 method either uses broadcast-based name resolution, performs a WINS database
588 lookup in order to find a Domain Controller against which to authenticate,
589 or locates the Domain Controller using DNS name resolution.
590 </para>
592 <para>
593 To join the domain, run this command:
594 </para>
596 <para>
597 <screen>
598 &rootprompt;<userinput>net join -S DOMPDC -U<replaceable>Administrator%password</replaceable></userinput>
599 </screen>
600 </para>
602 <para>
603 If the <option>-S DOMPDC</option> argument is not given, the domain name will be obtained from &smb.conf;.
604 </para>
606 <para>
607 The machine is joining the domain DOM, and the PDC for that domain (the only machine
608 that has write access to the domain SAM database) is DOMPDC, therefore use the <option>-S</option>
609 option. The <replaceable>Administrator%password</replaceable> is the login name and
610 password for an account that has the necessary privilege to add machines to the
611 domain. If this is successful, you will see the message in your terminal window the
612 text shown below. Where the older NT4 style domain architecture is used:
613 <screen>
614 <computeroutput>Joined domain DOM.</computeroutput>
615 </screen>
616 </para>
618 <para>
619 Where Active Directory is used:
620 <screen>
621 <computeroutput>Joined SERV1 to realm MYREALM.</computeroutput>
622 </screen>
623 </para>
625 <para>
626 Refer to the <command>net</command> man page for further information.
627 </para>
629 <para>
630 This process joins the server to the domain without having to create the machine
631 trust account on the PDC beforehand.
632 </para>
634 <para>
635 This command goes through the machine account password change protocol, then writes
636 the new (random) machine account password for this Samba server into a file in the
637 same directory in which a smbpasswd file would be normally stored:
638 <screen>
639 <filename>/usr/local/samba/private/secrets.tdb</filename>
640 or 
641 <filename>/etc/samba/secrets.tdb</filename>.
642 </screen>
643 </para>
645 <para>
646 This file is created and owned by root and is not readable by any other user. It is
647 the key to the Domain-level security for your system, and should be treated as carefully 
648 as a shadow password file.
649 </para>
651 <para>
652 Finally, restart your Samba daemons and get ready for clients to begin using domain
653 security. The way you can restart your Samba daemons depends on your distribution,
654 but in most cases the following will suffice:
655 <screen>
656 &rootprompt;/etc/init.d/samba restart
657 </screen>
658 </para>
660 </sect2>
662 <sect2>
663 <title>Why Is This Better Than <parameter>security = server</parameter>?</title>
665 <para>
666 Currently, domain security in Samba does not free you from 
667 having to create local UNIX users to represent the users attaching 
668 to your server. This means that if Domain user <constant>DOM\fred
669 </constant> attaches to your Domain Security Samba server, there needs 
670 to be a local UNIX user fred to represent that user in the UNIX 
671 file system. This is similar to the older Samba security mode 
672 <smbconfoption><name>security</name><value>server</value></smbconfoption>,
673 where Samba would pass through the authentication request to a Windows 
674 NT server in the same way as a Windows 95 or Windows 98 server would.
675 </para>
677 <para>
678 Please refer to <link linkend="winbind">Winbind: Use of Domain Accounts</link> chapter, for information on a system
679 to automatically assign UNIX UIDs and GIDs to Windows NT Domain users and groups.
680 </para>
682 <para>
683 The advantage to Domain-level security is that the 
684 authentication in Domain-level security is passed down the authenticated 
685 RPC channel in exactly the same way that an NT server would do it. This 
686 means Samba servers now participate in domain trust relationships in 
687 exactly the same way NT servers do (i.e., you can add Samba servers into 
688 a resource domain and have the authentication passed on from a resource
689 domain PDC to an account domain PDC).
690 </para>
692 <para>
693 In addition, with <smbconfoption><name>security</name><value>server</value></smbconfoption>, every Samba 
694 daemon on a server has to keep a connection open to the 
695 authenticating server for as long as that daemon lasts. This can drain 
696 the connection resources on a Microsoft NT server and cause it to run 
697 out of available connections. With <smbconfoption><name>security</name><value>domain</value></smbconfoption>, 
698 however, the Samba daemons connect to the PDC/BDC only for as long 
699 as is necessary to authenticate the user and then drop the connection, 
700 thus conserving PDC connection resources.
701 </para>
703 <para>
704 And finally, acting in the same manner as an NT server 
705 authenticating to a PDC means that as part of the authentication 
706 reply, the Samba server gets the user identification information such 
707 as the user SID, the list of NT groups the user belongs to, and so on. 
708 </para>
710 <note>
711 <para>
712 Much of the text of this document was first published in the Web magazine 
713 <ulink url="http://www.linuxworld.com">LinuxWorld</ulink> as the article <ulink
714 url="http://www.linuxworld.com/linuxworld/lw-1998-10/lw-10-samba.html"/>
715 <emphasis>Doing the NIS/NT Samba</emphasis>.
716 </para>
717 </note>
719 </sect2>
720 </sect1>
722 <sect1 id="ads-member">
723 <title>Samba ADS Domain Membership</title>
725 <para>
726 <indexterm significance="preferred"><primary>Active Directory</primary></indexterm>
727 <indexterm significance="preferred"><primary>ADS</primary><see>Active Directory</see></indexterm>
728 <indexterm><primary>KDC</primary></indexterm>
729 <indexterm><primary>Kerberos</primary></indexterm>
730 This is a rough guide to setting up Samba-3 with Kerberos authentication against a
731 Windows 200x KDC. A familiarity with Kerberos is assumed.
732 </para> 
734 <sect2>
735 <title>Configure &smb.conf;</title>
737 <para>
738 You must use at least the following three options in &smb.conf;:
739 </para>
741 <para><smbconfblock>
742 <smbconfoption><name>realm</name><value>your.kerberos.REALM</value></smbconfoption>
743 <smbconfoption><name>security</name><value>ADS</value></smbconfoption>
744 <smbconfcomment>The following parameter need only be specified if present.</smbconfcomment>
745 <smbconfcomment>The default setting is not present is Yes.</smbconfcomment>
746 <smbconfoption><name>encrypt passwords</name><value>yes</value></smbconfoption>
747 </smbconfblock></para>
749 <para>
750 In case samba cannot correctly identify the appropriate ADS server using the realm name, use the 
751 <smbconfoption><name>password server</name></smbconfoption> option in &smb.conf;:
752 <smbconfblock>
753 <smbconfoption><name>password server</name><value>your.kerberos.server</value></smbconfoption>
754 </smbconfblock>
755 </para>
757 <note><para>
758 You do <emphasis>not</emphasis> need a smbpasswd file, and older clients will be authenticated as 
759 if <smbconfoption><name>security</name><value>domain</value></smbconfoption>, although it will not do any harm and 
760 allows you to have local users not in the domain.
761 </para></note>
763 </sect2>
764   
765 <sect2>
766 <title>Configure <filename>/etc/krb5.conf</filename></title>
768 <para>
769 <indexterm><primary>/etc/krb5.conf</primary></indexterm>
770 <indexterm><primary>Kerberos</primary><secondary>/etc/krb5.conf</secondary></indexterm>
771 With both MIT and Heimdal Kerberos, it is unnecessary to configure the 
772 <filename>/etc/krb5.conf</filename>, and it may be detrimental.
773 </para>
775 <para>
776 Microsoft Active Directory servers automatically create SRV records in the DNS zone 
777 <parameter>_kerberos.REALM.NAME</parameter> for each KDC in the realm. This is part
778 of the installation and configuration process used to create an Active Directory Domain.
779 </para>
781 <para>
782 MIT's, as well as Heimdal's, recent KRB5 libraries default to checking for SRV records, so they will 
783 automatically find the KDCs. In addition, <filename>krb5.conf</filename> only allows specifying 
784 a single KDC, even there if there may be more than one. Using the DNS lookup allows the KRB5 
785 libraries to use whichever KDCs are available.
786 </para>
788 <para>
789 When manually configuring <filename>krb5.conf</filename>, the minimal configuration is:
790 </para>
792 <para>
793         <smbfile name="krb5.conf">
794         <programlisting>
795 [libdefaults]
796         default_realm = YOUR.KERBEROS.REALM
798 [realms]
799         YOUR.KERBEROS.REALM = {
800         kdc = your.kerberos.server
801         }
803 [domain_realms]
804         .kerberos.server = YOUR.KERBEROS.REALM
805 </programlisting></smbfile></para>
807 <para>
808 When using Heimdal versions before 0.6 use the following configuration settings:
809 <screen>
810 [libdefaults]
811         default_realm      = YOUR.KERBEROS.REALM
812         default_etypes     = des-cbc-crc des-cbc-md5
813         default_etypes_des = des-cbc-crc des-cbc-md5
815 [realms]
816         YOUR.KERBEROS.REALM = {
817         kdc = your.kerberos.server
818         }
820 [domain_realms]
821         .kerberos.server = YOUR.KERBEROS.REALM
822 </screen>
823 </para>
825 <para>
826 <indexterm><primary>kinit</primary></indexterm>
827 Test your config by doing a <userinput>kinit
828 <replaceable>USERNAME</replaceable>@<replaceable>REALM</replaceable></userinput> and
829 making sure that your password is accepted by the Win2000 KDC.
830 </para>
832 <para>
833 With Heimdal versions earlier than 0.6.x you only can use newly created accounts
834 in ADS or accounts that have had the password changed once after migration, or
835 in case of <constant>Administrator</constant> after installation. At the
836 moment, a Windows 2003 KDC can only be used with a Heimdal releases later than 0.6
837 (and no default etypes in krb5.conf). Unfortunately this whole area is still
838 in a state of flux.
839 </para>
841 <note><para>
842 The realm must be in uppercase or you will get <quote><errorname>Cannot find KDC for
843 requested realm while getting initial credentials</errorname></quote> error (Kerberos
844 is case-sensitive!).
845 </para></note>
847 <note><para>
848 Time between the two servers must be synchronized. You will get a
849 <quote><errorname>kinit(v5): Clock skew too great while getting initial credentials</errorname></quote>
850 if the time difference is more than five minutes. 
851 </para></note>
853 <para>
854 Clock skew limits are configurable in the Kerberos protocols. The default setting is
855 five minutes.
856 </para>
858 <para>
859 You also must ensure that you can do a reverse DNS lookup on the IP
860 address of your KDC. Also, the name that this reverse lookup maps to
861 must either be the NetBIOS name of the KDC (i.e., the hostname with no
862 domain attached) or it can alternately be the NetBIOS name followed by the realm. 
863 </para>
865 <para>
866 The easiest way to ensure you get this right is to add a 
867 <filename>/etc/hosts</filename> entry mapping the IP address of your KDC to 
868 its NetBIOS name. If you do not get this correct then you will get a 
869 <errorname>local error</errorname> when you try to join the realm.
870 </para>
872 <para>
873 If all you want is Kerberos support in &smbclient; then you can skip
874 directly to <link linkend="ads-test-smbclient">Testing with &smbclient;</link> now. 
875 <link linkend="ads-create-machine-account">Create the Computer Account</link> and 
876 <link linkend="ads-test-server">Testing Server Setup</link>
877 are needed only if you want Kerberos support for &smbd; and &winbindd;.
878 </para>
880 </sect2>
882 <sect2 id="ads-create-machine-account">
883 <title>Create the Computer Account</title>
885 <para>
886 As a user who has write permission on the Samba private directory (usually root), run:
887 <screen>
888 &rootprompt; <userinput>net ads join -U Administrator%password</userinput>
889 </screen>
890 </para>
892 <para>
893 When making a Windows client a member of an ADS domain within a complex organization, you
894 may want to create the machine account within a particular organizational unit. Samba-3 permits
895 this to be done using the following syntax:
896 <screen>
897 &rootprompt; <userinput>kinit Administrator@your.kerberos.REALM</userinput>
898 &rootprompt; <userinput>net ads join "organizational_unit"</userinput>
899 </screen>
900 </para>
902 <para>
903 For example, you may want to create the machine account in a container called <quote>Servers</quote>
904 under the organizational directory <quote>Computers\BusinessUnit\Department</quote> like this:
905 <screen>
906 &rootprompt; <userinput>net ads join "Computers\BusinessUnit\Department\Servers"</userinput>
907 </screen>
908 </para>
910 <?latex \newpage ?>
912 <sect3>
913 <title>Possible Errors</title>
915 <para>
916 <variablelist>
917         <varlistentry><term><errorname>ADS support not compiled in</errorname></term>
918         <listitem><para>Samba must be reconfigured (remove config.cache) and recompiled
919         (make clean all install) after the Kerberos libraries and headers files are installed.
920         </para></listitem></varlistentry>
922         <varlistentry><term><errorname>net ads join prompts for user name</errorname></term>
923         <listitem><para>You need to login to the domain using <userinput>kinit
924         <replaceable>USERNAME</replaceable>@<replaceable>REALM</replaceable></userinput>.
925         <replaceable>USERNAME</replaceable> must be a user who has rights to add a machine
926         to the domain. </para></listitem></varlistentry>
928         <varlistentry><term>Unsupported encryption/or checksum types</term>
929         <listitem><para>
930         Make sure that the <filename>/etc/krb5.conf</filename> is correctly configured
931         for the type and version of Kerberos installed on the system.
932         </para></listitem></varlistentry>
933 </variablelist>
934 </para>
936 </sect3>
938 </sect2>
940 <sect2 id="ads-test-server">
941 <title>Testing Server Setup</title>
943 <para>
944 If the join was successful, you will see a new computer account with the
945 NetBIOS name of your Samba server in Active Directory (in the <quote>Computers</quote>
946 folder under Users and Computers.
947 </para>
949 <para>
950 On a Windows 2000 client, try <userinput>net use * \\server\share</userinput>. You should
951 be logged in with Kerberos without needing to know a password. If this fails then run
952 <userinput>klist tickets</userinput>. Did you get a ticket for the server? Does it have
953 an encryption type of DES-CBC-MD5? 
954 </para>
956 <para><note>
957 Samba can use both DES-CBC-MD5 encryption as well as ARCFOUR-HMAC-MD5 encoding.
958 </note></para>
960 </sect2>
962 <sect2 id="ads-test-smbclient">
963 <title>Testing with &smbclient;</title>
966 <para>
967 <indexterm><primary>smbclient</primary></indexterm>
968 On your Samba server try to login to a Win2000 server or your Samba
969 server using &smbclient; and Kerberos. Use &smbclient; as usual, but
970 specify the <option>-k</option> option to choose Kerberos authentication.
971 </para>
973 </sect2>
975 <sect2>
976 <title>Notes</title>
978 <para>
979 You must change administrator password at least once after DC 
980 install, to create the right encryption types.
981 </para>
983 <para>
984 Windows 200x does not seem to create the <parameter>_kerberos._udp</parameter> and <parameter>_ldap._tcp</parameter> in
985 the default DNS setup. Perhaps this will be fixed later in service packs.
986 </para>
988 </sect2>
989 </sect1>
991 <sect1>
992 <title>Sharing User ID Mappings between Samba Domain Members</title>
994 <para>
995 Samba maps UNIX users and groups (identified by UIDs and GIDs) to Windows users and groups (identified by SIDs).
996 These mappings are done by the <parameter>idmap</parameter> subsystem of Samba.
997 </para>
999 <para>
1000 In some cases it is useful to share these mappings between Samba Domain Members,
1001 so <emphasis>name->id</emphasis> mapping is identical on all machines.
1002 This may be needed in particular when sharing files over both CIFS and NFS.
1003 </para>
1005 <para>To use the <emphasis>LDAP</emphasis> <parameter>ldap idmap suffix</parameter>, set:</para>
1007 <smbconfblock>
1008 <smbconfoption><name>ldap idmap suffix</name><value>ou=Idmap,dc=quenya,dc=org</value></smbconfoption>
1009 </smbconfblock>
1011 <para>See the &smb.conf; man page entry for the <smbconfoption><name>ldap idmap suffix</name><value></value></smbconfoption>
1012 parameter for further information.</para>
1014 <para>
1015 Do not forget to specify also the <smbconfoption><name>ldap admin dn</name></smbconfoption>
1016 and to make certain to set the LDAP administrative password into the <filename>secrets.tdb</filename> using:
1017 <screen>
1018 &rootprompt; smbpasswd -w ldap-admin-password
1019 </screen></para>
1021 </sect1>
1023 <sect1>
1024 <title>Common Errors</title>
1026 <para>
1027 In the process of adding/deleting/re-adding Domain Member machine accounts, there are
1028 many traps for the unwary player and many <quote>little</quote> things that can go wrong.
1029 It is particularly interesting how often subscribers on the Samba mailing list have concluded
1030 after repeated failed attempts to add a machine account that it is necessary to <quote>re-install</quote>
1031 MS Windows on the machine. In truth, it is seldom necessary to reinstall because of this type
1032 of problem. The real solution is often quite simple and with an understanding of how MS Windows
1033 networking functions, it is easy to overcome.
1034 </para>
1036 <sect2>
1037 <title>Cannot Add Machine Back to Domain</title>
1039 <para>
1040 <quote>A Windows workstation was re-installed. The original domain machine
1041 account was deleted and added immediately. The workstation will not join the domain if I use 
1042 the same machine name. Attempts to add the machine fail with a message that the machine already
1043 exists on the network &smbmdash; I know it does not. Why is this failing?</quote>
1044 </para>
1046 <para>
1047 The original name is still in the NetBIOS name cache and must expire after machine account
1048 deletion before adding that same name as a Domain Member again. The best advice is to delete
1049 the old account and then add the machine with a new name.
1050 </para>
1052 </sect2>
1054 <sect2>
1055 <title>Adding Machine to Domain Fails</title>
1057 <para>
1058 <quote>Adding a Windows 200x or XP Professional machine to the Samba PDC Domain fails with a
1059 message that, <errorname>`The machine could not be added at this time, there is a network problem.
1060 Please try again later.'</errorname> Why?</quote>
1061 </para>
1063 <para>
1064 You should check that there is an <smbconfoption><name>add machine script</name></smbconfoption> in your &smb.conf;
1065 file. If there is not, please add one that is appropriate for your OS platform. If a script
1066 has been defined, you will need to debug its operation. Increase the <smbconfoption><name>log level</name><value></value></smbconfoption>
1067 in the &smb.conf; file to level 10, then try to rejoin the domain. Check the logs to see which
1068 operation is failing.
1069 </para>
1071 <para>
1072 Possible causes include:
1073 </para>
1075 <itemizedlist>
1076         <listitem><para>
1077         The script does not actually exist, or could not be located in the path specified.
1078         </para>
1080         <para>
1081         <emphasis>Corrective action:</emphasis> Fix it. Make sure when run manually
1082         that the script will add both the UNIX system account and the Samba SAM account.
1083         </para></listitem>
1085         <listitem><para>
1086         The machine could not be added to the UNIX system accounts file <filename>/etc/passwd</filename>.
1087         </para>
1089         <para>
1090         <emphasis>Corrective action:</emphasis> Check that the machine name is a legal UNIX
1091         system account name. If the UNIX utility <command>useradd</command> is called,
1092         then make sure that the machine name you are trying to add can be added using this
1093         tool. <command>Useradd</command> on some systems will not allow any upper case characters
1094         nor will it allow spaces in the name.
1095         </para></listitem>
1096 </itemizedlist>
1098 <para>
1099 The <smbconfoption><name>add machine script</name></smbconfoption> does not create the
1100 machine account in the Samba backend database, it is there only to create a UNIX system
1101 account to which the Samba backend database account can be mapped.
1102 </para>
1104 </sect2>
1106 <sect2>
1107         <title>I Can't Join a Windows 2003 PDC</title>
1109         <para>Windows 2003 requires SMB signing. Client side SMB signing has been implemented in Samba-3.0.
1110         Set <smbconfoption><name>client use spnego</name><value>yes</value></smbconfoption> when communicating 
1111         with a Windows 2003 server.</para>
1112 </sect2>
1114 </sect1>
1115 </chapter>