Follow DTD more strictly
[Samba/gebeck_regimport.git] / docs / docbook / projdoc / GROUP-MAPPING-HOWTO.xml
blob9e9d1a0e0192f520f34d240095f2e7e8224bedf2
1 <?xml version="1.0" encoding="iso8859-1"?>
2 <chapter id="groupmapping">
3 <chapterinfo>
4         &author.jht;
5         <author>
6                 <firstname>Jean François</firstname><surname>Micouleau</surname>
7         </author>
8         &author.jerry;
9 </chapterinfo>
10 <title>Group Mapping &smbmdash; MS Windows and UNIX</title>
13         <para>
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.
18         </para>
20         <para>
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.
25         </para>
27         <warning>
28         <para>
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).
34         </para>
35         </warning>
37 <sect1>
38 <title>Features and Benefits</title>
40         <para>
41         Samba allows the administrator to create MS Windows NT4/200x group accounts and to
42         arbitrarily associate them with UNIX/Linux group accounts.
43         </para>
45         <para>
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.
55         </para>
57         <figure id="idmap-sid2gid"><title>IDMAP: group SID to GID resolution.</title>
58         <mediaobject>
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>
61         </mediaobject>
62         </figure>
64         <figure id="idmap-gid2sid"><title>IDMAP: GID resolution to matching SID.</title>
65         <mediaobject>
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>
68         </mediaobject>
69         </figure>
71         <para>
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>.
75         </para>
77         <figure id="idmap-store-gid2sid"><title>IDMAP storing group mappings.</title>
78         <mediaobject>
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>
81         </mediaobject>
82         </figure>
85         <para>
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.
95         </para>
99         <para>
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.
106         </para>
108         <para>
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.
112         </para>
114 </sect1>
116 <sect1>
117 <title>Discussion</title>
119         <para>
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
124         local machine.
125         </para>
126         
127         <para>
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>.
133         </para>
135         <para>
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.
140         </para>
142         <para>
143         The following steps describe how to make Samba PDC users members of the <constant>Domain Admins</constant> group?
144         </para>
146         <orderedlist>
147                 <listitem><para>
148                 Create a UNIX group (usually in <filename>/etc/group</filename>), let's call it <constant>domadm</constant>.
149                 </para></listitem>
151                 <listitem><para>
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:
155                 </para>
157                 <para><programlisting>
158                 domadm:x:502:joe,john,mary
159                 </programlisting>
160                 </para></listitem>
162                 <listitem><para>
163                 Map this domadm group to the <quote>Domain Admins</quote> group by running the command:
164                 </para>
166                 <para>
167         <screen>
168         &rootprompt;<userinput>net groupmap add ntgroup="Domain Admins" UNIXgroup=domadm</userinput>
169         </screen>
170         </para>
171                 
172                 <para>
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 (=).
176                 </para></listitem>
177         </orderedlist>
179         <para>
180         Now <constant>joe, john</constant> and <constant>mary</constant> are domain administrators.
181         </para>
183         <para>
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:
189         </para>
191         <para>
192 <screen>
193 &rootprompt;<userinput>net groupmap add rid=1000 ntgroup="Accounting" UNIXgroup=acct</userinput>
194 </screen>
195         </para>
197         <para>
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.
203         </para>
205         <sect2>
206         <title>Default Users, Groups and Relative Identifiers</title>
208         <para>
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.
217         </para>
219         <para>
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"/>.
222         </para>
224         <note><para>
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.
227         </para></note>
229         <para>
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.
233         </para>
235         <para>
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.
238         </para>
240         <para>
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"/>
248                         <thead>
249                                 <row>
250                                         <entry>Well-Known Entity</entry>
251                                         <entry>RID</entry>
252                                         <entry>Type</entry>
253                                         <entry>Essential</entry>
254                                 </row>
255                         </thead>
256                         <tbody>
257                                 <row>
258                                         <entry>Domain Administrator</entry>
259                                         <entry>500</entry>
260                                         <entry>User</entry>
261                                         <entry>No</entry>
262                                 </row>
263                                 <row>
264                                         <entry>Domain Guest</entry>
265                                         <entry>501</entry>
266                                         <entry>User</entry>
267                                         <entry>No</entry>
268                                 </row>
269                                 <row>
270                                         <entry>Domain KRBTGT</entry>
271                                         <entry>502</entry>
272                                         <entry>User</entry>
273                                         <entry>No</entry>
274                                 </row>
275                                 <row>
276                                         <entry>Domain Admins</entry>
277                                         <entry>512</entry>
278                                         <entry>Group</entry>
279                                         <entry>Yes</entry>
280                                 </row>
281                                 <row>
282                                         <entry>Domain Users</entry>
283                                         <entry>513</entry>
284                                         <entry>Group</entry>
285                                         <entry>Yes</entry>
286                                 </row>
287                                 <row>
288                                         <entry>Domain Guests</entry>
289                                         <entry>514</entry>
290                                         <entry>Group</entry>
291                                         <entry>Yes</entry>
292                                 </row>
293                                 <row>
294                                         <entry>Domain Computers</entry>
295                                         <entry>515</entry>
296                                         <entry>Group</entry>
297                                         <entry>No</entry>
298                                 </row>
299                                 <row>
300                                         <entry>Domain Controllers</entry>
301                                         <entry>516</entry>
302                                         <entry>Group</entry>
303                                         <entry>No</entry>
304                                 </row>
305                                 <row>
306                                         <entry>Domain Certificate Admins</entry>
307                                         <entry>517</entry>
308                                         <entry>Group</entry>
309                                         <entry>No</entry>
310                                 </row>
311                                 <row>
312                                         <entry>Domain Schema Admins</entry>
313                                         <entry>518</entry>
314                                         <entry>Group</entry>
315                                         <entry>No</entry>
316                                 </row>
317                                 <row>
318                                         <entry>Domain Enterprise Admins</entry>
319                                         <entry>519</entry>
320                                         <entry>Group</entry>
321                                         <entry>No</entry>
322                                 </row>
323                                 <row>
324                                         <entry>Domain Policy Admins</entry>
325                                         <entry>520</entry>
326                                         <entry>Group</entry>
327                                         <entry>No</entry>
328                                 </row>
329                                 <row>
330                                         <entry>Builtin Admins</entry>
331                                         <entry>544</entry>
332                                         <entry>Alias</entry>
333                                         <entry>No</entry>
334                                 </row>
335                                 <row>
336                                         <entry>Builtin users</entry>
337                                         <entry>545</entry>
338                                         <entry>Alias</entry>
339                                         <entry>No</entry>
340                                 </row>
341                                 <row>
342                                         <entry>Builtin Guests</entry>
343                                         <entry>546</entry>
344                                         <entry>Alias</entry>
345                                         <entry>No</entry>
346                                 </row>
347                                 <row>
348                                         <entry>Builtin Power Users</entry>
349                                         <entry>547</entry>
350                                         <entry>Alias</entry>
351                                         <entry>No</entry>
352                                 </row>
353                                 <row>
354                                         <entry>Builtin Account Operators</entry>
355                                         <entry>548</entry>
356                                         <entry>Alias</entry>
357                                         <entry>No</entry>
358                                 </row>
359                                 <row>
360                                         <entry>Builtin System Operators</entry>
361                                         <entry>549</entry>
362                                         <entry>Alias</entry>
363                                         <entry>No</entry>
364                                 </row>
365                                 <row>
366                                         <entry>Builtin Print Operators</entry>
367                                         <entry>550</entry>
368                                         <entry>Alias</entry>
369                                         <entry>No</entry>
370                                 </row>
371                                 <row>
372                                         <entry>Builtin Backup Operators</entry>
373                                         <entry>551</entry>
374                                         <entry>Alias</entry>
375                                         <entry>No</entry>
376                                 </row>
377                                 <row>
378                                         <entry>Builtin Replicator</entry>
379                                         <entry>552</entry>
380                                         <entry>Alias</entry>
381                                         <entry>No</entry>
382                                 </row>
383                                 <row>
384                                         <entry>Builtin RAS Servers</entry>
385                                         <entry>553</entry>
386                                         <entry>Alias</entry>
387                                         <entry>No</entry>
388                                 </row>
389                         </tbody>
390                 </tgroup>
391         </table>
392         </para>
394         </sect2>
396         <sect2>
397         <title>Example Configuration</title>
399                 <para>
400                 You can list the various groups in the mapping database by executing
401                 <command>net groupmap list</command>. Here is an example:
402                 </para>
404 <indexterm><primary>net</primary><secondary>groupmap</secondary></indexterm>
406                 <para>
407 <screen>
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
412 </screen>
413                 </para>
415                 <para>
416                 For complete details on <command>net groupmap</command>, refer to the net(8) man page.
417                 </para>
419         </sect2>
421 </sect1>
423 <sect1>
424 <title>Configuration Scripts</title>
426         <para>
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). 
429         </para>
431         <sect2>
432         <title>Sample &smb.conf; Add Group Script</title>
434                 <para>
435                 A script to create complying group names for use by the Samba group interfaces
436                 is provided in <link linkend="smbgrpadd.sh"></link>.
437                 </para>
439 <indexterm><primary>smbgrpadd.sh</primary></indexterm>
440                 <para>
441 <example id="smbgrpadd.sh">
442         <title>smbgrpadd.sh</title>
443 <programlisting>
445 #!/bin/bash
447 # Add the group using normal system groupadd tool.
448 groupadd smbtmpgrp00
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.
457 echo $thegid
458 exit 0
459 </programlisting>
460 </example>
461 </para>
463                 <para>
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>
468 <member>...</member>
469 <smbconfoption><name>add group script</name><value>/path_to_tool/smbgrpadd.sh %g</value></smbconfoption>
470 <member>...</member>
471 </smbconfexample>
472                 </para>
474         </sect2>
475         
476         <sect2>
477         <title>Script to Configure Group Mapping</title>
479         <para>
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>.
485         </para>
487 <para>
488 <indexterm><primary>initGroups.sh</primary></indexterm>
489 <example id="set-group-map">
490         <title>Script to Set Group Mapping</title>
491 <programlisting>
492 #!/bin/bash
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
498 groupadd Orks
499 groupadd Elves
500 groupadd Gnomes
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
505 </programlisting>
506 </example>
507 </para>
509         <para>
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.
513         </para>
515         </sect2>
517 </sect1>
519 <sect1>
520 <title>Common Errors</title>
522 <para>
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.
526 </para>
528         <sect2>
529         <title>Adding Groups Fails</title>
531                 <para>
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
534                 the &smb.conf; file.
535                 </para>
537                 <para>
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.
540                 </para>
542                 <para>
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.
549                 </para>
551         </sect2>
553         <sect2>
554         <title>Adding MS Windows Groups to MS Windows Groups Fails</title>
556         <indexterm><primary>groups</primary><secondary>nested</secondary></indexterm>
558                 <para>
559                 Samba-3 does not support nested groups from the MS Windows control environment.
560                 </para>
562         </sect2>
564         <sect2>
565         <title>Adding <emphasis>Domain Users</emphasis> to the <emphasis>Power Users</emphasis> Group</title>
567                 <para><quote>
568                 What must I do to add Domain Users to the Power Users group?
569                 </quote></para>
571 <indexterm><primary>Domain Users group</primary></indexterm>
573                 <para>
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:
578                 </para>
580                 <procedure>
581                         <step><para>
582                         Click <guimenu>Start -> Control Panel -> Users and Passwords</guimenu>.
583                         </para></step>
585                         <step><para>
586                         Click the <guimenuitem>Advanced</guimenuitem> tab.
587                         </para></step>
589                         <step><para>
590                         Click the <guibutton>Advanced</guibutton> button.
591                         </para></step>
593                         <step><para>
594                         Click <constant>Groups</constant>.
595                         </para></step>
597                         <step><para>
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.
600                         </para></step>
602                         <step><para>
603                         Click the <guibutton>Add</guibutton> button.
604                         </para></step>
606                         <step><para>
607                         Select the domain from which the <constant>Domain Users</constant> group is to be added.
608                         </para></step>
610                         <step><para>
611                         Double click the <constant>Domain Users</constant> group.
612                         </para></step>
614                         <step><para>
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>.
619                         </para></step>
620                 </procedure>
621         </sect2>
623 </sect1>
625 </chapter>