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