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;. In Samba-2.2.x, 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="howto/imagefiles/idmap-sid2gid" scale="50" scalefit="1"/></imageobject>
60 <imageobject><imagedata fileref="howto/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="howto/imagefiles/idmap-gid2sid" scale="50" scalefit="1"/></imageobject>
67 <imageobject><imagedata fileref="howto/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">IDMAP: group SID to GID resolution</link> and <link linkend="idmap-gid2sid">IDMAP: GID resolution to matching SID</link>.
74 The <command>net groupmap</command> is
75 used to establish UNIX group to NT SID mappings as shown in <link linkend="idmap-store-gid2sid">IDMAP: storing group mappings</link>.
78 <figure id="idmap-store-gid2sid"><title>IDMAP storing group mappings.</title>
80 <imageobject role="latex"><imagedata fileref="howto/imagefiles/idmap-store-gid2sid" scale="50" scalefit="1"/></imageobject>
81 <imageobject><imagedata fileref="howto/imagefiles/idmap-store-gid2sid.png" scale="50" scalefit="1"/></imageobject>
87 <indexterm><primary>groupadd</primary></indexterm>
88 <indexterm><primary>groupdel</primary></indexterm>
89 Administrators should be aware that where &smb.conf; group interface scripts make
90 direct calls to the UNIX/Linux system tools (the shadow utilities, <command>groupadd</command>,
91 <command>groupdel</command>, and <command>groupmod</command>), the resulting UNIX/Linux group names will be subject
92 to any limits imposed by these tools. If the tool does not allow upper case characters
93 or space characters, then the creation of an MS Windows NT4/200x style group of
94 <ntgroup>Engineering Managers</ntgroup> will attempt to create an identically named
95 UNIX/Linux group, an attempt that will of course fail.
101 <indexterm><primary>GID</primary></indexterm>
102 <indexterm><primary>SID</primary></indexterm>
103 There are several possible work-arounds for the operating system tools limitation. One
104 method is to use a script that generates a name for the UNIX/Linux system group that
105 fits the operating system limits, and that then just passes the UNIX/Linux group ID (GID)
106 back to the calling Samba interface. This will provide a dynamic work-around solution.
110 Another work-around is to manually create a UNIX/Linux group, then manually create the
111 MS Windows NT4/200x group on the Samba server and then use the <command>net groupmap</command>
112 tool to connect the two to each other.
118 <title>Discussion</title>
121 When installing <application>MS Windows NT4/200x</application> on a computer, the installation
122 program creates default users and groups, notably the <constant>Administrators</constant> group,
123 and gives that group privileges necessary privileges to perform essential system tasks,
124 such as the ability to change the date and time or to kill (or close) any process running on the
129 <indexterm><primary>Administrator</primary></indexterm>
130 The <constant>Administrator</constant> user is a member of the <constant>Administrators</constant> group, and thus inherits
131 <constant>Administrators</constant> group privileges. If a <constant>joe</constant> user is created to be a member of the
132 <constant>Administrators</constant> group, <constant>joe</constant> has exactly the same rights as the user,
133 <constant>Administrator</constant>.
137 When an MS Windows NT4/200x/XP machine is made a Domain Member, the <quote>Domain Admins</quote> group of the
138 PDC is added to the local <constant>Administrators</constant> group of the workstation. Every member of the
139 <constant>Domain Administrators</constant> group inherits the rights of the local <constant>Administrators</constant> group when
140 logging on the workstation.
144 The following steps describe how to make Samba PDC users members of the <constant>Domain Admins</constant> group?
149 Create a UNIX group (usually in <filename>/etc/group</filename>), let's call it <constant>domadm</constant>.
153 Add to this group the users that must be <quote>Administrators</quote>. For example,
154 if you want <constant>joe, john</constant> and <constant>mary</constant> to be administrators,
155 your entry in <filename>/etc/group</filename> will look like this:
158 <para><programlisting>
159 domadm:x:502:joe,john,mary
164 Map this domadm group to the <quote>Domain Admins</quote> group by running the command:
169 &rootprompt;<userinput>net groupmap add ntgroup=<quote>Domain Admins</quote> unixgroup=domadm</userinput>
174 <indexterm><primary>Domain Admins group</primary></indexterm>
175 The quotes around <quote>Domain Admins</quote> are necessary due to the space in the group name.
176 Also make sure to leave no white-space surrounding the equal character (=).
181 Now <constant>joe, john</constant> and <constant>mary</constant> are domain administrators.
185 <indexterm><primary>groups</primary><secondary>domain</secondary></indexterm>
186 It is possible to map any arbitrary UNIX group to any Windows NT4/200x group as well as
187 making any UNIX group a Windows domain group. For example, if you wanted to include a
188 UNIX group (e.g., acct) in an ACL on a local file or printer on a Domain Member machine,
189 you would flag that group as a domain group by running the following on the Samba PDC:
194 &rootprompt;<userinput>net groupmap add rid=1000 ntgroup="Accounting" unixgroup=acct</userinput>
199 Be aware that the RID parameter is a unsigned 32-bit integer that should
200 normally start at 1000. However, this RID must not overlap with any RID assigned
201 to a user. Verification for this is done differently depending on the passdb backend
202 you are using. Future versions of the tools may perform the verification automatically,
203 but for now the burden is on you.
207 <title>Important Administrative Information</title>
210 Administrative rights are necessary in two specific forms:
214 <listitem><para>For Samba-3 Domain Controllers and
215 Domain Member Servers/Clients.</para></listitem>
216 <listitem><para>To manage Domain Member Windows workstations.</para></listitem>
220 Administrative tasks on UNIX/Linux systems, such as adding users or groups, requires <constant>root</constant>
221 level privilege. The addition of a Windows client to a Samba Domain involves the addition of a user account
222 for the Windows client.
226 Many UNIX administrators continue to request the Samba Team make it possible to add Windows workstations, or
227 to ability to add/delete or modify user accounts, without requiring <constant>root</constant> privileges.
228 Such a request violates every understanding of basic UNIX system security.
232 There is no safe way to provide access on a UNIX/Linux system without providing <constant>root</constant>
233 level privilege. Provision of <constant>root</constant> privileges can be done either by logging onto
234 the Domain as the user <constant>root</constant>, or by permitting particular users to use a UNIX account
235 that is a member of the UNIX group that has a GID=0 as the primary group in the <filename>/etc/passwd</filename>
236 database. Users of such accounts can use tools like the NT4 Domain User Manager, and the NT4 Domain Server
237 Manager to manage user and group accounts as well as Domain Member server and client accounts. This level
238 of privilege is also needed to manage share level ACLs.
242 Administrative tasks on a Windows Domain Member workstation, can be done by anyone who is a member of the
243 <constant>Domain Admins</constant> group. This group can be mapped to any convenient UNIX group.
249 <title>Default Users, Groups and Relative Identifiers</title>
252 <indexterm><primary>Relative Identifier</primary><see>RID</see></indexterm>
253 <indexterm><primary>RID</primary></indexterm>
254 When first installed, Microsoft Windows NT4/200x/XP are pre-configured with certain User, Group, and
255 Alias entities. Each has a well-known Relative Identifier (RID). These must be preserved for continued
256 integrity of operation. Samba must be provisioned with certain essential Domain Groups that require
257 the appropriate RID value. When Samba-3 is configured to use <constant>tdbsam</constant> the essential
258 Domain Groups are automatically created. It is the LDAP administrators' responsibility to create
259 (provision) the default NT Groups.
263 Each essential Domain Group must be assigned its respective well-known RID. The default Users, Groups,
264 Aliases, and RIDs are shown in <link linkend="WKURIDS">Well-Known User Default RIDs</link> table.
268 When the <parameter>passdb backend</parameter> uses LDAP (<constant>ldapsam</constant>) it is the
269 administrators' responsibility to create the essential Domain Groups, and to assign each its default RID.
273 It is permissible to create any Domain Group that may be necessary, just make certain that the essential
274 Domain Groups (well known) have been created and assigned its default RID. Other groups you create may
275 be assigned any arbitrary RID you care to use.
279 Be sure to map each Domain Group to a UNIX system group. That is the only way to ensure that the group
280 will be available for use as an NT Domain Group.
284 <table frame="all" id="WKURIDS">
285 <title>Well-Known User Default RIDs</title>
286 <tgroup cols="4" align="left">
287 <colspec align="left"/>
288 <colspec align="left"/>
289 <colspec align="left"/>
290 <colspec align="center"/>
293 <entry>Well-Known Entity</entry>
296 <entry>Essential</entry>
301 <entry>Domain Administrator</entry>
307 <entry>Domain Guest</entry>
313 <entry>Domain KRBTGT</entry>
319 <entry>Domain Admins</entry>
325 <entry>Domain Users</entry>
331 <entry>Domain Guests</entry>
337 <entry>Domain Computers</entry>
343 <entry>Domain Controllers</entry>
349 <entry>Domain Certificate Admins</entry>
355 <entry>Domain Schema Admins</entry>
361 <entry>Domain Enterprise Admins</entry>
367 <entry>Domain Policy Admins</entry>
373 <entry>Builtin Admins</entry>
379 <entry>Builtin users</entry>
385 <entry>Builtin Guests</entry>
391 <entry>Builtin Power Users</entry>
397 <entry>Builtin Account Operators</entry>
403 <entry>Builtin System Operators</entry>
409 <entry>Builtin Print Operators</entry>
415 <entry>Builtin Backup Operators</entry>
421 <entry>Builtin Replicator</entry>
427 <entry>Builtin RAS Servers</entry>
440 <title>Example Configuration</title>
443 You can list the various groups in the mapping database by executing
444 <command>net groupmap list</command>. Here is an example:
447 <indexterm><primary>net</primary><secondary>groupmap</secondary></indexterm>
451 &rootprompt; <userinput>net groupmap list</userinput>
452 Domain Admins (S-1-5-21-2547222302-1596225915-2414751004-512) -> domadmin
453 Domain Users (S-1-5-21-2547222302-1596225915-2414751004-513) -> domuser
454 Domain Guests (S-1-5-21-2547222302-1596225915-2414751004-514) -> domguest
459 For complete details on <command>net groupmap</command>, refer to the net(8) man page.
467 <title>Configuration Scripts</title>
470 Everyone needs tools. Some of us like to create our own, others prefer to use canned tools
471 (i.e., prepared by someone else for general use).
475 <title>Sample &smb.conf; Add Group Script</title>
478 A script to create complying group names for use by the Samba group interfaces
479 is provided in <link linkend="smbgrpadd.sh">smbgrpadd.sh</link>.
482 <indexterm><primary>smbgrpadd.sh</primary></indexterm>
484 <example id="smbgrpadd.sh">
485 <title>smbgrpadd.sh</title>
490 # Add the group using normal system groupadd tool.
493 thegid=`cat /etc/group | grep ^smbtmpgrp00 | cut -d ":" -f3`
495 # Now change the name to what we want for the MS Windows networking end
496 cp /etc/group /etc/group.bak
497 cat /etc/group.bak | sed "s/^smbtmpgrp00/$1/g" > /etc/group
499 # Now return the GID as would normally happen.
507 The &smb.conf; entry for the above script would be something like that in <link linkend="smbgrpadd">the following example</link>.
508 <smbconfexample id="smbgrpadd">
509 <title>Configuration of &smb.conf; for the add group script.</title>
510 <smbconfsection>[global]</smbconfsection>
512 <smbconfoption><name>add group script</name><value>/path_to_tool/smbgrpadd.sh "%g"</value></smbconfoption>
520 <title>Script to Configure Group Mapping</title>
523 In our example we have created a UNIX/Linux group called <ntgroup>ntadmin</ntgroup>.
524 Our script will create the additional groups <ntgroup>Orks</ntgroup>, <ntgroup>Elves</ntgroup>, and <ntgroup>Gnomes</ntgroup>.
525 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.
526 For the sake of convenience we elect to save this script as a file called <filename>initGroups.sh</filename>.
527 This script is given in <link linkend="set-group-map">intGroups.sh</link>.
531 <indexterm><primary>initGroups.sh</primary></indexterm>
532 <example id="set-group-map">
533 <title>Script to Set Group Mapping</title>
537 net groupmap modify ntgroup="Domain Admins" unixgroup=ntadmin
538 net groupmap modify ntgroup="Domain Users" unixgroup=users
539 net groupmap modify ntgroup="Domain Guests" unixgroup=nobody
545 net groupmap add ntgroup="Orks" unixgroup=Orks type=d
546 net groupmap add ntgroup="Elves" unixgroup=Elves type=d
547 net groupmap add ntgroup="Gnomes" unixgroup=Gnomes type=d
553 Of course it is expected that the administrator will modify this to suit local needs.
554 For information regarding the use of the <command>net groupmap</command> tool please
555 refer to the man page.
563 <title>Common Errors</title>
566 At this time there are many little surprises for the unwary administrator. In a real sense
567 it is imperative that every step of automated control scripts must be carefully tested
568 manually before putting them into active service.
572 <title>Adding Groups Fails</title>
575 This is a common problem when the <command>groupadd</command> is called directly
576 by the Samba interface script for the <smbconfoption><name>add group script</name></smbconfoption> in
581 The most common cause of failure is an attempt to add an MS Windows group account
582 that has either an upper case character and/or a space character in it.
586 There are three possible work-arounds. First, use only group names that comply
587 with the limitations of the UNIX/Linux <command>groupadd</command> system tool.
588 Second, it involves the use of the script mentioned earlier in this chapter, and
589 third is the option is to manually create a UNIX/Linux group account that can substitute
590 for the MS Windows group name, then use the procedure listed above to map that group
591 to the MS Windows group.
597 <title>Adding MS Windows Groups to MS Windows Groups Fails</title>
599 <indexterm><primary>groups</primary><secondary>nested</secondary></indexterm>
602 Samba-3 does not support nested groups from the MS Windows control environment.
608 <title>Adding <emphasis>Domain Users</emphasis> to the <emphasis>Power Users</emphasis> Group</title>
611 What must I do to add Domain Users to the Power Users group?
614 <indexterm><primary>Domain Users group</primary></indexterm>
617 The Power Users group is a group that is local to each Windows 200x/XP Professional workstation.
618 You cannot add the Domain Users group to the Power Users group automatically, it must be done on
619 each workstation by logging in as the local workstation <emphasis>administrator</emphasis> and
620 then using the following procedure:
625 Click <guimenu>Start -> Control Panel -> Users and Passwords</guimenu>.
629 Click the <guimenuitem>Advanced</guimenuitem> tab.
633 Click the <guibutton>Advanced</guibutton> button.
637 Click <constant>Groups</constant>.
641 Double click <constant>Power Users</constant>. This will launch the panel to add users or groups
642 to the local machine <constant>Power Uses</constant> group.
646 Click the <guibutton>Add</guibutton> button.
650 Select the domain from which the <constant>Domain Users</constant> group is to be added.
654 Double click the <constant>Domain Users</constant> group.
658 Click the <guibutton>Ok</guibutton> button. If a logon box is presented during this process
659 please remember to enter the connect as <constant>DOMAIN\UserName</constant>. i.e., For the
660 domain <constant>MIDEARTH</constant> and the user <constant>root</constant> enter
661 <constant>MIDEARTH\root</constant>.