source: vendor/current/examples/scripts/idmap/README

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 5.5 KB
Line 
1idmap script option for flexible UID/GID handling
2-------------------------------------------------
3
4If you are using "idmap backend = tdb2" with winbind in Samba3, then
5you have the option of specifying an external script to perform
6uid/gid allocation. This can be useful in situations where you are
7using AD for authentication, but the AD server is not configured to
8supply uid/gid mappings via the services for unix extensions and you
9have a need to support a pre-existing system for uid/gid allocation.
10
11One common situation where this arises is where you have a mixture of
12NFS and CIFS clients, and the NFS clients are configured to use NIS
13for their id mapping. It is quite common to have an administrative
14mechanism in place to ensure that all of the NIS users have a
15corresponding AD user account, but there may be no direct mechanism to
16ensure that any unix uid/gid attributes in AD match those in NIS.
17
18In this situation it would normally not be possible to share files
19with correct ownership between the CIFS and NFS clients, as winbind
20would normally allocate its own set of UIDs from a reserved pool, and
21those uids won't match the existing ones in NIS.
22
23The idmap script option
24-----------------------
25
26To resolve this problem the idmap tdb2 module has the ability to call
27out to an external script whenever it meeds an unknown SID or UID/GID
28for the first time. It is then the job of that script to provide a
29mapping consistent with whatever external system is in place (such as
30NIS), and return the mapped result to winbind.
31
32Winbind will then persistently store the result of the mapping, so
33that the script is not invoked more than once per user/group.
34
35To setup the idmap script you need to set the following options:
36
37 idmap backend = tdb2
38 idmap script = /usr/local/bin/idmap.sh
39
40where the location and name of the script is arbitrary. It just needs
41to be executable by winbind.
42
43You then need to stop Samba, delete the key idmap cache files, and
44restart Samba. The idmap files that need to be deleted are:
45
46 - gencache.tdb
47 - winbindd_cache.tdb
48 - idmap2.tdb
49
50
51Script operation
52----------------
53
54The script will be called by winbind in one of three ways.
55
56 1) idmap.sh SIDTOID <SID>
57 2) idmap.sh IDTOSID UID <UID>
58 2) idmap.sh IDTOSID GID <GID>
59
60In the first form the script is being asked to map a windows SID (in
61the string form "S-*") to a UID or GID. In the second form the script
62is being asked to map a UID to a SID, and in the third form it is
63being asked to map a GID to a SID.
64
65SIDTOID
66-------
67
68In the first form the script is expected to output a UID or GID given
69a SID. The output format is expected to be like this:
70
71 UID:1234
72or
73 GID:1122
74
75If the SID cannot be found, then the script should output an error
76like this:
77
78 ERR:Some error message
79
80Note that it is common for the external mechanism to not know about
81windows SIDs, in which case the script may use the wbinfo command to
82ask winbind to change the SID into a username or group name. The
83"wbinfo -s" option is the one to use.
84
85
86IDTOSID UID
87-----------
88
89In this form the script is expected to turn a UID into a SID,
90returning a result like this:
91
92 SID:S-1-5-21-1110277820-2343689819-414998773-1124
93
94or an error like this:
95
96 ERR:Some error message
97
98If the external mechanism that the script wants to use cannot produce
99a SID, but can produce a username, then the script can convert the
100username to a SID using the "wbinfo -n" option.
101
102IDTOSID GID
103-----------
104
105In this form the script is expected to turn a GID into a SID,
106returning a result like this:
107
108 SID:S-1-5-21-1110277820-2343689819-414998773-1120
109
110or an error like this:
111
112 ERR:Some error message
113
114If the external mechanism that the script wants to use cannot produce
115a SID, but can produce a group name, then the script can convert the
116groupname to a SID using the "wbinfo -n" option.
117
118
119Testing the script
120------------------
121
122It is suggested that you test the script on the command line first,
123before using it in winbind. To do that first get a list of users you
124would like to test using the command "wbinfo -u". Let's assume one of
125those users is "DC01\tridge". You would then test the script as
126follows:
127
128 [root ~]# wbinfo -n 'DC01\tridge'
129 S-1-5-21-1110277820-2343689819-414998773-1124 User (1)
130
131 [root ~]# /usr/local/bin/idmap.sh SIDTOID S-1-5-21-1110277820-2343689819-414998773-1124
132 UID:1003
133
134 [root ~]# /usr/local/bin/idmap.sh IDTOSID UID 1003
135 SID:S-1-5-21-1110277820-2343689819-414998773-1124
136
137Once those steps pass, you can enable the script in winbind
138(remembering to clear the cache tdbs), and test using the id command:
139
140 [root ~]# id 'DC01\tridge'
141 uid=1003(DC01\tridge) gid=10000009(DC01\domain users)
142
143
144nsswitch.conf
145-------------
146
147When using the idmap script option you setup nsswitch.conf as usual
148for winbind, with one addition. If your external idmap mechanism
149support nsswitch then you may optionally choose to add it to
150nsswitch.conf, but you must add it after the winbind entry. So for
151example, if using NIS, you could have a nsswitch.conf entry like this:
152
153 passwd: files winbind nis
154 group: files winbind nis
155
156Adding this to nsswitch.conf is not essential, but may be useful for
157some local administration tools.
158
159Sample script
160-------------
161
162This directory contains a simple example script 'idmap_nis.sh' that
163provides idmap script support for NIS. To use it you first need to
164enable the NIS client on your Samba server, usually by configuring
165/etc/yp.conf. See the manual page for yp.conf for details.
166
167You should test the ypcat and ypmatch commands and make sure they work
168before enabling the idmap_nis.sh script.
Note: See TracBrowser for help on using the repository browser.