merging some changes from SAMBA_2_2
[kai/samba.git] / docs / docbook / projdoc / winbind.sgml
1 <chapter id="winbind">
2
3
4 <chapterinfo>
5         <author>
6                 <firstname>Tim</firstname><surname>Potter</surname>
7                 <affiliation>
8                         <orgname>Samba Team</orgname>
9                         <address><email>tpot@linuxcare.com.au</email></address>
10                 </affiliation>
11         </author>
12         <author>
13                 <firstname>Andrew</firstname><surname>Trigdell</surname>
14                 <affiliation>
15                         <orgname>Samba Team</orgname>
16                         <address><email>tridge@linuxcare.com.au</email></address>
17                 </affiliation>
18         </author>
19         <author>
20                 <firstname>John</firstname><surname>Trostel</surname>
21                 <affiliation>
22                         <orgname>Snapserver</orgname>
23                         <address><email>jtrostel@snapserver.com</email></address>
24                 </affiliation>
25         </author>
26         
27                 
28         <pubdate>16 Oct 2000</pubdate>
29 </chapterinfo>
30
31 <title>Unified Logons between Windows NT and UNIX using Winbind</title>
32
33 <sect1>
34         <title>Abstract</title>
35
36         <para>Integration of UNIX and Microsoft Windows NT through 
37         a unified logon has been considered a "holy grail" in heterogeneous 
38         computing environments for a long time. We present 
39         <emphasis>winbind</emphasis>, a component of the Samba suite 
40         of programs as a solution to the unified logon problem. Winbind 
41         uses a UNIX implementation 
42         of Microsoft RPC calls, Pluggable Authentication Modules, and the Name 
43         Service Switch to allow Windows NT domain users to appear and operate 
44         as UNIX users on a UNIX machine. This paper describes the winbind 
45         system, explaining the functionality it provides, how it is configured, 
46         and how it works internally.</para>
47 </sect1>
48
49
50 <sect1>
51         <title>Introduction</title>
52         
53         <para>It is well known that UNIX and Microsoft Windows NT have 
54         different models for representing user and group information and 
55         use different technologies for implementing them. This fact has 
56         made it difficult to integrate the two systems in a satisfactory 
57         manner.</para>
58         
59         <para>One common solution in use today has been to create 
60         identically named user accounts on both the UNIX and Windows systems 
61         and use the Samba suite of programs to provide file and print services 
62         between the two. This solution is far from perfect however, as 
63         adding and deleting users on both sets of machines becomes a chore 
64         and two sets of passwords are required both of which
65         can lead to synchronization problems between the UNIX and Windows 
66         systems and confusion for users.</para>
67         
68         <para>We divide the unified logon problem for UNIX machines into 
69         three smaller problems:</para>
70         
71         <itemizedlist>
72                 <listitem><para>Obtaining Windows NT user and group information
73                 </para></listitem>
74                 
75                 <listitem><para>Authenticating Windows NT users
76                 </para></listitem>
77                 
78                 <listitem><para>Password changing for Windows NT users
79                 </para></listitem>
80         </itemizedlist>
81
82
83         <para>Ideally, a prospective solution to the unified logon problem 
84         would satisfy all the above components without duplication of 
85         information on the UNIX machines and without creating additional 
86         tasks for the system administrator when maintaining users and 
87         groups on either system. The winbind system provides a simple 
88         and elegant solution to all three components of the unified logon 
89         problem.</para>
90 </sect1>
91
92
93 <sect1>
94         <title>What Winbind Provides</title>
95
96         <para>Winbind unifies UNIX and Windows NT account management by 
97         allowing a UNIX box to become a full member of a NT domain. Once 
98         this is done the UNIX box will see NT users and groups as if 
99         they were native UNIX users and groups, allowing the NT domain 
100         to be used in much the same manner that NIS+ is used within 
101         UNIX-only environments.</para>
102         
103         <para>The end result is that whenever any 
104         program on the UNIX machine asks the operating system to lookup 
105         a user or group name, the query will be resolved by asking the 
106         NT domain controller for the specified domain to do the lookup.
107         Because Winbind hooks into the operating system at a low level 
108         (via the NSS name resolution modules in the C library) this 
109         redirection to the NT domain controller is completely 
110         transparent.</para>
111         
112         <para>Users on the UNIX machine can then use NT user and group 
113         names as they would use "native" UNIX names. They can chown files 
114         so that they are owned by NT domain users or even login to the 
115         UNIX machine and run a UNIX X-Window session as a domain user.</para>
116         
117         <para>The only obvious indication that Winbind is being used is 
118         that user and group names take the form DOMAIN\user and 
119         DOMAIN\group. This is necessary as it allows Winbind to determine 
120         that redirection to a domain controller is wanted for a particular 
121         lookup and which trusted domain is being referenced.</para>
122         
123         <para>Additionally, Winbind provides an authentication service 
124         that hooks into the Pluggable Authentication Modules (PAM) system 
125         to provide authentication via a NT domain to any PAM enabled 
126         applications. This capability solves the problem of synchronizing 
127         passwords between systems since all passwords are stored in a single 
128         location (on the domain controller).</para>
129         
130         <sect2>
131                 <title>Target Uses</title>
132                 
133                 <para>Winbind is targeted at organizations that have an 
134                 existing NT based domain infrastructure into which they wish 
135                 to put UNIX workstations or servers. Winbind will allow these 
136                 organizations to deploy UNIX workstations without having to 
137                 maintain a separate account infrastructure. This greatly 
138                 simplifies the administrative overhead of deploying UNIX 
139                 workstations into a NT based organization.</para>
140                 
141                 <para>Another interesting way in which we expect Winbind to 
142                 be used is as a central part of UNIX based appliances. Appliances 
143                 that provide file and print services to Microsoft based networks 
144                 will be able to use Winbind to provide seamless integration of 
145                 the appliance into the domain.</para>
146         </sect2>
147 </sect1>
148
149
150
151 <sect1>
152         <title>How Winbind Works</title>
153         
154         <para>The winbind system is designed around a client/server 
155         architecture. A long running <command>winbindd</command> daemon 
156         listens on a UNIX domain socket waiting for requests
157         to arrive. These requests are generated by the NSS and PAM 
158         clients and processed sequentially.</para>
159         
160         <para>The technologies used to implement winbind are described 
161         in detail below.</para>
162         
163         <sect2>
164                 <title>Microsoft Remote Procedure Calls</title>
165                 
166                 <para>Over the last two years, efforts have been underway 
167                 by various Samba Team members to decode various aspects of 
168                 the Microsoft Remote Procedure Call (MSRPC) system. This 
169                 system is used for most network related operations between 
170                 Windows NT machines including remote management, user authentication
171                 and print spooling. Although initially this work was done 
172                 to aid the implementation of Primary Domain Controller (PDC) 
173                 functionality in Samba, it has also yielded a body of code which 
174                 can be used for other purposes.</para>
175                 
176                 <para>Winbind uses various MSRPC calls to enumerate domain users 
177                 and groups and to obtain detailed information about individual 
178                 users or groups. Other MSRPC calls can be used to authenticate 
179                 NT domain users and to change user passwords. By directly querying 
180                 a Windows PDC for user and group information, winbind maps the 
181                 NT account information onto UNIX user and group names.</para>
182         </sect2>
183         
184         <sect2>
185                 <title>Name Service Switch</title>
186                 
187                 <para>The Name Service Switch, or NSS, is a feature that is 
188                 present in many UNIX operating systems. It allows system 
189                 information such as hostnames, mail aliases and user information 
190                 to be resolved from different sources. For example, a standalone 
191                 UNIX workstation may resolve system information from a series of 
192                 flat files stored on the local filesystem. A networked workstation 
193                 may first attempt to resolve system information from local files, 
194                 and then consult a NIS database for user information or a DNS server 
195                 for hostname information.</para>
196                 
197                 <para>The NSS application programming interface allows winbind 
198                 to present itself as a source of system information when 
199                 resolving UNIX usernames and groups.  Winbind uses this interface, 
200                 and information obtained from a Windows NT server using MSRPC 
201                 calls to provide a new source of account enumeration.  Using standard 
202                 UNIX library calls, one can enumerate the users and groups on
203                 a UNIX machine running winbind and see all users and groups in 
204                 a NT domain plus any trusted domain as though they were local 
205                 users and groups.</para>
206                 
207                 <para>The primary control file for NSS is 
208                 <filename>/etc/nsswitch.conf</filename>. 
209                 When a UNIX application makes a request to do a lookup 
210                 the C library looks in <filename>/etc/nsswitch.conf</filename> 
211                 for a line which matches the service type being requested, for 
212                 example the "passwd" service type is used when user or group names 
213                 are looked up. This     config line species which implementations 
214                 of that service should be tried and in what order. If the passwd 
215                 config line is:</para>
216
217                 <para><command>passwd: files example</command></para>
218
219                 <para>then the C library will first load a module called 
220                 <filename>/lib/libnss_files.so</filename> followed by
221                 the module <filename>/lib/libnss_example.so</filename>. The 
222                 C library will dynamically load each of these modules in turn 
223                 and call resolver functions within the modules to try to resolve 
224                 the request. Once the request is resolved the C library returns the
225                 result to the application.</para>
226                 
227                 <para>This NSS interface provides a very easy way for Winbind 
228                 to hook into the operating system. All that needs to be done 
229                 is to put <filename>libnss_winbind.so</filename> in <filename>/lib/</filename> 
230                 then add "winbind" into <filename>/etc/nsswitch.conf</filename> at 
231                 the appropriate place. The C library will then call Winbind to 
232                 resolve user and group names.</para>
233         </sect2>
234         
235         <sect2>
236                 <title>Pluggable Authentication Modules</title>
237                 
238                 <para>Pluggable Authentication Modules, also known as PAM, 
239                 is a system for abstracting authentication and authorization 
240                 technologies. With a PAM module it is possible to specify different 
241                 authentication methods for different system applications without 
242                 having to recompile these applications. PAM is also useful
243                 for implementing a particular policy for authorization. For example, 
244                 a system administrator may only allow console logins from users 
245                 stored in the local password file but only allow users resolved from 
246                 a NIS database to log in over the network.</para>
247                 
248                 <para>Winbind uses the authentication management and password 
249                 management PAM interface to integrate Windows NT users into a 
250                 UNIX system. This allows Windows NT users to log in to a UNIX 
251                 machine and be authenticated against a suitable Primary Domain 
252                 Controller. These users can also change their passwords and have 
253                 this change take effect directly on the Primary Domain Controller.
254                 </para>
255                 
256                 <para>PAM is configured by providing control files in the directory 
257                 <filename>/etc/pam.d/</filename> for each of the services that 
258                 require authentication. When an authentication request is made 
259                 by an application the PAM code in the C library looks up this
260                 control file to determine what modules to load to do the 
261                 authentication check and in what order. This interface makes adding 
262                 a new authentication service for Winbind very easy, all that needs 
263                 to be done is that the <filename>pam_winbind.so</filename> module 
264                 is copied to <filename>/lib/security/</filename> and the PAM 
265                 control files for relevant services are updated to allow 
266                 authentication via winbind. See the PAM documentation
267                 for more details.</para>
268         </sect2>
269         
270         
271         <sect2>
272                 <title>User and Group ID Allocation</title>
273                 
274                 <para>When a user or group is created under Windows NT 
275                 is it allocated a numerical relative identifier (RID). This is 
276                 slightly different to UNIX which has a range of numbers that are 
277                 used to identify users, and the same range in which to identify 
278                 groups. It is winbind's job to convert RIDs to UNIX id numbers and
279                 vice versa.  When winbind is configured it is given part of the UNIX 
280                 user id space and a part of the UNIX group id space in which to 
281                 store Windows NT users and groups. If a Windows NT user is 
282                 resolved for the first time, it is allocated the next UNIX id from 
283                 the range. The same process applies for Windows NT groups. Over 
284                 time, winbind will have mapped all Windows NT users and groups
285                 to UNIX user ids and group ids.</para>
286
287                 <para>The results of this mapping are stored persistently in 
288                 an ID mapping database held in a tdb database). This ensures that 
289                 RIDs are mapped to UNIX IDs in a consistent way.</para>
290         </sect2>
291         
292         
293         <sect2>
294                 <title>Result Caching</title>
295
296                 <para>An active system can generate a lot of user and group 
297                 name lookups. To reduce the network cost of these lookups winbind 
298                 uses a caching scheme based on the SAM sequence number supplied 
299                 by NT domain controllers.  User or group information returned 
300                 by a PDC is cached by winbind along with a sequence number also 
301                 returned by the PDC. This sequence number is incremented by 
302                 Windows NT whenever any user or group information is modified. If 
303                 a cached entry has expired, the sequence number is requested from 
304                 the PDC and compared against the sequence number of the cached entry. 
305                 If the sequence numbers do not match, then the cached information 
306                 is discarded and up to date information is requested directly 
307                 from the PDC.</para>
308         </sect2>
309 </sect1>
310
311
312 <sect1>
313         <title>Installation and Configuration</title>
314         
315 <para>
316 Many thanks to John Trostel <ulink 
317 url="mailto:jtrostel@snapserver.com">jtrostel@snapserver.com</ulink>
318 for providing the HOWTO for this section.
319 </para>
320
321 <para>
322 This HOWTO describes how to get winbind services up and running 
323 to control access and authenticate users on your Linux box using 
324 the winbind services which come with SAMBA 2.2.2.
325 </para>
326
327 <para>
328 There is also some Solaris specific information in 
329 <filename>docs/textdocs/Solaris-Winbind-HOWTO.txt</filename>.
330 Future revisions of this document will incorporate that
331 information.
332 </para>
333
334
335
336 <sect2>
337 <title>Introduction</title>
338
339 <para>
340 This HOWTO describes the procedures used to get winbind up and 
341 running on my RedHat 7.1 system.  Winbind is capable of providing access 
342 and authentication control for Windows Domain users through an NT 
343 or Win2K PDC for 'regular' services, such as telnet a nd ftp, as
344 well for SAMBA services.
345 </para>
346
347 <para>
348 This HOWTO has been written from a 'RedHat-centric' perspective, so if 
349 you are using another distribution, you may have to modify the instructions 
350 somewhat to fit the way your distribution works.
351 </para>
352
353
354 <itemizedlist>
355 <listitem>
356         <para>
357         <emphasis>Why should I to this?</emphasis>
358         </para>
359         
360         <para>This allows the SAMBA administrator to rely on the 
361         authentication mechanisms on the NT/Win2K PDC for the authentication 
362         of domain members.  NT/Win2K users no longer need to have separate 
363         accounts on the SAMBA server.
364         </para>
365 </listitem>
366
367 <listitem>
368         <para>
369         <emphasis>Who should be reading this document?</emphasis>
370         </para>
371         
372         <para>
373         This HOWTO is designed for system administrators.  If you are 
374         implementing SAMBA on a file server and wish to (fairly easily) 
375         integrate existing NT/Win2K users from your PDC onto the
376         SAMBA server, this HOWTO is for you.  That said, I am no NT or PAM 
377         expert, so you may find a better or easier way to accomplish 
378         these tasks.
379         </para>
380 </listitem>
381 </itemizedlist>
382 </sect2>
383
384
385 <sect2>
386 <title>Requirements</title>
387
388 <para>
389 If you have a samba configuration file that you are currently 
390 using... <emphasis>BACK IT UP!</emphasis>  If your system already uses PAM, 
391 <emphasis>back up the <filename>/etc/pam.d</filename> directory 
392 contents!</emphasis> If you haven't already made a boot disk, 
393 <emphasis>MAKE ONE NOW!</emphasis>
394 </para>
395
396 <para>
397 Messing with the pam configuration files can make it nearly impossible 
398 to log in to yourmachine. That's why you want to be able to boot back 
399 into your machine in single user mode and restore your 
400 <filename>/etc/pam.d</filename> back to the original state they were in if 
401 you get frustrated with the way things are going.  ;-)
402 </para>
403
404 <para>
405 The latest version of SAMBA (version 2.2.2 as of this writing), now 
406 includes a functioning winbindd daemon.  Please refer to the 
407 <ulink url="http://samba.org/">main SAMBA web page</ulink> or, 
408 better yet, your closest SAMBA mirror site for instructions on 
409 downloading the source code.
410 </para>
411
412 <para>
413 To allow Domain users the ability to access SAMBA shares and 
414 files, as well as potentially other services provided by your 
415 SAMBA machine, PAM (pluggable authentication modules) must
416 be setup properly on your machine.  In order to compile the 
417 winbind modules, you should have at least the pam libraries resident 
418 on your system.  For recent RedHat systems (7.1, for instance), that 
419 means <filename>pam-0.74-22</filename>.  For best results, it is helpful to also
420 install the development packages in <filename>pam-devel-0.74-22</filename>.
421 </para>
422
423 </sect2>
424
425
426 <sect2>
427 <title>Testing Things Out</title>
428
429 <para>
430 Before starting, it is probably best to kill off all the SAMBA 
431 related daemons running on your server.  Kill off all <command>smbd</command>, 
432 <command>nmbd</command>, and <command>winbindd</command> processes that may 
433 be running.  To use PAM, you will want to make sure that you have the 
434 standard PAM package (for RedHat) which supplies the <filename>/etc/pam.d</filename> 
435 directory structure, including the pam modules are used by pam-aware 
436 services, several pam libraries, and the <filename>/usr/doc</filename> 
437 and <filename>/usr/man</filename> entries for pam.  Winbind built better 
438 in SAMBA if the pam-devel package was also installed.  This package includes 
439 the header files needed to compile pam-aware applications. For instance, 
440 my RedHat system has both <filename>pam-0.74-22</filename> and
441 <filename>pam-devel-0.74-22</filename> RPMs installed.
442 </para>
443
444 <sect3>
445 <title>Configure and compile SAMBA</title>
446
447 <para>
448 The configuration and compilation of SAMBA is pretty straightforward.
449 The first three steps may not be necessary depending upon
450 whether or not you have previously built the Samba binaries.
451 </para>
452
453 <para><programlisting>
454 <prompt>root#</prompt> <command>autoconf</command>
455 <prompt>root#</prompt> <command>make clean</command>
456 <prompt>root#</prompt> <command>rm config.cache</command>
457 <prompt>root#</prompt> <command>./configure --with-winbind</command>
458 <prompt>root#</prompt> <command>make</command>
459 <prompt>root#</prompt> <command>make install</command>
460 </programlisting></para>
461
462
463 <para>
464 This will, by default, install SAMBA in <filename>/usr/local/samba</filename>.
465 See the main SAMBA documentation if you want to install SAMBA somewhere else.
466 It will also build the winbindd executable and libraries. 
467 </para>
468
469 </sect3>
470
471 <sect3>
472 <title>Configure <filename>nsswitch.conf</filename> and the 
473 winbind libraries</title>
474
475 <para>
476 The libraries needed to run the <command>winbindd</command> daemon 
477 through nsswitch need to be copied to their proper locations, so
478 </para>
479
480 <para>
481 <prompt>root#</prompt> <command>cp ../samba/source/nsswitch/libnss_winbind.so /lib</command>
482 </para>
483
484 <para>
485 I also found it necessary to make the following symbolic link:
486 </para>
487
488 <para>
489 <prompt>root#</prompt> <command>ln -s /lib/libnss_winbind.so /lib/libnss_winbind.so.2</command>
490 </para>
491
492 <para>
493 Now, as root you need to edit <filename>/etc/nsswitch.conf</filename> to 
494 allow user and group entries to be visible from the <command>winbindd</command> 
495 daemon.  My <filename>/etc/nsswitch.conf</filename> file look like 
496 this after editing:
497 </para>
498
499 <para><programlisting>
500         passwd:     files winbind
501         shadow:     files 
502         group:      files winbind
503 </programlisting></para>
504
505 <para>  
506 The libraries needed by the winbind daemon will be automatically 
507 entered into the <command>ldconfig</command> cache the next time 
508 your system reboots, but it 
509 is faster (and you don't need to reboot) if you do it manually:
510 </para>
511
512 <para>
513 <prompt>root#</prompt> <command>/sbin/ldconfig -v | grep winbind</command>
514 </para>
515
516 <para>
517 This makes <filename>libnss_winbind</filename> available to winbindd 
518 and echos back a check to you.
519 </para>
520
521 </sect3>
522
523
524 <sect3>
525 <title>Configure smb.conf</title>
526
527 <para>
528 Several parameters are needed in the smb.conf file to control 
529 the behavior of <command>winbindd</command>. Configure 
530 <filename>smb.conf</filename> These are described in more detail in 
531 the <ulink url="winbindd.8.html">winbindd(8)</ulink> man page.  My 
532 <filename>smb.conf</filename> file was modified to
533 include the following entries in the [global] section:
534 </para>
535
536 <para><programlisting>
537 [global]
538      <...>
539      # separate domain and username with '+', like DOMAIN+username
540      <ulink url="winbindd.8.html#WINBINDSEPARATOR">winbind separator</ulink> = +
541      # use uids from 10000 to 20000 for domain users
542      <ulink url="winbindd.8.html#WINBINDUID">winbind uid</ulink> = 10000-20000
543      # use gids from 10000 to 20000 for domain groups
544      <ulink url="winbindd.8.html#WINBINDGID">winbind gid</ulink> = 10000-20000
545      # allow enumeration of winbind users and groups
546      <ulink url="winbindd.8.html#WINBINDENUMUSERS">winbind enum users</ulink> = yes
547      <ulink url="winbindd.8.html#WINBINDENUMGROUP">winbind enum groups</ulink> = yes
548      # give winbind users a real shell (only needed if they have telnet access)
549      <ulink url="winbindd.8.html#TEMPLATEHOMEDIR">template homedir</ulink> = /home/winnt/%D/%U
550      <ulink url="winbindd.8.html#TEMPLATESHELL">template shell</ulink> = /bin/bash
551 </programlisting></para>
552
553 </sect3>
554
555
556 <sect3>
557 <title>Join the SAMBA server to the PDC domain</title>
558
559 <para>
560 Enter the following command to make the SAMBA server join the 
561 PDC domain, where <replaceable>DOMAIN</replaceable> is the name of 
562 your Windows domain and <replaceable>Administrator</replaceable> is 
563 a domain user who has administrative privileges in the domain.
564 </para>
565         
566
567 <para>
568 <prompt>root#</prompt> <command>/usr/local/samba/bin/net rpc join -s PDC -U Administrator</command>
569 </para>
570
571
572 <para>
573 The proper response to the command should be: "Joined the domain 
574 <replaceable>DOMAIN</replaceable>" where <replaceable>DOMAIN</replaceable> 
575 is your DOMAIN name.
576 </para>
577
578 </sect3>
579
580
581 <sect3>
582 <title>Start up the winbindd daemon and test it!</title>
583
584 <para>
585 Eventually, you will want to modify your smb startup script to 
586 automatically invoke the winbindd daemon when the other parts of 
587 SAMBA start, but it is possible to test out just the winbind
588 portion first.  To start up winbind services, enter the following 
589 command as root:
590 </para>
591         
592 <para>
593 <prompt>root#</prompt> <command>/usr/local/samba/bin/winbindd</command>
594 </para>
595
596 <para>
597 I'm always paranoid and like to make sure the daemon 
598 is really running...
599 </para>
600
601 <para>
602 <prompt>root#</prompt> <command>ps -ae | grep winbindd</command>
603 </para>
604 <para>
605 This command should produce output like this, if the daemon is running
606 </para>
607 <para>
608 3025 ?        00:00:00 winbindd
609 </para>
610
611 <para>
612 Now... for the real test, try to get some information about the 
613 users on your PDC
614 </para>
615
616 <para>
617 <prompt>root#</prompt> <command>/usr/local/samba/bin/wbinfo -u</command>
618 </para>
619
620 <para>  
621 This should echo back a list of users on your Windows users on 
622 your PDC.  For example, I get the following response:
623 </para>
624
625 <para><programlisting>
626 CEO+Administrator
627 CEO+burdell
628 CEO+Guest
629 CEO+jt-ad
630 CEO+krbtgt
631 CEO+TsInternetUser
632 </programlisting></para>
633
634 <para>
635 Obviously, I have named my domain 'CEO' and my <parameter>winbind
636 separator</parameter> is '+'.
637 </para>
638
639 <para>
640 You can do the same sort of thing to get group information from 
641 the PDC:
642 </para>
643
644 <para><programlisting>
645 <prompt>root#</prompt> <command>/usr/local/samba/bin/wbinfo -g</command>
646 CEO+Domain Admins
647 CEO+Domain Users
648 CEO+Domain Guests
649 CEO+Domain Computers
650 CEO+Domain Controllers
651 CEO+Cert Publishers
652 CEO+Schema Admins
653 CEO+Enterprise Admins
654 CEO+Group Policy Creator Owners
655 </programlisting></para>
656
657 <para>
658 The function 'getent' can now be used to get unified 
659 lists of both local and PDC users and groups.
660 Try the following command:
661 </para>
662
663 <para>
664 <prompt>root#</prompt> <command>getent passwd</command>
665 </para>
666         
667 <para>
668 You should get a list that looks like your <filename>/etc/passwd</filename> 
669 list followed by the domain users with their new uids, gids, home 
670 directories and default shells.
671 </para>
672
673 <para>
674 The same thing can be done for groups with the command
675 </para>
676
677 <para>
678 <prompt>root#</prompt> <command>getent group</command>
679 </para>
680
681 </sect3>
682
683
684 <sect3>
685 <title>Fix the <filename>/etc/rc.d/init.d/smb</filename> startup files</title>
686
687 <para>
688 The <command>winbindd</command> daemon needs to start up after the 
689 <command>smbd</command> and <command>nmbd</command> daemons are running.  
690 To accomplish this task, you need to modify the <filename>/etc/init.d/smb</filename>
691 script to add commands to invoke this daemon in the proper sequence.  My 
692 <filename>/etc/init.d/smb</filename> file starts up <command>smbd</command>, 
693 <command>nmbd</command>, and <command>winbindd</command> from the 
694 <filename>/usr/local/samba/bin</filename> directory directly.  The 'start' 
695 function in the script looks like this:
696 </para>
697
698 <para><programlisting>
699 start() {
700         KIND="SMB"
701         echo -n $"Starting $KIND services: "
702         daemon /usr/local/samba/bin/smbd $SMBDOPTIONS
703         RETVAL=$?
704         echo
705         KIND="NMB"
706         echo -n $"Starting $KIND services: "
707         daemon /usr/local/samba/bin/nmbd $NMBDOPTIONS
708         RETVAL2=$?
709         echo
710         KIND="Winbind"
711         echo -n $"Starting $KIND services: "
712         daemon /usr/local/samba/bin/winbindd
713         RETVAL3=$?
714         echo
715         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 -a $RETVAL3 -eq 0 ] && touch /var/lock/subsys/smb || \
716            RETVAL=1
717         return $RETVAL
718 }
719 </programlisting></para>
720
721 <para>
722 The 'stop' function has a corresponding entry to shut down the 
723 services and look s like this:
724 </para>
725
726 <para><programlisting>
727 stop() {
728         KIND="SMB"
729         echo -n $"Shutting down $KIND services: "
730         killproc smbd
731         RETVAL=$?
732         echo
733         KIND="NMB"
734         echo -n $"Shutting down $KIND services: "
735         killproc nmbd
736         RETVAL2=$?
737         echo
738         KIND="Winbind"
739         echo -n $"Shutting down $KIND services: "
740         killproc winbindd
741         RETVAL3=$?
742         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 -a $RETVAL3 -eq 0 ] && rm -f /var/lock/subsys/smb
743         echo ""
744         return $RETVAL
745 }
746 </programlisting></para>
747
748 <para>
749 If you restart the <command>smbd</command>, <command>nmbd</command>, 
750 and <command>winbindd</command> daemons at this point, you
751 should be able to connect to the samba server as a domain member just as
752 if you were a local user.
753 </para>
754
755 </sect3>
756
757
758
759 <sect3>
760 <title>Configure Winbind and PAM</title>
761
762 <para>
763 If you have made it this far, you know that winbindd and samba are working
764 together.  If you want to use winbind to provide authentication for other 
765 services, keep reading.  The pam configuration files need to be altered in
766 this step.  (Did you remember to make backups of your original 
767 <filename>/etc/pam.d</filename> files? If not, do it now.)
768 </para>
769
770 <para>
771 You will need a pam module to use winbindd with these other services.  This 
772 module will be compiled in the <filename>../source/nsswitch</filename> directory
773 by invoking the command
774 </para>
775
776 <para>
777 <prompt>root#</prompt> <command>make nsswitch/pam_winbind.so</command>
778 </para>
779
780 <para>
781 from the <filename>../source</filename> directory.  The
782 <filename>pam_winbind.so</filename> file should be copied to the location of
783 your other pam security modules.  On my RedHat system, this was the
784 <filename>/lib/security</filename> directory.
785 </para>
786
787 <para>
788 <prompt>root#</prompt> <command>cp ../samba/source/nsswitch/pam_winbind.so /lib/security</command>
789 </para>
790
791 <para>
792 The <filename>/etc/pam.d/samba</filename> file does not need to be changed. I 
793 just left this fileas it was:
794 </para>
795
796
797 <para><programlisting>
798 auth    required        /lib/security/pam_stack.so service=system-auth
799 account required        /lib/security/pam_stack.so service=system-auth
800 </programlisting></para>
801
802 <para>
803 The other services that I modified to allow the use of winbind 
804 as an authentication service were the normal login on the console (or a terminal 
805 session), telnet logins, and ftp service.  In order to enable these 
806 services, you may first need to change the entries in 
807 <filename>/etc/xinetd.d</filename> (or <filename>/etc/inetd.conf</filename>).  
808 RedHat 7.1 uses the new xinetd.d structure, in this case you need 
809 to change the lines in <filename>/etc/xinetd.d/telnet</filename> 
810 and <filename>/etc/xinetd.d/wu-ftp</filename> from 
811 </para>
812
813 <para><programlisting>
814 enable = no
815 </programlisting></para>
816
817 <para>
818 to
819 </para>
820
821 <para><programlisting>
822 enable = yes
823 </programlisting></para>
824
825 <para>  
826 For ftp services to work properly, you will also need to either 
827 have individual directories for the domain users already present on 
828 the server, or change the home directory template to a general
829 directory for all domain users.  These can be easily set using 
830 the <filename>smb.conf</filename> global entry 
831 <command>template homedir</command>.
832 </para>
833
834 <para>
835 The <filename>/etc/pam.d/ftp</filename> file can be changed 
836 to allow winbind ftp access in a manner similar to the
837 samba file.  My <filename>/etc/pam.d/ftp</filename> file was 
838 changed to look like this:
839 </para>
840
841 <para><programlisting>
842 auth       required     /lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
843 auth       sufficient   /lib/security/pam_winbind.so
844 auth       required     /lib/security/pam_stack.so service=system-auth
845 auth       required     /lib/security/pam_shells.so
846 account    sufficient   /lib/security/pam_winbind.so
847 account    required     /lib/security/pam_stack.so service=system-auth
848 session    required     /lib/security/pam_stack.so service=system-auth
849 </programlisting></para>
850
851 <para>
852 The <filename>/etc/pam.d/login</filename> file can be changed nearly the 
853 same way.  It now looks like this:
854 </para>
855
856 <para><programlisting>
857 auth       required     /lib/security/pam_securetty.so
858 auth       sufficient   /lib/security/pam_winbind.so
859 auth       sufficient   /lib/security/pam_unix.so use_first_pass
860 auth       required     /lib/security/pam_stack.so service=system-auth
861 auth       required     /lib/security/pam_nologin.so
862 account    sufficient   /lib/security/pam_winbind.so
863 account    required     /lib/security/pam_stack.so service=system-auth
864 password   required     /lib/security/pam_stack.so service=system-auth
865 session    required     /lib/security/pam_stack.so service=system-auth
866 session    optional     /lib/security/pam_console.so
867 </programlisting></para>
868
869 <para>
870 In this case, I added the <command>auth sufficient /lib/security/pam_winbind.so</command> 
871 lines as before, but also added the <command>required pam_securetty.so</command> 
872 above it, to disallow root logins over the network.  I also added a 
873 <command>sufficient /lib/security/pam_unix.so use_first_pass</command>
874 line after the <command>winbind.so</command> line to get rid of annoying 
875 double prompts for passwords.
876 </para>
877
878
879 </sect3>
880
881 </sect2>
882
883 </sect1>
884
885 <sect1>
886         <title>Limitations</title>
887         
888         <para>Winbind has a number of limitations in its current 
889         released version that we hope to overcome in future 
890         releases:</para>
891
892         <itemizedlist>
893                 <listitem><para>Winbind is currently only available for 
894                 the Linux operating system, although ports to other operating 
895                 systems are certainly possible. For such ports to be feasible, 
896                 we require the C library of the target operating system to 
897                 support the Name Service Switch and Pluggable Authentication
898                 Modules systems. This is becoming more common as NSS and 
899                 PAM gain        support among UNIX vendors.</para></listitem>
900                 
901                 <listitem><para>The mappings of Windows NT RIDs to UNIX ids 
902                 is not made algorithmically and depends on the order in which 
903                 unmapped users or groups are seen by winbind. It may be difficult 
904                 to recover the mappings of rid to UNIX id mapping if the file 
905                 containing this information is corrupted or destroyed.</para>
906                 </listitem>
907                 
908                 <listitem><para>Currently the winbind PAM module does not take 
909                 into account possible workstation and logon time restrictions 
910                 that may be been set for Windows NT users.</para></listitem>
911         </itemizedlist>
912 </sect1>
913
914
915 <sect1>
916         <title>Conclusion</title>
917
918         <para>The winbind system, through the use of the Name Service 
919         Switch, Pluggable Authentication Modules, and appropriate 
920         Microsoft RPC calls have allowed us to provide seamless 
921         integration of Microsoft Windows NT domain users on a
922         UNIX system. The result is a great reduction in the administrative 
923         cost of running a mixed UNIX and NT network.</para>
924         
925 </sect1>
926
927 </chapter>