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="groupmapping">
7 <firstname>Jean François</firstname><surname>Micouleau</surname>
11 <title>Group Mapping &smbmdash; MS Windows and UNIX</title>
15 <indexterm significance="preferred"><primary>groups</primary><secondary>mapping</secondary></indexterm>
16 Starting with Samba-3, new group mapping functionality is available to create associations
17 between Windows group SIDs and UNIX groups. The <command>groupmap</command> subcommand
18 included with the &net; tool can be used to manage these associations.
22 The new facility for mapping NT Groups to UNIX system groups allows the administrator to decide
23 which NT Domain Groups are to be exposed to MS Windows clients. Only those NT Groups that map
24 to a UNIX group that has a value other than the default (<constant>-1</constant>) will be exposed
25 in group selection lists in tools that access domain users and groups.
30 <indexterm><primary>domain admin group</primary></indexterm>
31 The <parameter>domain admin group</parameter> parameter has been removed in Samba-3 and should no longer
32 be specified in &smb.conf;. In Samba-2.2.x, this parameter was used to give the listed users membership in the
33 <constant>Domain Admins</constant> Windows group which gave local admin rights on their workstations
34 (in default configurations).
39 <title>Features and Benefits</title>
42 Samba allows the administrator to create MS Windows NT4/200x group accounts and to
43 arbitrarily associate them with UNIX/Linux group accounts.
47 <indexterm><primary>UID</primary></indexterm>
48 <indexterm><primary>GID</primary></indexterm>
49 <indexterm><primary>idmap uid</primary></indexterm>
50 Group accounts can be managed using the MS Windows NT4 or MS Windows 200x/XP Professional MMC tools.
51 Appropriate interface scripts should be provided in &smb.conf; if it is desired that UNIX/Linux system
52 accounts should be automatically created when these tools are used. In the absence of these scripts, and
53 so long as <command>winbindd</command> is running, Samba group accounts that are created using these
54 tools will be allocated UNIX UIDs/GIDs from the ID range specified by the
55 <smbconfoption name="idmap uid"/>/<smbconfoption name="idmap gid"/>
56 parameters in the &smb.conf; file.
59 <image id="idmap-sid2gid">
60 <imagedescription>IDMAP: group SID to GID resolution.</imagedescription>
61 <imagefile scale="50">idmap-sid2gid</imagefile>
64 <image id="idmap-gid2sid">
65 <imagedescription>IDMAP: GID resolution to matching SID.</imagedescription>
66 <imagefile scale="50">idmap-gid2sid</imagefile>
70 <indexterm><primary>IDMAP</primary></indexterm>
71 In both cases, when winbindd is not running, only locally resolvable groups can be recognized. Please refer to
72 <link linkend="idmap-sid2gid">IDMAP: group SID to GID resolution</link> and <link linkend="idmap-gid2sid">IDMAP: GID resolution to matching SID</link>.
73 The <command>net groupmap</command> is
74 used to establish UNIX group to NT SID mappings as shown in <link linkend="idmap-store-gid2sid">IDMAP: storing group mappings</link>.
77 <image id="idmap-store-gid2sid">
78 <imagedescription>IDMAP storing group mappings.</imagedescription>
79 <imagefile scale="50">idmap-store-gid2sid</imagefile>
83 <indexterm><primary>groupadd</primary></indexterm>
84 <indexterm><primary>groupdel</primary></indexterm>
85 Administrators should be aware that where &smb.conf; group interface scripts make
86 direct calls to the UNIX/Linux system tools (the shadow utilities, <command>groupadd</command>,
87 <command>groupdel</command>, and <command>groupmod</command>), the resulting UNIX/Linux group names will be subject
88 to any limits imposed by these tools. If the tool does not allow upper case characters
89 or space characters, then the creation of an MS Windows NT4/200x style group of
90 <ntgroup>Engineering Managers</ntgroup> will attempt to create an identically named
91 UNIX/Linux group, an attempt that will of course fail.
97 <indexterm><primary>GID</primary></indexterm>
98 <indexterm><primary>SID</primary></indexterm>
99 There are several possible work-arounds for the operating system tools limitation. One
100 method is to use a script that generates a name for the UNIX/Linux system group that
101 fits the operating system limits, and that then just passes the UNIX/Linux group ID (GID)
102 back to the calling Samba interface. This will provide a dynamic work-around solution.
106 Another work-around is to manually create a UNIX/Linux group, then manually create the
107 MS Windows NT4/200x group on the Samba server and then use the <command>net groupmap</command>
108 tool to connect the two to each other.
114 <title>Discussion</title>
117 When installing <application>MS Windows NT4/200x</application> on a computer, the installation
118 program creates default users and groups, notably the <constant>Administrators</constant> group,
119 and gives that group privileges necessary privileges to perform essential system tasks,
120 such as the ability to change the date and time or to kill (or close) any process running on the
125 <indexterm><primary>Administrator</primary></indexterm>
126 The <constant>Administrator</constant> user is a member of the <constant>Administrators</constant> group, and thus inherits
127 <constant>Administrators</constant> group privileges. If a <constant>joe</constant> user is created to be a member of the
128 <constant>Administrators</constant> group, <constant>joe</constant> has exactly the same rights as the user,
129 <constant>Administrator</constant>.
133 When an MS Windows NT4/200x/XP machine is made a Domain Member, the <quote>Domain Admins</quote> group of the
134 PDC is added to the local <constant>Administrators</constant> group of the workstation. Every member of the
135 <constant>Domain Administrators</constant> group inherits the rights of the local <constant>Administrators</constant> group when
136 logging on the workstation.
140 The following steps describe how to make Samba PDC users members of the <constant>Domain Admins</constant> group?
145 Create a UNIX group (usually in <filename>/etc/group</filename>), let's call it <constant>domadm</constant>.
149 Add to this group the users that must be <quote>Administrators</quote>. For example,
150 if you want <constant>joe, john</constant> and <constant>mary</constant> to be administrators,
151 your entry in <filename>/etc/group</filename> will look like this:
154 <para><programlisting>
155 domadm:x:502:joe,john,mary
160 Map this domadm group to the <quote>Domain Admins</quote> group by running the command:
165 &rootprompt;<userinput>net groupmap add ntgroup="Domain Admins" unixgroup=domadm</userinput>
170 <indexterm><primary>Domain Admins group</primary></indexterm>
171 The quotes around <quote>Domain Admins</quote> are necessary due to the space in the group name.
172 Also make sure to leave no white-space surrounding the equal character (=).
177 Now <constant>joe, john</constant> and <constant>mary</constant> are domain administrators.
181 <indexterm><primary>groups</primary><secondary>domain</secondary></indexterm>
182 It is possible to map any arbitrary UNIX group to any Windows NT4/200x group as well as
183 making any UNIX group a Windows domain group. For example, if you wanted to include a
184 UNIX group (e.g., acct) in an ACL on a local file or printer on a Domain Member machine,
185 you would flag that group as a domain group by running the following on the Samba PDC:
190 &rootprompt;<userinput>net groupmap add rid=1000 ntgroup="Accounting" unixgroup=acct</userinput>
195 Be aware that the RID parameter is a unsigned 32-bit integer that should
196 normally start at 1000. However, this RID must not overlap with any RID assigned
197 to a user. Verification for this is done differently depending on the passdb backend
198 you are using. Future versions of the tools may perform the verification automatically,
199 but for now the burden is on you.
203 <title>Important Administrative Information</title>
206 Administrative rights are necessary in two specific forms:
210 <listitem><para>For Samba-3 Domain Controllers and
211 Domain Member Servers/Clients.</para></listitem>
212 <listitem><para>To manage Domain Member Windows workstations.</para></listitem>
216 Versions of Samba up to and including 3.0.10 do not provide a means for assigning rights and privileges
217 that are necessary for system administration tasks from a Windows Domain Member Client machine so that
218 domain administration tasks such as adding/deleting/changing user and group account information, and
219 managing workstation domain membership accounts, can be handled by any account other than root.
223 Samba-3.0.11 introduced a new privilege management interface (see <link linkend="rights">Chapter on Rights and Privileges</link>)
224 that permits these tasks to be delegated to non-root (i.e.: accounts other than the equivalent of the
225 MS Windows Administrator) account.
229 Administrative tasks on a Windows Domain Member workstation, can be done by anyone who is a member of the
230 <constant>Domain Admins</constant> group. This group can be mapped to any convenient UNIX group.
234 <title>Applicable Only to Versions Earlier than 3.0.11</title>
237 Administrative tasks on UNIX/Linux systems, such as adding users or groups, requires <constant>root</constant>
238 level privilege. The addition of a Windows client to a Samba Domain involves the addition of a user account
239 for the Windows client.
243 Many UNIX administrators continue to request the Samba Team make it possible to add Windows workstations, or
244 to ability to add/delete or modify user accounts, without requiring <constant>root</constant> privileges.
245 Such a request violates every understanding of basic UNIX system security.
249 There is no safe way to provide access on a UNIX/Linux system without providing <constant>root</constant>
250 level privilege. Provision of <constant>root</constant> privileges can be done either by logging onto
251 the Domain as the user <constant>root</constant>, or by permitting particular users to use a UNIX account
252 that has a UID=0 in the <filename>/etc/passwd</filename> database. Users of such accounts can use tools
253 like the NT4 Domain User Manager, and the NT4 Domain Server Manager to manage user and group accounts as
254 well as Domain Member server and client accounts. This level of privilege is also needed to manage share
263 <title>Default Users, Groups and Relative Identifiers</title>
266 <indexterm><primary>Relative Identifier</primary><see>RID</see></indexterm>
267 <indexterm><primary>RID</primary></indexterm>
268 When first installed, Microsoft Windows NT4/200x/XP are pre-configured with certain User, Group, and
269 Alias entities. Each has a well-known Relative Identifier (RID). These must be preserved for continued
270 integrity of operation. Samba must be provisioned with certain essential Domain Groups that require
271 the appropriate RID value. When Samba-3 is configured to use <constant>tdbsam</constant> the essential
272 Domain Groups are automatically created. It is the LDAP administrators' responsibility to create
273 (provision) the default NT Groups.
277 Each essential Domain Group must be assigned its respective well-known RID. The default Users, Groups,
278 Aliases, and RIDs are shown in <link linkend="WKURIDS">Well-Known User Default RIDs</link> table.
282 When the <parameter>passdb backend</parameter> uses LDAP (<constant>ldapsam</constant>) it is the
283 administrators' responsibility to create the essential Domain Groups, and to assign each its default RID.
287 It is permissible to create any Domain Group that may be necessary, just make certain that the essential
288 Domain Groups (well known) have been created and assigned its default RID. Other groups you create may
289 be assigned any arbitrary RID you care to use.
293 Be sure to map each Domain Group to a UNIX system group. That is the only way to ensure that the group
294 will be available for use as an NT Domain Group.
298 <table frame="all" id="WKURIDS">
299 <title>Well-Known User Default RIDs</title>
300 <tgroup cols="4" align="left">
301 <colspec align="left"/>
302 <colspec align="left"/>
303 <colspec align="left"/>
304 <colspec align="center"/>
307 <entry>Well-Known Entity</entry>
310 <entry>Essential</entry>
315 <entry>Domain Administrator</entry>
321 <entry>Domain Guest</entry>
327 <entry>Domain KRBTGT</entry>
333 <entry>Domain Admins</entry>
339 <entry>Domain Users</entry>
345 <entry>Domain Guests</entry>
351 <entry>Domain Computers</entry>
357 <entry>Domain Controllers</entry>
363 <entry>Domain Certificate Admins</entry>
369 <entry>Domain Schema Admins</entry>
375 <entry>Domain Enterprise Admins</entry>
381 <entry>Domain Policy Admins</entry>
387 <entry>Builtin Admins</entry>
393 <entry>Builtin users</entry>
399 <entry>Builtin Guests</entry>
405 <entry>Builtin Power Users</entry>
411 <entry>Builtin Account Operators</entry>
417 <entry>Builtin System Operators</entry>
423 <entry>Builtin Print Operators</entry>
429 <entry>Builtin Backup Operators</entry>
435 <entry>Builtin Replicator</entry>
441 <entry>Builtin RAS Servers</entry>
454 <title>Example Configuration</title>
457 You can list the various groups in the mapping database by executing
458 <command>net groupmap list</command>. Here is an example:
461 <indexterm><primary>net</primary><secondary>groupmap</secondary></indexterm>
465 &rootprompt; <userinput>net groupmap list</userinput>
466 Domain Admins (S-1-5-21-2547222302-1596225915-2414751004-512) -> domadmin
467 Domain Users (S-1-5-21-2547222302-1596225915-2414751004-513) -> domuser
468 Domain Guests (S-1-5-21-2547222302-1596225915-2414751004-514) -> domguest
473 For complete details on <command>net groupmap</command>, refer to the net(8) man page.
481 <title>Configuration Scripts</title>
484 Everyone needs tools. Some of us like to create our own, others prefer to use canned tools
485 (i.e., prepared by someone else for general use).
489 <title>Sample &smb.conf; Add Group Script</title>
492 <indexterm><primary>smbgrpadd.sh</primary></indexterm>
493 <indexterm><primary>groupadd limitations</primary></indexterm>
494 A script to create complying group names for use by the Samba group interfaces
495 is provided in <link linkend="smbgrpadd.sh">smbgrpadd.sh</link>. This script will
496 add a temporary entry in the <filename>/etc/group</filename> file and then rename
497 it to to the desired name. This is an example of a method to get around operating
498 system maintenance tool limititations such as that present in some version of the
499 <command>groupadd</command> tool.
502 <indexterm><primary>smbgrpadd.sh</primary></indexterm>
504 <example id="smbgrpadd.sh">
505 <title>smbgrpadd.sh</title>
510 # Add the group using normal system groupadd tool.
513 thegid=`cat /etc/group | grep ^smbtmpgrp00 | cut -d ":" -f3`
515 # Now change the name to what we want for the MS Windows networking end
516 cp /etc/group /etc/group.bak
517 cat /etc/group.bak | sed "s/^smbtmpgrp00/$1/g" > /etc/group
519 # Now return the GID as would normally happen.
527 The &smb.conf; entry for the above script would be something like that in <link linkend="smbgrpadd">the following example</link>.
528 <smbconfexample id="smbgrpadd">
529 <title>Configuration of &smb.conf; for the add group script.</title>
530 <smbconfsection>[global]</smbconfsection>
532 <smbconfoption name="add group script">/path_to_tool/smbgrpadd.sh "%g"</smbconfoption>
540 <title>Script to Configure Group Mapping</title>
543 In our example we have created a UNIX/Linux group called <ntgroup>ntadmin</ntgroup>.
544 Our script will create the additional groups <ntgroup>Orks</ntgroup>, <ntgroup>Elves</ntgroup>, and <ntgroup>Gnomes</ntgroup>.
545 It is a good idea to save this shell script for later re-use just in case you ever need to rebuild your mapping database.
546 For the sake of convenience we elect to save this script as a file called <filename>initGroups.sh</filename>.
547 This script is given in <link linkend="set-group-map">intGroups.sh</link>.
551 <indexterm><primary>initGroups.sh</primary></indexterm>
552 <example id="set-group-map">
553 <title>Script to Set Group Mapping</title>
557 net groupmap modify ntgroup="Domain Admins" unixgroup=ntadmin
558 net groupmap modify ntgroup="Domain Users" unixgroup=users
559 net groupmap modify ntgroup="Domain Guests" unixgroup=nobody
565 net groupmap add ntgroup="Orks" unixgroup=Orks type=d
566 net groupmap add ntgroup="Elves" unixgroup=Elves type=d
567 net groupmap add ntgroup="Gnomes" unixgroup=Gnomes type=d
573 Of course it is expected that the administrator will modify this to suit local needs.
574 For information regarding the use of the <command>net groupmap</command> tool please
575 refer to the man page.
583 <title>Common Errors</title>
586 At this time there are many little surprises for the unwary administrator. In a real sense
587 it is imperative that every step of automated control scripts must be carefully tested
588 manually before putting them into active service.
592 <title>Adding Groups Fails</title>
595 This is a common problem when the <command>groupadd</command> is called directly
596 by the Samba interface script for the <smbconfoption name="add group script"/> in
601 The most common cause of failure is an attempt to add an MS Windows group account
602 that has either an upper case character and/or a space character in it.
606 There are three possible work-arounds. First, use only group names that comply
607 with the limitations of the UNIX/Linux <command>groupadd</command> system tool.
608 Second, it involves the use of the script mentioned earlier in this chapter, and
609 third is the option is to manually create a UNIX/Linux group account that can substitute
610 for the MS Windows group name, then use the procedure listed above to map that group
611 to the MS Windows group.
617 <title>Adding MS Windows Groups to MS Windows Groups Fails</title>
619 <indexterm><primary>groups</primary><secondary>nested</secondary></indexterm>
622 Samba-3 does not support nested groups from the MS Windows control environment.
628 <title>Adding <emphasis>Domain Users</emphasis> to the <emphasis>Power Users</emphasis> Group</title>
631 What must I do to add Domain Users to the Power Users group?
634 <indexterm><primary>Domain Users group</primary></indexterm>
637 The Power Users group is a group that is local to each Windows 200x/XP Professional workstation.
638 You cannot add the Domain Users group to the Power Users group automatically, it must be done on
639 each workstation by logging in as the local workstation <emphasis>administrator</emphasis> and
640 then using the following procedure:
645 Click <guimenu>Start -> Control Panel -> Users and Passwords</guimenu>.
649 Click the <guimenuitem>Advanced</guimenuitem> tab.
653 Click the <guibutton>Advanced</guibutton> button.
657 Click <constant>Groups</constant>.
661 Double click <constant>Power Users</constant>. This will launch the panel to add users or groups
662 to the local machine <constant>Power Uses</constant> group.
666 Click the <guibutton>Add</guibutton> button.
670 Select the domain from which the <constant>Domain Users</constant> group is to be added.
674 Double click the <constant>Domain Users</constant> group.
678 Click the <guibutton>Ok</guibutton> button. If a logon box is presented during this process
679 please remember to enter the connect as <constant>DOMAIN\UserName</constant>. i.e., For the
680 domain <constant>MIDEARTH</constant> and the user <constant>root</constant> enter
681 <constant>MIDEARTH\root</constant>.