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