trying to get HEAD building again. If you want the code
[Samba.git] / docs / docbook / projdoc / GROUP-MAPPING-HOWTO.xml
bloba13a43675b168c9ea808315f9e719b304dbae347
1 <?xml version="1.0" encoding="iso8859-1"?>
2 <chapter id="groupmapping">
3 <chapterinfo>
4         <author>
5                 <firstname>Jean François</firstname><surname>Micouleau</surname>
6         </author>
7         &author.jerry;
8         &author.jht;
9 </chapterinfo>
10 <title>Mapping MS Windows and Unix Groups</title>
12         <para>
13         Starting with Samba-3, new group mapping functionality is available to create associations
14         between Windows group SIDs and UNIX groups. The <parameter>groupmap</parameter> subcommand
15         included with the &net; tool can be used to manage these associations.
16         </para>
18         <warning>
19         <para>
20         The first immediate reason to use the group mapping on a Samba PDC, is that
21         the <parameter>domain admin group</parameter> has been removed and should no longer
22         be specified in &smb.conf;. This parameter was used to give the listed users membership
23         in the <constant>Domain Admins</constant> Windows group which gave local admin rights on their workstations
24         (in default configurations).
25         </para>
26         </warning>
28 <sect1>
29 <title>Features and Benefits</title>
31         <para>
32         Samba allows the administrator to create MS Windows NT4 / 200x group accounts and to
33         arbitrarily associate them with Unix/Linux group accounts.
34         </para>
36         <para>
37         Group accounts can be managed using the MS Windows NT4 or MS Windows 200x MMC tools
38         so long as appropriate interface scripts have been provided to &smb.conf;.
39         </para>
41         <para>
42         Administrators should be aware that where &smb.conf; group interface scripts make
43         direct calls to the Unix/Linux system tools (eg: the shadow utilities, <command>groupadd</command>,
44         <command>groupdel</command>, <command>groupmod</command>) then the resulting Unix/Linux group names will be subject
45         to any limits imposed by these tools. If the tool does NOT allow upper case characters
46         or space characters, then the creation of an MS Windows NT4 / 200x style group of
47         <parameter>Engineering Managers</parameter> will attempt to create an identically named
48         Unix/Linux group, an attempt that will of course fail!
49         </para>
51         <para>
52         There are several possible work-arounds for the operating system tools limitation. One
53         method is to use a script that generates a name for the Unix/Linux system group that
54         fits the operating system limits, and that then just passes the Unix/Linux group id (GID)
55         back to the calling Samba interface. This will provide a dynamic work-around solution.
56         </para>
58         <para>
59         Another work-around is to manually create a Unix/Linux group, then manually create the
60         MS Windows NT4 / 200x group on the Samba server and then use the <command>net groupmap</command>
61         tool to connect the two to each other.
62         </para>
64 </sect1>
66 <sect1>
67 <title>Discussion</title>
69         <para>
70         When installing <application>MS Windows NT4 / 200x</application> on a computer, the installation
71         program creates default users and groups, notably the <constant>Administrators</constant> group,
72         and gives that group privileges necessary privileges to perform essential system tasks.
73         eg: Ability to change the date and time or to kill (or close) any process running on the
74         local machine.
75         </para>
76         
77         <para>
78         The 'Administrator' user is a member of the 'Administrators' group, and thus inherits
79         'Administrators' group privileges. If a 'joe' user is created to be a member of the
80         'Administrator' group, 'joe' has exactly the same rights as 'Administrator'.
81         </para>
83         <para>
84         When an MS Windows NT4 / W200x is made a domain member, the "Domain Admins" group of the
85         PDC is added to the local 'Administrators' group of the workstation. Every member of the
86         'Domain Administrators' group inherits the rights of the local 'Administrators' group when
87         logging on the workstation.
88         </para>
90         <para>
91         The following steps describe how to make Samba PDC users members of the 'Domain Admins' group?
92         </para>
94         <orderedlist>
95                 <listitem><para>
96                 create a unix group (usually in <filename>/etc/group</filename>), let's call it domadm
97                 </para></listitem>
99                 <listitem><para>add to this group the users that must be Administrators. For example
100                 if you want joe, john and mary, your entry in <filename>/etc/group</filename> will
101                 look like:
102                 </para>
104                 <para><programlisting>
105                 domadm:x:502:joe,john,mary
106                 </programlisting>
107                 </para></listitem>
109                 <listitem><para>
110                 Map this domadm group to the "Domain Admins" group by running the command:
111                 </para>
113                 <para>
114                 <screen>
115                 &rootprompt;<userinput>net groupmap add ntgroup="Domain Admins" unixgroup=domadm</userinput>
116                 </screen>
117                 </para>
118                 
119                 <para>
120                 The quotes around "Domain Admins" are necessary due to the space in the group name.
121                 Also make sure to leave no whitespace surrounding the equal character (=).
122                 </para></listitem>
123         </orderedlist>
125         <para>
126         Now joe, john and mary are domain administrators!
127         </para>
129         <para>
130         It is possible to map any arbitrary UNIX group to any Windows NT4 / 200x group as well as
131         making any UNIX group a Windows domain group.  For example, if you wanted to include a
132         UNIX group (e.g. acct) in a ACL on a local file or printer on a domain member machine,
133         you would flag that group as a domain group by running the following on the Samba PDC:
134         </para>
136         <para>
137         <screen>
138         &rootprompt;<userinput>net groupmap add rid=1000 ntgroup="Accounting" unixgroup=acct</userinput>
139         </screen>
140         </para>
142         <para>
143         Be aware that the RID parameter is a unsigned 32 bit integer that should
144         normally start at 1000.  However, this rid must not overlap with any RID assigned
145         to a user.  Verifying this is done differently depending on on the passdb backend 
146         you are using.  Future versions of the tools may perform the verification automatically,
147         but for now the burden is on you.
148         </para>
150         <sect2>
151         <title>Example Configuration</title>
153                 <para>
154                 You can list the various groups in the mapping database by executing 
155                 <command>net groupmap list</command>.  Here is an example:
156                 </para>
158                 <para>
159                 <screen>
160                 &rootprompt; <userinput>net groupmap list</userinput>
161                 System Administrators (S-1-5-21-2547222302-1596225915-2414751004-1002) -> sysadmin
162                 Domain Admins (S-1-5-21-2547222302-1596225915-2414751004-512) -> domadmin
163                 Domain Users (S-1-5-21-2547222302-1596225915-2414751004-513) -> domuser
164                 Domain Guests (S-1-5-21-2547222302-1596225915-2414751004-514) -> domguest
165                 </screen>
166                 </para>
168                 <para>
169                 For complete details on <command>net groupmap</command>, refer to the net(8) man page.
170                 </para>
172         </sect2>
174 </sect1>
176 <sect1>
177 <title>Configuration Scripts</title>
179         <para>
180         Everyone needs tools. Some of us like to create our own, others prefer to use canned tools
181         (ie: prepared by someone else for general use). 
182         </para>
184         <sect2>
185         <title>Sample &smb.conf; add group script</title>
187                 <para>
188                 A script to great complying group names for use by the Samba group interfaces:
189                 </para>
191                 <para>
192 <example>
193         <title>smbgrpadd.sh</title>
194 <programlisting>
196 #!/bin/bash
198 # Add the group using normal system groupadd tool.
199 groupadd smbtmpgrp00
201 thegid=`cat /etc/group | grep smbtmpgrp00 | cut -d ":" -f3`
203 # Now change the name to what we want for the MS Windows networking end
204 cp /etc/group /etc/group.bak
205 cat /etc/group.bak | sed s/smbtmpgrp00/$1/g > /etc/group
207 # Now return the GID as would normally happen.
208 echo $thegid
209 exit 0
210 </programlisting>
211 </example>
212 </para>
214                 <para>
215                 The &smb.conf; entry for the above script would look like:
216                 <programlisting>
217                 add group script = /path_to_tool/smbgrpadd.sh %g
218                 </programlisting>
219                 </para>
221         </sect2>
222         
223         <sect2>
224         <title>Script to configure Group Mapping</title>
226         <para>
227         In our example we have created a Unix/Linux group called <parameter>ntadmin</parameter>.
228         Our script will create the additional groups <parameter>Engineers, Marketoids, Gnomes</parameter>:
229         </para>
231 <para>
232 <programlisting>
233 #!/bin/bash
235 net groupmap modify ntgroup="Domain Admins" unixgroup=ntadmin
236 net groupmap modify ntgroup="Domain Users" unixgroup=users
237 net groupmap modify ntgroup="Domain Guests" unixgroup=nobody
238 net groupmap modify ntgroup="Administrators" unixgroup=root
239 net groupmap modify ntgroup="Users" unixgroup=users
240 net groupmap modify ntgroup="Guests" unixgroup=nobody
241 net groupmap modify ntgroup="System Operators" unixgroup=sys
242 net groupmap modify ntgroup="Account Operators" unixgroup=root
243 net groupmap modify ntgroup="Backup Operators" unixgroup=bin
244 net groupmap modify ntgroup="Print Operators" unixgroup=lp
245 net groupmap modify ntgroup="Replicators" unixgroup=daemon
246 net groupmap modify ntgroup="Power Users" unixgroup=sys
248 #groupadd Engineers
249 #groupadd Marketoids
250 #groupadd Gnomes
252 #net groupmap add ntgroup="Engineers"  unixgroup=Engineers    type=d
253 #net groupmap add ntgroup="Marketoids" unixgroup=Marketoids   type=d
254 #net groupmap add ntgroup="Gnomes"     unixgroup=Gnomes       type=d
255 </programlisting>
256 </para>
258         <para>
259         Of course it is expected that the administrator will modify this to suit local needs.
260         For information regarding the use of the <command>net groupmap</command> tool please
261         refer to the man page.
262         </para>
264         </sect2>
266 </sect1>
268 <sect1>
269 <title>Common Errors</title>
271 <para>
272 At this time there are many little surprises for the unwary administrator. In a real sense
273 it is imperative that every step of automated control scripts must be carefully tested
274 manually before putting them into active service.
275 </para>
277         <sect2>
278         <title>Adding Groups Fails</title>
280                 <para>
281                 This is a common problem when the <command>groupadd</command> is called directly
282                 by the Samba interface script for the <parameter>add group script</parameter> in
283                 the &smb.conf; file.
284                 </para>
286                 <para>
287                 The most common cause of failure is an attempt to add an MS Windows group account
288                 that has either an upper case character and/or a space character in it.
289                 </para>
291                 <para>
292                 There are three possible work-arounds. Firstly, use only group names that comply
293                 with the limitations of the Unix/Linux <command>groupadd</command> system tool.
294                 The second involves use of the script mentioned earlier in this chapter, and the
295                 third option is to manually create a Unix/Linux group account that can substitute
296                 for the MS Windows group name, then use the procedure listed above to map that group
297                 to the MS Windows group.
298                 </para>
300         </sect2>
302         <sect2>
303         <title>Adding MS Windows Groups to MS Windows Groups Fails</title>
305                 <para>
306                 Samba-3 does NOT support nested groups from the MS Windows control environment.
307                 </para>
309         </sect2>
311 </sect1>
313 </chapter>