This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[kai/samba.git] / docs / docbook / projdoc / GROUP-MAPPING-HOWTO.xml
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>
11
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>
17
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>
27
28 <sect1>
29 <title>Features and Benefits</title>
30
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>
35
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>
40
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>
50
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>
57
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>
63
64 </sect1>
65
66 <sect1>
67 <title>Discussion</title>
68
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 to that group privileges necessary privilidges to perform essential system tasks.
73         eg: Ability to change the date and time or to kill any process (or close too) 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>
82
83         <para>
84         When an MS Windows NT4 / W200x is made a domain member, the "Domain Adminis" 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>
89
90         <para>
91         The following steps describe how to make samba PDC users members of the 'Domain Admins' group?
92         </para>
93
94         <orderedlist>
95                 <listitem><para>
96                 create a unix group (usually in <filename>/etc/group</filename>), let's call it domadm
97                 </para></listitem>
98
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>
103
104                 <para><programlisting>
105                 domadm:x:502:joe,john,mary
106                 </programlisting>
107                 </para></listitem>
108
109                 <listitem><para>
110                 Map this domadm group to the "Domain Admins" group by running the command:
111                 </para>
112
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>
124
125         <para>
126         Now joe, john and mary are domain administrators!
127         </para>
128
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>
135
136         <para>
137         <screen>
138         &rootprompt;<userinput>net groupmap add rid=1000 ntgroup="Accounting" unixgroup=acct</userinput>
139         </screen>
140         </para>
141
142         <para>
143         Be aware that the RID parmeter 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>
149
150         <sect2>
151         <title>Example Configuration</title>
152
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>
157
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>
167
168                 <para>
169                 For complete details on <command>net groupmap</command>, refer to the net(8) man page.
170                 </para>
171
172         </sect2>
173
174 </sect1>
175
176 <sect1>
177 <title>Configuration Scripts</title>
178
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>
183
184         <sect2>
185         <title>Sample &smb.conf; add group script</title>
186
187                 <para>
188                 A script to great complying group names for use by the samba group interfaces:
189                 </para>
190
191                 <para>
192 <example>
193         <title>smbgrpadd.sh</title>
194 <programlisting>
195
196 #!/bin/bash
197
198 # Add the group using normal system groupadd tool.
199 groupadd smbtmpgrp00
200
201 thegid=`cat /etc/group | grep smbtmpgrp00 | cut -d ":" -f3`
202
203 # Now change the name to what we want for the MS Windows networking end
204 cat /etc/group | sed s/smbtmpgrp00/$1/g > /etc/group
205
206 # Now return the GID as would normally happen.
207 echo $thegid
208 exit 0
209 </programlisting>
210 </example>
211 </para>
212
213                 <para>
214                 The &smb.conf; entry for the above script would look like:
215                 <programlisting>
216                 add group script = /path_to_tool/smbgrpadd.sh %g
217                 </programlisting>
218                 </para>
219
220         </sect2>
221         
222         <sect2>
223         <title>Script to configure Group Mapping</title>
224
225         <para>
226         In our example we have created a Unix/Linux group called <parameter>ntadmin</parameter>.
227         Our script will create the additional groups <parameter>Engineers, Marketoids, Gnomes</parameter>:
228         </para>
229
230 <para>
231 <programlisting>
232 #!/bin/bash
233
234 net groupmap modify ntgroup="Domain Admins" unixgroup=ntadmin
235 net groupmap modify ntgroup="Domain Users" unixgroup=users
236 net groupmap modify ntgroup="Domain Guests" unixgroup=nobody
237 net groupmap modify ntgroup="Administrators" unixgroup=root
238 net groupmap modify ntgroup="Users" unixgroup=users
239 net groupmap modify ntgroup="Guests" unixgroup=nobody
240 net groupmap modify ntgroup="System Operators" unixgroup=sys
241 net groupmap modify ntgroup="Account Operators" unixgroup=root
242 net groupmap modify ntgroup="Backup Operators" unixgroup=bin
243 net groupmap modify ntgroup="Print Operators" unixgroup=lp
244 net groupmap modify ntgroup="Replicators" unixgroup=daemon
245 net groupmap modify ntgroup="Power Users" unixgroup=sys
246
247 #groupadd Engineers
248 #groupadd Marketoids
249 #groupadd Gnomes
250
251 #net groupmap add ntgroup="Engineers"  unixgroup=Engineers    type=d
252 #net groupmap add ntgroup="Marketoids" unixgroup=Marketoids   type=d
253 #net groupmap add ntgroup="Gnomes"     unixgroup=Gnomes       type=d
254 </programlisting>
255 </para>
256
257         <para>
258         Of course it is expected that the admininstrator will modify this to suit local needs.
259         For information regarding the use of the <command>net groupmap</command> tool please
260         refer to the man page.
261         </para>
262
263         </sect2>
264
265 </sect1>
266
267 <sect1>
268 <title>Common Errors</title>
269
270 <para>
271 At this time there are many little surprises for the unwary administrator. In a real sense
272 it is imperative that every step of automated control scripts must be carefully tested
273 manually before putting them into active service.
274 </para>
275
276         <sect2>
277         <title>Adding Groups Fails</title>
278
279                 <para>
280                 This is a common problem when the <command>groupadd</command> is called directly
281                 by the samba interface script for the <parameter>add group script</parameter> in
282                 the &smb.conf; file.
283                 </para>
284
285                 <para>
286                 The most common cause of failure is an attempt to add an MS Windows group acocunt
287                 that has either an upper case character and/or a space character in it.
288                 </para>
289
290                 <para>
291                 There are three possible work-arounds. Firstly, use only group names that comply
292                 with the limitations of the Unix/Linux <command>groupadd</command> system tool.
293                 The second involves use of the script mentioned earlier in this chapter, and the
294                 third option is to manually create a Unix/Linux group account that can substitute
295                 for the MS Windows group name, then use the procedure listed above to map that group
296                 to the MS Windows group.
297                 </para>
298
299         </sect2>
300
301         <sect2>
302         <title>Adding MS Windows Groups to MS Windows Groups Fails</title>
303
304                 <para>
305                 Samba-3 does NOT support nested groups from the MS Windows control environment.
306                 </para>
307
308         </sect2>
309
310 </sect1>
311
312 </chapter>