- Regenerate docs
[samba.git] / docs / htmldocs / groupmapping.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 12. Mapping MS Windows and Unix Groups</title><link rel="stylesheet" href="samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.60.1"><link rel="home" href="index.html" title="SAMBA Project Documentation"><link rel="up" href="optional.html" title="Part III. Advanced Configuration"><link rel="previous" href="passdb.html" title="Chapter 11. Account Information Databases"><link rel="next" href="AccessControls.html" title="Chapter 13. File, Directory and Share Access Controls"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 12. Mapping MS Windows and Unix Groups</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="passdb.html">Prev</a> </td><th width="60%" align="center">Part III. Advanced Configuration</th><td width="20%" align="right"> <a accesskey="n" href="AccessControls.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="groupmapping"></a>Chapter 12. Mapping MS Windows and Unix Groups</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Jean François</span> <span class="surname">Micouleau</span></h3></div></div><div><div class="author"><h3 class="author"><span class="firstname">Gerald</span> <span class="othername">(Jerry)</span> <span class="surname">Carter</span></h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt class="email">&lt;<a href="mailto:jerry@samba.org">jerry@samba.org</a>&gt;</tt></p></div></div></div></div><div><div class="author"><h3 class="author"><span class="firstname">John</span> <span class="othername">H.</span> <span class="surname">Terpstra</span></h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt class="email">&lt;<a href="mailto:jht@samba.org">jht@samba.org</a>&gt;</tt></p></div></div></div></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="groupmapping.html#id2921059">Features and Benefits</a></dt><dt><a href="groupmapping.html#id2921161">Discussion</a></dt><dd><dl><dt><a href="groupmapping.html#id2921352">Example Configuration</a></dt></dl></dd><dt><a href="groupmapping.html#id2921416">Configuration Scripts</a></dt><dd><dl><dt><a href="groupmapping.html#id2921430">Sample smb.conf add group script</a></dt><dt><a href="groupmapping.html#id2921498">Script to configure Group Mapping</a></dt></dl></dd><dt><a href="groupmapping.html#id2921590">Common Errors</a></dt><dd><dl><dt><a href="groupmapping.html#id2921606">Adding Groups Fails</a></dt><dt><a href="groupmapping.html#id2921666">Adding MS Windows Groups to MS Windows Groups Fails</a></dt></dl></dd></dl></div><p>
2         Starting with Samba-3, new group mapping functionality is available to create associations
3         between Windows group SIDs and UNIX groups. The <i class="parameter"><tt>groupmap</tt></i> subcommand
4         included with the <span class="application">net</span> tool can be used to manage these associations.
5         </p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>
6         The first immediate reason to use the group mapping on a Samba PDC, is that
7         the <i class="parameter"><tt>domain admin group</tt></i> has been removed and should no longer
8         be specified in <tt class="filename">smb.conf</tt>. This parameter was used to give the listed users membership
9         in the <tt class="constant">Domain Admins</tt> Windows group which gave local admin rights on their workstations
10         (in default configurations).
11         </p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2921059"></a>Features and Benefits</h2></div></div><div></div></div><p>
12         Samba allows the administrator to create MS Windows NT4 / 200x group accounts and to
13         arbitrarily associate them with Unix/Linux group accounts.
14         </p><p>
15         Group accounts can be managed using the MS Windows NT4 or MS Windows 200x MMC tools
16         so long as appropriate interface scripts have been provided to <tt class="filename">smb.conf</tt>
17         </p><p>
18         Administrators should be aware that where <tt class="filename">smb.conf</tt> group interface scripts make
19         direct calls to the Unix/Linux system tools (eg: the shadow utilities, <b class="command">groupadd</b>,
20         <b class="command">groupdel</b>, <b class="command">groupmod</b>) then the resulting Unix/Linux group names will be subject
21         to any limits imposed by these tools. If the tool does NOT allow upper case characters
22         or space characters, then the creation of an MS Windows NT4 / 200x style group of
23         <i class="parameter"><tt>Engineering Managers</tt></i> will attempt to create an identically named
24         Unix/Linux group, an attempt that will of course fail!
25         </p><p>
26         There are several possible work-arounds for the operating system tools limitation. One
27         method is to use a script that generates a name for the Unix/Linux system group that
28         fits the operating system limits, and that then just passes the Unix/Linux group id (GID)
29         back to the calling samba interface. This will provide a dynamic work-around solution.
30         </p><p>
31         Another work-around is to manually create a Unix/Linux group, then manually create the
32         MS Windows NT4 / 200x group on the Samba server and then use the <b class="command">net groupmap</b>
33         tool to connect the two to each other.
34         </p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2921161"></a>Discussion</h2></div></div><div></div></div><p>
35         When installing <span class="application">MS Windows NT4 / 200x</span> on a computer, the installation
36         program creates default users and groups. Notably the <tt class="constant">Administrators</tt> group,
37         and gives to that group privileges necessary privilidges to perform essential system tasks.
38         eg: Ability to change the date and time or to kill any process (or close too) running on the
39         local machine.
40         </p><p>
41         The 'Administrator' user is a member of the 'Administrators' group, and thus inherits
42         'Administrators' group privileges. If a 'joe' user is created to be a member of the
43         'Administrator' group, 'joe' has exactly the same rights as 'Administrator'.
44         </p><p>
45         When an MS Windows NT4 / W200x is made a domain member, the &quot;Domain Adminis&quot; group of the
46         PDC is added to the local 'Administrators' group of the workstation. Every member of the
47         'Domain Administrators' group inherits the rights of the local 'Administrators' group when
48         logging on the workstation.
49         </p><p>
50         The following steps describe how to make samba PDC users members of the 'Domain Admins' group?
51         </p><div class="orderedlist"><ol type="1"><li><p>
52                 create a unix group (usually in <tt class="filename">/etc/group</tt>), let's call it domadm
53                 </p></li><li><p>add to this group the users that must be Administrators. For example
54                 if you want joe,john and mary, your entry in <tt class="filename">/etc/group</tt> will
55                 look like:
56                 </p><pre class="programlisting">
57                 domadm:x:502:joe,john,mary
58                 </pre><p>
59                 </p></li><li><p>
60                 Map this domadm group to the &quot;Domain Admins&quot; group by running the command:
61                 </p><p>
62                 </p><pre class="screen">
63                 <tt class="prompt">root# </tt><b class="userinput"><tt>net groupmap add ntgroup=&quot;Domain Admins&quot; unixgroup=domadm</tt></b>
64                 </pre><p>
65                 </p><p>
66                 The quotes around &quot;Domain Admins&quot; are necessary due to the space in the group name.
67                 Also make sure to leave no whitespace surrounding the equal character (=).
68                 </p></li></ol></div><p>
69         Now joe, john and mary are domain administrators!
70         </p><p>
71         It is possible to map any arbitrary UNIX group to any Windows NT4 / 200x group as well as
72         making any UNIX group a Windows domain group.  For example, if you wanted to include a
73         UNIX group (e.g. acct) in a ACL on a local file or printer on a domain member machine,
74         you would flag that group as a domain group by running the following on the Samba PDC:
75         </p><p>
76         </p><pre class="screen">
77         <tt class="prompt">root# </tt><b class="userinput"><tt>net groupmap add rid=1000 ntgroup=&quot;Accounting&quot; unixgroup=acct</tt></b>
78         </pre><p>
79         </p><p>
80         Be aware that the RID parmeter is a unsigned 32 bit integer that should
81         normally start at 1000.  However, this rid must not overlap with any RID assigned
82         to a user.  Verifying this is done differently depending on on the passdb backend 
83         you are using.  Future versions of the tools may perform the verification automatically,
84         but for now the burden is on you.
85         </p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2921352"></a>Example Configuration</h3></div></div><div></div></div><p>
86                 You can list the various groups in the mapping database by executing 
87                 <b class="command">net groupmap list</b>.  Here is an example:
88                 </p><p>
89                 </p><pre class="screen">
90                 <tt class="prompt">root# </tt> <b class="userinput"><tt>net groupmap list</tt></b>
91                 System Administrators (S-1-5-21-2547222302-1596225915-2414751004-1002) -&gt; sysadmin
92                 Domain Admins (S-1-5-21-2547222302-1596225915-2414751004-512) -&gt; domadmin
93                 Domain Users (S-1-5-21-2547222302-1596225915-2414751004-513) -&gt; domuser
94                 Domain Guests (S-1-5-21-2547222302-1596225915-2414751004-514) -&gt; domguest
95                 </pre><p>
96                 </p><p>
97                 For complete details on <b class="command">net groupmap</b>, refer to the net(8) man page.
98                 </p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2921416"></a>Configuration Scripts</h2></div></div><div></div></div><p>
99         Everyone needs tools. Some of us like to create our own, others prefer to use canned tools
100         (ie: prepared by someone else for general use). 
101         </p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2921430"></a>Sample <tt class="filename">smb.conf</tt> add group script</h3></div></div><div></div></div><p>
102                 A script to great complying group names for use by the samba group interfaces:
103                 </p><p>
104 </p><div class="example"><a name="id2921453"></a><p class="title"><b>Example 12.1. smbgrpadd.sh</b></p><pre class="programlisting">
105
106 #!/bin/bash
107
108 # Add the group using normal system groupadd tool.
109 groupadd smbtmpgrp00
110
111 thegid=`cat /etc/group | grep smbtmpgrp00 | cut -d &quot;:&quot; -f3`
112
113 # Now change the name to what we want for the MS Windows networking end
114 cat /etc/group | sed s/smbtmpgrp00/$1/g &gt; /etc/group
115
116 # Now return the GID as would normally happen.
117 echo $thegid
118 exit 0
119 </pre></div><p>
120 </p><p>
121                 The <tt class="filename">smb.conf</tt> entry for the above script would look like:
122                 </p><pre class="programlisting">
123                 add group script = /path_to_tool/smbgrpadd.sh %g
124                 </pre><p>
125                 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2921498"></a>Script to configure Group Mapping</h3></div></div><div></div></div><p>
126         In our example we have created a Unix/Linux group called <i class="parameter"><tt>ntadmin</tt></i>.
127         Our script will create the additional groups <i class="parameter"><tt>Engineers, Marketoids, Gnomes</tt></i>:
128         </p><p>
129 </p><pre class="programlisting">
130 #!/bin/bash
131
132 net groupmap modify ntgroup=&quot;Domain Admins&quot; unixgroup=ntadmin
133 net groupmap modify ntgroup=&quot;Domain Users&quot; unixgroup=users
134 net groupmap modify ntgroup=&quot;Domain Guests&quot; unixgroup=nobody
135 net groupmap modify ntgroup=&quot;Administrators&quot; unixgroup=root
136 net groupmap modify ntgroup=&quot;Users&quot; unixgroup=users
137 net groupmap modify ntgroup=&quot;Guests&quot; unixgroup=nobody
138 net groupmap modify ntgroup=&quot;System Operators&quot; unixgroup=sys
139 net groupmap modify ntgroup=&quot;Account Operators&quot; unixgroup=root
140 net groupmap modify ntgroup=&quot;Backup Operators&quot; unixgroup=bin
141 net groupmap modify ntgroup=&quot;Print Operators&quot; unixgroup=lp
142 net groupmap modify ntgroup=&quot;Replicators&quot; unixgroup=daemon
143 net groupmap modify ntgroup=&quot;Power Users&quot; unixgroup=sys
144
145 #groupadd Engineers
146 #groupadd Marketoids
147 #groupadd Gnomes
148
149 #net groupmap add ntgroup=&quot;Engineers&quot;  unixgroup=Engineers    type=d
150 #net groupmap add ntgroup=&quot;Marketoids&quot; unixgroup=Marketoids   type=d
151 #net groupmap add ntgroup=&quot;Gnomes&quot;     unixgroup=Gnomes       type=d
152 </pre><p>
153 </p><p>
154         Of course it is expected that the admininstrator will modify this to suit local needs.
155         For information regarding the use of the <b class="command">net groupmap</b> tool please
156         refer to the man page.
157         </p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2921590"></a>Common Errors</h2></div></div><div></div></div><p>
158 At this time there are many little surprises for the unwary administrator. In a real sense
159 it is imperative that every step of automated control scripts must be carefully tested
160 manually before putting them into active service.
161 </p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2921606"></a>Adding Groups Fails</h3></div></div><div></div></div><p>
162                 This is a common problem when the <b class="command">groupadd</b> is called directly
163                 by the samba interface script for the <i class="parameter"><tt>add group script</tt></i> in
164                 the <tt class="filename">smb.conf</tt> file.
165                 </p><p>
166                 The most common cause of failure is an attempt to add an MS Windows group acocunt
167                 that has either an upper case character and/or a space character in it.
168                 </p><p>
169                 There are three possible work-arounds. Firstly, use only group names that comply
170                 with the limitations of the Unix/Linux <b class="command">groupadd</b> system tool.
171                 The second involves use of the script mentioned earlier in this chapter, and the
172                 third option is to manually create a Unix/Linux group account that can substitute
173                 for the MS Windows group name, then use the procedure listed above to map that group
174                 to the MS Windows group.
175                 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2921666"></a>Adding MS Windows Groups to MS Windows Groups Fails</h3></div></div><div></div></div><p>
176                 Samba-3 does NOT support nested groups from the MS Windows control environment.
177                 </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="passdb.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="optional.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="AccessControls.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 11. Account Information Databases </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 13. File, Directory and Share Access Controls</td></tr></table></div></body></html>