1 <chapter id="domain-member">
9 <title>Domain Membership</title>
12 Domain Membership is a subject of vital concern, Samba must be able to participate
13 as a member server in a Microsoft Domain security context, and Samba must be capable of
14 providing Domain machine member trust accounts, otherwise it would not be capable of offering
15 a viable option for many users.
19 This chapter covers background information pertaining to domain membership, Samba
20 configuration for it, and MS Windows client procedures for joining a domain. Why is
21 this necessary? Because both are areas in which there exists within the current MS
22 Windows networking world and particularly in the Unix/Linux networking and administration
23 world, a considerable level of mis-information, incorrect understanding, and a lack of
24 knowledge. Hopefully this chapter will fill the voids.
28 <title>Features and Benefits</title>
31 MS Windows workstations and servers that want to participate in domain security need to
32 be made Domain members. Participating in Domain security is often called
33 <emphasis>Single Sign On</emphasis> or SSO for short. This chapter describes the process
34 that must be followed to make a workstation (or another server - be it an MS Windows NT4 / 200x
35 server) or a Samba server a member of an MS Windows Domain security context.
39 Samba-3 can join an MS Windows NT4 style domain as a native member server, an MS Windows
40 Active Directory Domain as a native member server, or a Samba Domain Control network.
46 <title>MS Windows Workstation/Server Machine Trust Accounts</title>
49 A machine trust account is an account that is used to authenticate a client machine
50 (rather than a user) to the Domain Controller server. In Windows terminology,
51 this is known as a "Computer Account."
55 The password of a machine trust account acts as the shared secret for
56 secure communication with the Domain Controller. This is a security
57 feature to prevent an unauthorized machine with the same NetBIOS name
58 from joining the domain and gaining access to domain user/group
59 accounts. Windows NT, 200x, XP Professional clients use machine trust
60 accounts, but Windows 9x / Me / XP Home clients do not. Hence, a
61 Windows 9x / Me / XP Home client is never a true member of a domain
62 because it does not possess a machine trust account, and thus has no
63 shared secret with the domain controller.
67 A Windows NT4 PDC stores each machine trust account in the Windows
68 Registry. The introduction of MS Windows 2000 saw the introduction of Active Directory,
69 the new repository for machine trust accounts.
73 A Samba PDC, however, stores each machine trust account in two parts,
78 A Domain Security Account (stored in the <emphasis>passdb backend</emphasis>
79 that has been configured in the &smb.conf; file. The precise nature of the
80 account information that is stored depends on the type of backend database
85 The older format of this data is the <filename>smbpasswd</filename> database
86 which contains the unix login ID, the Unix user identifier (UID), and the
87 LanMan and NT encrypted passwords. There is also some other information in
88 this file that we do not need to concern ourselves with here.
92 The two newer database types are called <emphasis>ldapsam, tdbsam</emphasis>.
93 Both store considerably more data than the older <filename>smbpasswd</filename>
94 file did. The extra information enables new user account controls to be used.
98 A corresponding Unix account, typically stored in <filename>/etc/passwd</filename>.
99 Work is in progress to allow a simplified mode of operation that does not require
100 Unix user accounts, but this may not be a feature of the early releases of Samba-3.
106 There are two ways to create machine trust accounts:
111 Manual creation. Both the Samba and corresponding Unix account are created by hand.
115 "On-the-fly" creation. The Samba machine trust account is automatically created by
116 Samba at the time the client is joined to the domain. (For security, this is the
117 recommended method.) The corresponding Unix account may be created automatically or manually.
122 <title>Manual Creation of Machine Trust Accounts</title>
125 The first step in manually creating a machine trust account is to manually create the
126 corresponding Unix account in <filename>/etc/passwd</filename>. This can be done using
127 <command>vipw</command> or other 'add user' command that is normally used to create new
128 Unix accounts. The following is an example for a Linux based Samba server:
132 <prompt>root# </prompt><command>/usr/sbin/useradd -g 100 -d /dev/null -c <replaceable>"machine nickname"</replaceable> -s /bin/false <replaceable>machine_name</replaceable>$ </command>
136 <prompt>root# </prompt><command>passwd -l <replaceable>machine_name</replaceable>$</command>
140 On *BSD systems, this can be done using the 'chpass' utility:
144 <prompt>root# </prompt><command>chpass -a "<replaceable>machine_name</replaceable>$:*:101:100::0:0:Workstation <replaceable>machine_name</replaceable>:/dev/null:/sbin/nologin"</command>
148 The <filename>/etc/passwd</filename> entry will list the machine name
149 with a "$" appended, won't have a password, will have a null shell and no
150 home directory. For example a machine named 'doppy' would have an
151 <filename>/etc/passwd</filename> entry like this:
155 doppy$:x:505:501:<replaceable>machine_nickname</replaceable>:/dev/null:/bin/false
159 Above, <replaceable>machine_nickname</replaceable> can be any
160 descriptive name for the client, i.e., BasementComputer.
161 <replaceable>machine_name</replaceable> absolutely must be the NetBIOS
162 name of the client to be joined to the domain. The "$" must be
163 appended to the NetBIOS name of the client or Samba will not recognize
164 this as a machine trust account.
168 Now that the corresponding Unix account has been created, the next step is to create
169 the Samba account for the client containing the well-known initial
170 machine trust account password. This can be done using the <ulink
171 url="smbpasswd.8.html"><command>smbpasswd(8)</command></ulink> command
177 <prompt>root# </prompt><userinput>smbpasswd -a -m <replaceable>machine_name</replaceable></userinput>
182 where <replaceable>machine_name</replaceable> is the machine's NetBIOS
183 name. The RID of the new machine account is generated from the UID of
184 the corresponding Unix account.
188 <title>Join the client to the domain immediately</title>
191 Manually creating a machine trust account using this method is the
192 equivalent of creating a machine trust account on a Windows NT PDC using
193 the "Server Manager". From the time at which the account is created
194 to the time which the client joins the domain and changes the password,
195 your domain is vulnerable to an intruder joining your domain using
196 a machine with the same NetBIOS name. A PDC inherently trusts
197 members of the domain and will serve out a large degree of user
198 information to such clients. You have been warned!
205 <title>"On-the-Fly" Creation of Machine Trust Accounts</title>
208 The second (and recommended) way of creating machine trust accounts is
209 simply to allow the Samba server to create them as needed when the client
210 is joined to the domain.
213 <para>Since each Samba machine trust account requires a corresponding
214 Unix account, a method for automatically creating the
215 Unix account is usually supplied; this requires configuration of the
216 <ulink url="smb.conf.5.html#ADDMACHINESCRIPT">add machine script</ulink>
217 option in <filename>smb.conf</filename>. This
218 method is not required, however; corresponding Unix accounts may also
224 Below is an example for a RedHat Linux system.
227 <para><programlisting>
229 # <...remainder of parameters...>
230 add machine script = /usr/sbin/useradd -d /dev/null -g 100 -s /bin/false -M %u
231 </programlisting></para>
236 <sect2><title>Joining the Client to the Domain</title>
239 The procedure for joining a client to the domain varies with the version of Windows.
243 <listitem><para><emphasis>Windows 2000</emphasis></para>
246 When the user elects to join the client to a domain, Windows prompts for
247 an account and password that is privileged to join the domain. A Samba administrative
248 account (i.e., a Samba account that has root privileges on the Samba server) must be
249 entered here; the operation will fail if an ordinary user account is given.
250 The password for this account should be set to a different password than the associated
251 <filename>/etc/passwd</filename> entry, for security reasons.
255 The session key of the Samba administrative account acts as an
256 encryption key for setting the password of the machine trust
257 account. The machine trust account will be created on-the-fly, or
258 updated if it already exists.
261 <listitem><para><emphasis>Windows NT</emphasis></para>
264 If the machine trust account was created manually, on the
265 Identification Changes menu enter the domain name, but do not
266 check the box "Create a Computer Account in the Domain." In this case,
267 the existing machine trust account is used to join the machine to
272 If the machine trust account is to be created
273 on-the-fly, on the Identification Changes menu enter the domain
274 name, and check the box "Create a Computer Account in the Domain." In
275 this case, joining the domain proceeds as above for Windows 2000
276 (i.e., you must supply a Samba administrative account when
280 <listitem><para><emphasis>Samba</emphasis></para>
281 <para>Joining a samba client to a domain is documented in
282 the <link linkend="domain-member">Domain Member</link> chapter.
290 <title>Domain Member Server</title>
293 This mode of server operation involves the samba machine being made a member
294 of a domain security context. This means by definition that all user authentication
295 will be done from a centrally defined authentication regime. The authentication
296 regime may come from an NT3/4 style (old domain technology) server, or it may be
297 provided from an Active Directory server (ADS) running on MS Windows 2000 or later.
302 Of course it should be clear that the authentication back end itself could be from any
303 distributed directory architecture server that is supported by Samba. This can be
304 LDAP (from OpenLDAP), or Sun's iPlanet, of NetWare Directory Server, etc.
309 Please refer to the section on Howto configure Samba as a Primary Domain Controller
310 and for more information regarding how to create a domain machine account for a
311 domain member server as well as for information regarding how to enable the samba
312 domain member machine to join the domain and to be fully trusted by it.
316 <title>Joining an NT4 type Domain with Samba-3</title>
319 <emphasis>Assumptions:</emphasis>
322 Win2K/NT domain name: DOM
323 Domain's PDC NetBIOS name: DOMPDC
324 Domain's BDC NetBIOS names: DOMBDC1 and DOMBDC2
329 First, you must edit your &smb.conf; file to tell Samba it should
330 now use domain security.
334 Change (or add) your <ulink url="smb.conf.5.html#SECURITY">
335 <parameter>security =</parameter></ulink> line in the [global] section
336 of your &smb.conf; to read:
341 <command>security = domain</command>
346 Next change the <ulink url="smb.conf.5.html#WORKGROUP"><parameter>
347 workgroup =</parameter></ulink> line in the [global] section to read:
352 <command>workgroup = DOM</command>
357 as this is the name of the domain we are joining.
361 You must also have the parameter <ulink url="smb.conf.5.html#ENCRYPTPASSWORDS">
362 <parameter>encrypt passwords</parameter></ulink> set to <constant>yes
363 </constant> in order for your users to authenticate to the NT PDC.
367 Finally, add (or modify) a <ulink url="smb.conf.5.html#PASSWORDSERVER">
368 <parameter>password server =</parameter></ulink> line in the [global]
374 <command>password server = DOMPDC DOMBDC1 DOMBDC2</command>
379 These are the primary and backup domain controllers Samba
380 will attempt to contact in order to authenticate users. Samba will
381 try to contact each of these servers in order, so you may want to
382 rearrange this list in order to spread out the authentication load
383 among domain controllers.
387 Alternatively, if you want smbd to automatically determine
388 the list of Domain controllers to use for authentication, you may
394 <command>password server = *</command>
399 This method, allows Samba to use exactly the same mechanism that NT does. This
400 method either broadcasts or uses a WINS database in order to
401 find domain controllers to authenticate against.
405 In order to actually join the domain, you must run this command:
410 <prompt>root# </prompt><userinput>net join -S DOMPDC -U<replaceable>Administrator%password</replaceable></userinput>
415 If the <userinput>-S DOMPDC</userinput> argument is not given then
416 the domain name will be obtained from smb.conf.
420 As we are joining the domain DOM and the PDC for that domain
421 (the only machine that has write access to the domain SAM database)
422 is DOMPDC. The <replaceable>Administrator%password</replaceable> is
423 the login name and password for an account which has the necessary
424 privilege to add machines to the domain. If this is successful
425 you will see the message:
429 <computeroutput>Joined domain DOM.</computeroutput>
430 or <computeroutput>Joined 'SERV1' to realm 'MYREALM'</computeroutput>
434 in your terminal window. See the <ulink url="net.8.html">
435 net(8)</ulink> man page for more details.
439 This process joins the server to the domain without having to create the machine
440 trust account on the PDC beforehand.
444 This command goes through the machine account password
445 change protocol, then writes the new (random) machine account
446 password for this Samba server into a file in the same directory
447 in which an smbpasswd file would be stored - normally :
451 <filename>/usr/local/samba/private/secrets.tdb</filename>
455 This file is created and owned by root and is not
456 readable by any other user. It is the key to the domain-level
457 security for your system, and should be treated as carefully
458 as a shadow password file.
462 Finally, restart your Samba daemons and get ready for
463 clients to begin using domain security!
469 <title>Why is this better than security = server?</title>
472 Currently, domain security in Samba doesn't free you from
473 having to create local Unix users to represent the users attaching
474 to your server. This means that if domain user <constant>DOM\fred
475 </constant> attaches to your domain security Samba server, there needs
476 to be a local Unix user fred to represent that user in the Unix
477 filesystem. This is very similar to the older Samba security mode
478 <ulink url="smb.conf.5.html#SECURITYEQUALSSERVER">security = server</ulink>,
479 where Samba would pass through the authentication request to a Windows
480 NT server in the same way as a Windows 95 or Windows 98 server would.
484 Please refer to the <ulink url="winbind.html">Winbind
485 paper</ulink> for information on a system to automatically
486 assign UNIX uids and gids to Windows NT Domain users and groups.
490 The advantage to domain-level security is that the
491 authentication in domain-level security is passed down the authenticated
492 RPC channel in exactly the same way that an NT server would do it. This
493 means Samba servers now participate in domain trust relationships in
494 exactly the same way NT servers do (i.e., you can add Samba servers into
495 a resource domain and have the authentication passed on from a resource
496 domain PDC to an account domain PDC).
500 In addition, with <command>security = server</command> every Samba
501 daemon on a server has to keep a connection open to the
502 authenticating server for as long as that daemon lasts. This can drain
503 the connection resources on a Microsoft NT server and cause it to run
504 out of available connections. With <command>security = domain</command>,
505 however, the Samba daemons connect to the PDC/BDC only for as long
506 as is necessary to authenticate the user, and then drop the connection,
507 thus conserving PDC connection resources.
511 And finally, acting in the same manner as an NT server
512 authenticating to a PDC means that as part of the authentication
513 reply, the Samba server gets the user identification information such
514 as the user SID, the list of NT groups the user belongs to, etc.
519 Much of the text of this document
520 was first published in the Web magazine <ulink url="http://www.linuxworld.com">
521 LinuxWorld</ulink> as the article <ulink
522 url="http://www.linuxworld.com/linuxworld/lw-1998-10/lw-10-samba.html">Doing
523 the NIS/NT Samba</ulink>.
531 <title>Samba ADS Domain Membership</title>
534 This is a rough guide to setting up Samba 3.0 with kerberos authentication against a
539 <title>Setup your <filename>smb.conf</filename></title>
542 You must use at least the following 3 options in smb.conf:
545 <para><programlisting>
546 realm = your.kerberos.REALM
548 encrypt passwords = yes
549 </programlisting></para>
552 In case samba can't figure out your ads server using your realm name, use the
553 <command>ads server</command> option in <filename>smb.conf</filename>:
555 ads server = your.kerberos.server
560 You do *not* need a smbpasswd file, and older clients will be authenticated as if
561 <command>security = domain</command>, although it won't do any harm and allows you
562 to have local users not in the domain. I expect that the above required options will
563 change soon when we get better active directory integration.
569 <title>Setup your <filename>/etc/krb5.conf</filename></title>
572 Note: you will need the krb5 workstation, devel, and libs installed
576 The minimal configuration for <filename>krb5.conf</filename> is:
579 <para><programlisting>
581 YOUR.KERBEROS.REALM = {
582 kdc = your.kerberos.server
584 </programlisting></para>
587 Test your config by doing a <userinput>kinit
588 <replaceable>USERNAME</replaceable>@<replaceable>REALM</replaceable></userinput> and
589 making sure that your password is accepted by the Win2000 KDC.
593 The realm must be uppercase or you will get "Cannot find KDC for requested
594 realm while getting initial credentials" error
598 Time between the two servers must be synchronized. You will get a
599 "kinit(v5): Clock skew too great while getting initial credentials" if the time
600 difference is more than five minutes.
604 You also must ensure that you can do a reverse DNS lookup on the IP
605 address of your KDC. Also, the name that this reverse lookup maps to
606 must either be the netbios name of the KDC (ie. the hostname with no
607 domain attached) or it can alternatively be the netbios name
608 followed by the realm.
612 The easiest way to ensure you get this right is to add a
613 <filename>/etc/hosts</filename> entry mapping the IP address of your KDC to
614 its netbios name. If you don't get this right then you will get a
615 "local error" when you try to join the realm.
619 If all you want is kerberos support in &smbclient; then you can skip
620 straight to <link linkend="ads-test-smbclient">Test with &smbclient;</link> now.
621 <link linkend="ads-create-machine-account">Creating a computer account</link>
622 and <link linkend="ads-test-server">testing your servers</link>
623 is only needed if you want kerberos support for &smbd; and &winbindd;.
628 <sect2 id="ads-create-machine-account">
629 <title>Create the computer account</title>
632 As a user that has write permission on the Samba private directory
635 <userinput>net join -U Administrator%password</userinput>
640 <title>Possible errors</title>
644 <varlistentry><term>"ADS support not compiled in"</term>
645 <listitem><para>Samba must be reconfigured (remove config.cache) and recompiled
646 (make clean all install) after the kerberos libs and headers are installed.
647 </para></listitem></varlistentry>
649 <varlistentry><term>net join prompts for user name</term>
650 <listitem><para>You need to login to the domain using <userinput>kinit
651 <replaceable>USERNAME</replaceable>@<replaceable>REALM</replaceable></userinput>.
652 <replaceable>USERNAME</replaceable> must be a user who has rights to add a machine
653 to the domain. </para></listitem></varlistentry>
661 <sect2 id="ads-test-server">
662 <title>Test your server setup</title>
665 If the join was successful, you will see a new computer account with the
666 NetBIOS name of your Samba server in Active Directory (in the "Computers"
667 folder under Users and Computers.
671 On a Windows 2000 client try <userinput>net use * \\server\share</userinput>. You should
672 be logged in with kerberos without needing to know a password. If
673 this fails then run <userinput>klist tickets</userinput>. Did you get a ticket for the
674 server? Does it have an encoding type of DES-CBC-MD5 ?
679 <sect2 id="ads-test-smbclient">
680 <title>Testing with &smbclient;</title>
683 On your Samba server try to login to a Win2000 server or your Samba
684 server using &smbclient; and kerberos. Use &smbclient; as usual, but
685 specify the <parameter>-k</parameter> option to choose kerberos authentication.
694 You must change administrator password at least once after DC
695 install, to create the right encoding types
699 w2k doesn't seem to create the _kerberos._udp and _ldap._tcp in
700 their defaults DNS setup. Maybe fixed in service packs?