1 <?xml version="1.0" encoding="iso8859-1"?>
2 <chapter id="groupmapping">
6 <firstname>Jean François</firstname><surname>Micouleau</surname>
10 <title>Group Mapping &smbmdash; MS Windows and UNIX</title>
14 <indexterm significance="preferred"><primary>groups</primary><secondary>mapping</secondary></indexterm>
15 Starting with Samba-3, new group mapping functionality is available to create associations
16 between Windows group SIDs and UNIX groups. The <command>groupmap</command> subcommand
17 included with the &net; tool can be used to manage these associations.
21 The new facility for mapping NT Groups to UNIX system groups allows the administrator to decide
22 which NT Domain Groups are to be exposed to MS Windows clients. Only those NT Groups that map
23 to a UNIX group that has a value other than the default (<constant>-1</constant>) will be exposed
24 in group selection lists in tools that access domain users and groups.
29 <indexterm><primary>domain admin group</primary></indexterm>
30 The <parameter>domain admin group</parameter> parameter has been removed in Samba-3 and should no longer
31 be specified in &smb.conf;. This parameter was used to give the listed users membership in the
32 <constant>Domain Admins</constant> Windows group which gave local admin rights on their workstations
33 (in default configurations).
38 <title>Features and Benefits</title>
41 Samba allows the administrator to create MS Windows NT4/200x group accounts and to
42 arbitrarily associate them with UNIX/Linux group accounts.
46 <indexterm><primary>UID</primary></indexterm>
47 <indexterm><primary>GID</primary></indexterm>
48 Group accounts can be managed using the MS Windows NT4 or MS Windows 200x/XP Professional MMC tools.
49 Appropriate interface scripts should be provided in &smb.conf; if it is desired that UNIX/Linux system
50 accounts should be automatically created when these tools are used. In the absence of these scripts, and
51 so long as <command>winbindd</command> is running, Samba group accounts that are created using these
52 tools will be allocated UNIX UIDs/GIDs from the ID range specified by the
53 <smbconfoption><name>idmap uid</name></smbconfoption>/<smbconfoption><name>idmap gid</name></smbconfoption>
54 parameters in the &smb.conf; file.
57 <figure id="idmap-sid2gid"><title>IDMAP: group SID to GID resolution.</title>
59 <imageobject role="latex"><imagedata fileref="projdoc/imagefiles/idmap-sid2gid" scale="50" scalefit="1"/></imageobject>
60 <imageobject><imagedata fileref="projdoc/imagefiles/idmap-sid2gid.png" scale="50" scalefit="1"/></imageobject>
64 <figure id="idmap-gid2sid"><title>IDMAP: GID resolution to matching SID.</title>
66 <imageobject role="latex"><imagedata fileref="projdoc/imagefiles/idmap-gid2sid" scale="50" scalefit="1"/></imageobject>
67 <imageobject><imagedata fileref="projdoc/imagefiles/idmap-gid2sid.png" scale="50" scalefit="1"/></imageobject>
72 In both cases, when winbindd is not running, only locally resolvable groups can be recognized. Please refer to
73 <link linkend="idmap-sid2gid"></link> and <link linkend="idmap-gid2sid"></link>. The <command>net groupmap</command> is
74 used to establish UNIX group to NT SID mappings as shown in <link linkend="idmap-store-gid2sid"></link>.
77 <figure id="idmap-store-gid2sid"><title>IDMAP storing group mappings.</title>
79 <imageobject role="latex"><imagedata fileref="projdoc/imagefiles/idmap-store-gid2sid" scale="50" scalefit="1"/></imageobject>
80 <imageobject><imagedata fileref="projdoc/imagefiles/idmap-store-gid2sid.png" scale="50" scalefit="1"/></imageobject>
86 <indexterm><primary>groupadd</primary></indexterm>
87 <indexterm><primary>groupdel</primary></indexterm>
88 Administrators should be aware that where &smb.conf; group interface scripts make
89 direct calls to the UNIX/Linux system tools (the shadow utilities, <command>groupadd</command>,
90 <command>groupdel</command>, and <command>groupmod</command>), the resulting UNIX/Linux group names will be subject
91 to any limits imposed by these tools. If the tool does not allow upper case characters
92 or space characters, then the creation of an MS Windows NT4/200x style group of
93 <ntgroup>Engineering Managers</ntgroup> will attempt to create an identically named
94 UNIX/Linux group, an attempt that will of course fail.
100 <indexterm><primary>GID</primary></indexterm>
101 <indexterm><primary>SID</primary></indexterm>
102 There are several possible work-arounds for the operating system tools limitation. One
103 method is to use a script that generates a name for the UNIX/Linux system group that
104 fits the operating system limits, and that then just passes the UNIX/Linux group ID (GID)
105 back to the calling Samba interface. This will provide a dynamic work-around solution.
109 Another work-around is to manually create a UNIX/Linux group, then manually create the
110 MS Windows NT4/200x group on the Samba server and then use the <command>net groupmap</command>
111 tool to connect the two to each other.
117 <title>Discussion</title>
120 When installing <application>MS Windows NT4/200x</application> on a computer, the installation
121 program creates default users and groups, notably the <constant>Administrators</constant> group,
122 and gives that group privileges necessary privileges to perform essential system tasks,
123 such as the ability to change the date and time or to kill (or close) any process running on the
128 <indexterm><primary>Administrator</primary></indexterm>
129 The <constant>Administrator</constant> user is a member of the <constant>Administrators</constant> group, and thus inherits
130 <constant>Administrators</constant> group privileges. If a <constant>joe</constant> user is created to be a member of the
131 <constant>Administrators</constant> group, <constant>joe</constant> has exactly the same rights as the user,
132 <constant>Administrator</constant>.
136 When an MS Windows NT4/200x/XP machine is made a Domain Member, the <quote>Domain Admins</quote> group of the
137 PDC is added to the local <constant>Administrators</constant> group of the workstation. Every member of the
138 <constant>Domain Administrators</constant> group inherits the rights of the local <constant>Administrators</constant> group when
139 logging on the workstation.
143 The following steps describe how to make Samba PDC users members of the <constant>Domain Admins</constant> group?
148 Create a UNIX group (usually in <filename>/etc/group</filename>), let's call it <constant>domadm</constant>.
152 Add to this group the users that must be <quote>Administrators</quote>. For example,
153 if you want <constant>joe, john</constant> and <constant>mary</constant> to be administrators,
154 your entry in <filename>/etc/group</filename> will look like this:
157 <para><programlisting>
158 domadm:x:502:joe,john,mary
163 Map this domadm group to the <quote>Domain Admins</quote> group by running the command:
168 &rootprompt;<userinput>net groupmap add ntgroup="Domain Admins" UNIXgroup=domadm</userinput>
173 <indexterm><primary>Domain Admins group</primary></indexterm>
174 The quotes around <quote>Domain Admins</quote> are necessary due to the space in the group name.
175 Also make sure to leave no white-space surrounding the equal character (=).
180 Now <constant>joe, john</constant> and <constant>mary</constant> are domain administrators.
184 <indexterm><primary>groups</primary><secondary>domain</secondary></indexterm>
185 It is possible to map any arbitrary UNIX group to any Windows NT4/200x group as well as
186 making any UNIX group a Windows domain group. For example, if you wanted to include a
187 UNIX group (e.g., acct) in an ACL on a local file or printer on a Domain Member machine,
188 you would flag that group as a domain group by running the following on the Samba PDC:
193 &rootprompt;<userinput>net groupmap add rid=1000 ntgroup="Accounting" UNIXgroup=acct</userinput>
198 Be aware that the RID parameter is a unsigned 32-bit integer that should
199 normally start at 1000. However, this RID must not overlap with any RID assigned
200 to a user. Verification for this is done differently depending on the passdb backend
201 you are using. Future versions of the tools may perform the verification automatically,
202 but for now the burden is on you.
206 <title>Default Users, Groups and Relative Identifiers</title>
209 <indexterm><primary>Relative Identifier</primary><see>RID</see></indexterm>
210 <indexterm><primary>RID</primary></indexterm>
211 When first installed, Microsoft Windows NT4/200x/XP are preconfigured with certain User, Group, and
212 Alias entities. Each has a well-known Relative Identifier (RID). These must be preserved for continued
213 integrity of operation. Samba must be provisioned with certain essential Domain Groups that require
214 the appropriate RID value. When Samba-3 is configured to use <constant>tdbsam</constant> the essential
215 Domain Groups are automatically created. It is the LDAP administrators' responsibility to create
216 (provision) the default NT Groups.
220 Each essential Domain Group must be assigned its respective well-kown RID. The default Users, Groups,
221 Aliases, and RIDs are shown in <link linkend="WKURIDS"/>.
225 When the <parameter>passdb backend</parameter> uses LDAP (<constant>ldapsam</constant>) it is the
226 admininstrators' responsibility to create the essential Domain Groups, and to assign each its default RID.
230 It is permissible to create any Domain Group that may be necessary, just make certain that the essential
231 Domain Groups (well known) have been created and assigned its default RID. Other groups you create may
232 be assigned any arbitrary RID you care to use.
236 Be sure to map each Domain Group to a UNIX system group. That is the only way to ensure that the group
237 will be available for use as an NT Domain Group.
241 <table frame="all" id="WKURIDS">
242 <title>Well-Known User Default RIDs</title>
243 <tgroup cols="4" align="left">
244 <colspec align="left"/>
245 <colspec align="left"/>
246 <colspec align="left"/>
247 <colspec align="center"/>
250 <entry>Well-Known Entity</entry>
253 <entry>Essential</entry>
258 <entry>Domain Administrator</entry>
264 <entry>Domain Guest</entry>
270 <entry>Domain KRBTGT</entry>
276 <entry>Domain Admins</entry>
282 <entry>Domain Users</entry>
288 <entry>Domain Guests</entry>
294 <entry>Domain Computers</entry>
300 <entry>Domain Controllers</entry>
306 <entry>Domain Certificate Admins</entry>
312 <entry>Domain Schema Admins</entry>
318 <entry>Domain Enterprise Admins</entry>
324 <entry>Domain Policy Admins</entry>
330 <entry>Builtin Admins</entry>
336 <entry>Builtin users</entry>
342 <entry>Builtin Guests</entry>
348 <entry>Builtin Power Users</entry>
354 <entry>Builtin Account Operators</entry>
360 <entry>Builtin System Operators</entry>
366 <entry>Builtin Print Operators</entry>
372 <entry>Builtin Backup Operators</entry>
378 <entry>Builtin Replicator</entry>
384 <entry>Builtin RAS Servers</entry>
397 <title>Example Configuration</title>
400 You can list the various groups in the mapping database by executing
401 <command>net groupmap list</command>. Here is an example:
404 <indexterm><primary>net</primary><secondary>groupmap</secondary></indexterm>
408 &rootprompt; <userinput>net groupmap list</userinput>
409 Domain Admins (S-1-5-21-2547222302-1596225915-2414751004-512) -> domadmin
410 Domain Users (S-1-5-21-2547222302-1596225915-2414751004-513) -> domuser
411 Domain Guests (S-1-5-21-2547222302-1596225915-2414751004-514) -> domguest
416 For complete details on <command>net groupmap</command>, refer to the net(8) man page.
424 <title>Configuration Scripts</title>
427 Everyone needs tools. Some of us like to create our own, others prefer to use canned tools
428 (i.e., prepared by someone else for general use).
432 <title>Sample &smb.conf; Add Group Script</title>
435 A script to create complying group names for use by the Samba group interfaces
436 is provided in <link linkend="smbgrpadd.sh"></link>.
439 <indexterm><primary>smbgrpadd.sh</primary></indexterm>
441 <example id="smbgrpadd.sh">
442 <title>smbgrpadd.sh</title>
447 # Add the group using normal system groupadd tool.
450 thegid=`cat /etc/group | grep smbtmpgrp00 | cut -d ":" -f3`
452 # Now change the name to what we want for the MS Windows networking end
453 cp /etc/group /etc/group.bak
454 cat /etc/group.bak | sed s/smbtmpgrp00/$1/g > /etc/group
456 # Now return the GID as would normally happen.
464 The &smb.conf; entry for the above script would be something like that in <link linkend="smbgrpadd"/>.
465 <smbconfexample id="smbgrpadd">
466 <title>Configuration of &smb.conf; for the add group script.</title>
467 <smbconfsection>[global]</smbconfsection>
469 <smbconfoption><name>add group script</name><value>/path_to_tool/smbgrpadd.sh %g</value></smbconfoption>
477 <title>Script to Configure Group Mapping</title>
480 In our example we have created a UNIX/Linux group called <ntgroup>ntadmin</ntgroup>.
481 Our script will create the additional groups <ntgroup>Orks</ntgroup>, <ntgroup>Elves</ntgroup>, and <ntgroup>Gnomes</ntgroup>.
482 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.
483 For the sake of concenience we elect to save this script as a file called <filename>initGroups.sh</filename>.
484 This script is given in <link linkend="set-group-map"></link>.
488 <indexterm><primary>initGroups.sh</primary></indexterm>
489 <example id="set-group-map">
490 <title>Script to Set Group Mapping</title>
494 net groupmap modify ntgroup="Domain Admins" unixgroup=ntadmin
495 net groupmap modify ntgroup="Domain Users" unixgroup=users
496 net groupmap modify ntgroup="Domain Guests" unixgroup=nobody
502 net groupmap add ntgroup="Orks" unixgroup=Orks type=d
503 net groupmap add ntgroup="Elves" unixgroup=Elves type=d
504 net groupmap add ntgroup="Gnomes" unixgroup=Gnomes type=d
510 Of course it is expected that the administrator will modify this to suit local needs.
511 For information regarding the use of the <command>net groupmap</command> tool please
512 refer to the man page.
520 <title>Common Errors</title>
523 At this time there are many little surprises for the unwary administrator. In a real sense
524 it is imperative that every step of automated control scripts must be carefully tested
525 manually before putting them into active service.
529 <title>Adding Groups Fails</title>
532 This is a common problem when the <command>groupadd</command> is called directly
533 by the Samba interface script for the <smbconfoption><name>add group script</name></smbconfoption> in
538 The most common cause of failure is an attempt to add an MS Windows group account
539 that has either an upper case character and/or a space character in it.
543 There are three possible work-arounds. First, use only group names that comply
544 with the limitations of the UNIX/Linux <command>groupadd</command> system tool.
545 Second, it involves the use of the script mentioned earlier in this chapter, and
546 third is the option is to manually create a UNIX/Linux group account that can substitute
547 for the MS Windows group name, then use the procedure listed above to map that group
548 to the MS Windows group.
554 <title>Adding MS Windows Groups to MS Windows Groups Fails</title>
556 <indexterm><primary>groups</primary><secondary>nested</secondary></indexterm>
559 Samba-3 does not support nested groups from the MS Windows control environment.
565 <title>Adding <emphasis>Domain Users</emphasis> to the <emphasis>Power Users</emphasis> Group</title>
568 What must I do to add Domain Users to the Power Users group?
571 <indexterm><primary>Domain Users group</primary></indexterm>
574 The Power Users group is a group that is local to each Windows 200x/XP Professional workstation.
575 You cannot add the Domain Users group to the Power Users group automatically, it must be done on
576 each workstation by logging in as the local workstation <emphasis>administrator</emphasis> and
577 then using the following procedure:
582 Click <guimenu>Start -> Control Panel -> Users and Passwords</guimenu>.
586 Click the <guimenuitem>Advanced</guimenuitem> tab.
590 Click the <guibutton>Advanced</guibutton> button.
594 Click <constant>Groups</constant>.
598 Double click <constant>Power Users</constant>. This will launch the panel to add users or groups
599 to the local machine <constant>Power Uses</constant> group.
603 Click the <guibutton>Add</guibutton> button.
607 Select the domain from which the <constant>Domain Users</constant> group is to be added.
611 Double click the <constant>Domain Users</constant> group.
615 Click the <guibutton>Ok</guibutton> button. If a logon box is presented during this process
616 please remember to enter the connect as <constant>DOMAIN\UserName</constant>. i.e., For the
617 domain <constant>MIDEARTH</constant> and the user <constant>root</constant> enter
618 <constant>MIDEARTH\root</constant>.