This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[ira/wip.git] / docs / docbook / projdoc / winbind.xml
1 <chapter id="winbind">
2
3 <chapterinfo>
4         <authorgroup>
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.tridge;
13         &author.jht;
14         <author>
15                 <firstname>Naag</firstname><surname>Mummaneni</surname>
16                 <affiliation>
17                         <address><email>getnag@rediffmail.com</email></address>
18                 </affiliation>
19         </author>
20         &author.jelmer;
21         </authorgroup>
22         <pubdate>27 June 2002</pubdate>
23 </chapterinfo>
24
25 <title>Unified Logons between Windows NT and UNIX using Winbind</title>
26
27 <sect1>
28         <title>Abstract</title>
29
30         <para>Integration of UNIX and Microsoft Windows NT through 
31         a unified logon has been considered a "holy grail" in heterogeneous 
32         computing environments for a long time. We present 
33         <emphasis>winbind</emphasis>, a component of the Samba suite 
34         of programs as a solution to the unified logon problem. Winbind 
35         uses a UNIX implementation 
36         of Microsoft RPC calls, Pluggable Authentication Modules, and the Name 
37         Service Switch to allow Windows NT domain users to appear and operate 
38         as UNIX users on a UNIX machine. This paper describes the winbind 
39         system, explaining the functionality it provides, how it is configured, 
40         and how it works internally.</para>
41 </sect1>
42
43
44 <sect1>
45         <title>Introduction</title>
46         
47         <para>It is well known that UNIX and Microsoft Windows NT have 
48         different models for representing user and group information and 
49         use different technologies for implementing them. This fact has 
50         made it difficult to integrate the two systems in a satisfactory 
51         manner.</para>
52         
53         <para>One common solution in use today has been to create 
54         identically named user accounts on both the UNIX and Windows systems 
55         and use the Samba suite of programs to provide file and print services 
56         between the two. This solution is far from perfect however, as 
57         adding and deleting users on both sets of machines becomes a chore 
58         and two sets of passwords are required both of which
59         can lead to synchronization problems between the UNIX and Windows 
60         systems and confusion for users.</para>
61         
62         <para>We divide the unified logon problem for UNIX machines into 
63         three smaller problems:</para>
64         
65         <itemizedlist>
66                 <listitem><para>Obtaining Windows NT user and group information
67                 </para></listitem>
68                 
69                 <listitem><para>Authenticating Windows NT users
70                 </para></listitem>
71                 
72                 <listitem><para>Password changing for Windows NT users
73                 </para></listitem>
74         </itemizedlist>
75
76
77         <para>Ideally, a prospective solution to the unified logon problem 
78         would satisfy all the above components without duplication of 
79         information on the UNIX machines and without creating additional 
80         tasks for the system administrator when maintaining users and 
81         groups on either system. The winbind system provides a simple 
82         and elegant solution to all three components of the unified logon 
83         problem.</para>
84 </sect1>
85
86
87 <sect1>
88         <title>What Winbind Provides</title>
89
90         <para>Winbind unifies UNIX and Windows NT account management by 
91         allowing a UNIX box to become a full member of a NT domain. Once 
92         this is done the UNIX box will see NT users and groups as if 
93         they were native UNIX users and groups, allowing the NT domain 
94         to be used in much the same manner that NIS+ is used within 
95         UNIX-only environments.</para>
96         
97         <para>The end result is that whenever any 
98         program on the UNIX machine asks the operating system to lookup 
99         a user or group name, the query will be resolved by asking the 
100         NT domain controller for the specified domain to do the lookup.
101         Because Winbind hooks into the operating system at a low level 
102         (via the NSS name resolution modules in the C library) this 
103         redirection to the NT domain controller is completely 
104         transparent.</para>
105         
106         <para>Users on the UNIX machine can then use NT user and group 
107         names as they would use "native" UNIX names. They can chown files 
108         so that they are owned by NT domain users or even login to the 
109         UNIX machine and run a UNIX X-Window session as a domain user.</para>
110         
111         <para>The only obvious indication that Winbind is being used is 
112         that user and group names take the form DOMAIN\user and 
113         DOMAIN\group. This is necessary as it allows Winbind to determine 
114         that redirection to a domain controller is wanted for a particular 
115         lookup and which trusted domain is being referenced.</para>
116         
117         <para>Additionally, Winbind provides an authentication service 
118         that hooks into the Pluggable Authentication Modules (PAM) system 
119         to provide authentication via a NT domain to any PAM enabled 
120         applications. This capability solves the problem of synchronizing 
121         passwords between systems since all passwords are stored in a single 
122         location (on the domain controller).</para>
123         
124         <sect2>
125                 <title>Target Uses</title>
126                 
127                 <para>Winbind is targeted at organizations that have an 
128                 existing NT based domain infrastructure into which they wish 
129                 to put UNIX workstations or servers. Winbind will allow these 
130                 organizations to deploy UNIX workstations without having to 
131                 maintain a separate account infrastructure. This greatly 
132                 simplifies the administrative overhead of deploying UNIX 
133                 workstations into a NT based organization.</para>
134                 
135                 <para>Another interesting way in which we expect Winbind to 
136                 be used is as a central part of UNIX based appliances. Appliances 
137                 that provide file and print services to Microsoft based networks 
138                 will be able to use Winbind to provide seamless integration of 
139                 the appliance into the domain.</para>
140         </sect2>
141 </sect1>
142
143
144
145 <sect1>
146         <title>How Winbind Works</title>
147         
148         <para>The winbind system is designed around a client/server 
149         architecture. A long running <command>winbindd</command> daemon 
150         listens on a UNIX domain socket waiting for requests
151         to arrive. These requests are generated by the NSS and PAM 
152         clients and processed sequentially.</para>
153         
154         <para>The technologies used to implement winbind are described 
155         in detail below.</para>
156         
157         <sect2>
158                 <title>Microsoft Remote Procedure Calls</title>
159                 
160                 <para>Over the last few years, efforts have been underway 
161                 by various Samba Team members to decode various aspects of 
162                 the Microsoft Remote Procedure Call (MSRPC) system. This 
163                 system is used for most network related operations between 
164                 Windows NT machines including remote management, user authentication
165                 and print spooling. Although initially this work was done 
166                 to aid the implementation of Primary Domain Controller (PDC) 
167                 functionality in Samba, it has also yielded a body of code which 
168                 can be used for other purposes.</para>
169                 
170                 <para>Winbind uses various MSRPC calls to enumerate domain users 
171                 and groups and to obtain detailed information about individual 
172                 users or groups. Other MSRPC calls can be used to authenticate 
173                 NT domain users and to change user passwords. By directly querying 
174                 a Windows PDC for user and group information, winbind maps the 
175                 NT account information onto UNIX user and group names.</para>
176         </sect2>
177         
178         <sect2>
179                 <title>Microsoft Active Directory Services</title>
180
181                 <para>
182                 Since late 2001, Samba has gained the ability to
183                 interact with Microsoft Windows 2000 using its 'Native
184                 Mode' protocols, rather than the NT4 RPC services.
185                 Using LDAP and Kerberos, a domain member running
186                 winbind can enumerate users and groups in exactly the
187                 same way as a Win2k client would, and in so doing
188                 provide a much more efficient and
189                 effective winbind implementation.  
190                 </para>
191         </sect2>
192         
193         <sect2>
194                 <title>Name Service Switch</title>
195                 
196                 <para>The Name Service Switch, or NSS, is a feature that is 
197                 present in many UNIX operating systems. It allows system 
198                 information such as hostnames, mail aliases and user information 
199                 to be resolved from different sources. For example, a standalone 
200                 UNIX workstation may resolve system information from a series of 
201                 flat files stored on the local filesystem. A networked workstation 
202                 may first attempt to resolve system information from local files, 
203                 and then consult a NIS database for user information or a DNS server 
204                 for hostname information.</para>
205                 
206                 <para>The NSS application programming interface allows winbind 
207                 to present itself as a source of system information when 
208                 resolving UNIX usernames and groups.  Winbind uses this interface, 
209                 and information obtained from a Windows NT server using MSRPC 
210                 calls to provide a new source of account enumeration.  Using standard 
211                 UNIX library calls, one can enumerate the users and groups on
212                 a UNIX machine running winbind and see all users and groups in 
213                 a NT domain plus any trusted domain as though they were local 
214                 users and groups.</para>
215                 
216                 <para>The primary control file for NSS is 
217                 <filename>/etc/nsswitch.conf</filename>. 
218                 When a UNIX application makes a request to do a lookup 
219                 the C library looks in <filename>/etc/nsswitch.conf</filename> 
220                 for a line which matches the service type being requested, for 
221                 example the "passwd" service type is used when user or group names 
222                 are looked up. This     config line species which implementations 
223                 of that service should be tried and in what order. If the passwd 
224                 config line is:</para>
225
226                 <para><command>passwd: files example</command></para>
227
228                 <para>then the C library will first load a module called 
229                 <filename>/lib/libnss_files.so</filename> followed by
230                 the module <filename>/lib/libnss_example.so</filename>. The 
231                 C library will dynamically load each of these modules in turn 
232                 and call resolver functions within the modules to try to resolve 
233                 the request. Once the request is resolved the C library returns the
234                 result to the application.</para>
235                 
236                 <para>This NSS interface provides a very easy way for Winbind 
237                 to hook into the operating system. All that needs to be done 
238                 is to put <filename>libnss_winbind.so</filename> in <filename>/lib/</filename> 
239                 then add "winbind" into <filename>/etc/nsswitch.conf</filename> at 
240                 the appropriate place. The C library will then call Winbind to 
241                 resolve user and group names.</para>
242         </sect2>
243         
244         <sect2>
245                 <title>Pluggable Authentication Modules</title>
246                 
247                 <para>Pluggable Authentication Modules, also known as PAM, 
248                 is a system for abstracting authentication and authorization 
249                 technologies. With a PAM module it is possible to specify different 
250                 authentication methods for different system applications without 
251                 having to recompile these applications. PAM is also useful
252                 for implementing a particular policy for authorization. For example, 
253                 a system administrator may only allow console logins from users 
254                 stored in the local password file but only allow users resolved from 
255                 a NIS database to log in over the network.</para>
256                 
257                 <para>Winbind uses the authentication management and password 
258                 management PAM interface to integrate Windows NT users into a 
259                 UNIX system. This allows Windows NT users to log in to a UNIX 
260                 machine and be authenticated against a suitable Primary Domain 
261                 Controller. These users can also change their passwords and have 
262                 this change take effect directly on the Primary Domain Controller.
263                 </para>
264                 
265                 <para>PAM is configured by providing control files in the directory 
266                 <filename>/etc/pam.d/</filename> for each of the services that 
267                 require authentication. When an authentication request is made 
268                 by an application the PAM code in the C library looks up this
269                 control file to determine what modules to load to do the 
270                 authentication check and in what order. This interface makes adding 
271                 a new authentication service for Winbind very easy, all that needs 
272                 to be done is that the <filename>pam_winbind.so</filename> module 
273                 is copied to <filename>/lib/security/</filename> and the PAM 
274                 control files for relevant services are updated to allow 
275                 authentication via winbind. See the PAM documentation
276                 for more details.</para>
277         </sect2>
278         
279         
280         <sect2>
281                 <title>User and Group ID Allocation</title>
282                 
283                 <para>When a user or group is created under Windows NT 
284                 is it allocated a numerical relative identifier (RID). This is 
285                 slightly different to UNIX which has a range of numbers that are 
286                 used to identify users, and the same range in which to identify 
287                 groups. It is winbind's job to convert RIDs to UNIX id numbers and
288                 vice versa.  When winbind is configured it is given part of the UNIX 
289                 user id space and a part of the UNIX group id space in which to 
290                 store Windows NT users and groups. If a Windows NT user is 
291                 resolved for the first time, it is allocated the next UNIX id from 
292                 the range. The same process applies for Windows NT groups. Over 
293                 time, winbind will have mapped all Windows NT users and groups
294                 to UNIX user ids and group ids.</para>
295
296                 <para>The results of this mapping are stored persistently in 
297                 an ID mapping database held in a tdb database). This ensures that 
298                 RIDs are mapped to UNIX IDs in a consistent way.</para>
299         </sect2>
300         
301         
302         <sect2>
303                 <title>Result Caching</title>
304
305                 <para>An active system can generate a lot of user and group 
306                 name lookups. To reduce the network cost of these lookups winbind 
307                 uses a caching scheme based on the SAM sequence number supplied 
308                 by NT domain controllers.  User or group information returned 
309                 by a PDC is cached by winbind along with a sequence number also 
310                 returned by the PDC. This sequence number is incremented by 
311                 Windows NT whenever any user or group information is modified. If 
312                 a cached entry has expired, the sequence number is requested from 
313                 the PDC and compared against the sequence number of the cached entry. 
314                 If the sequence numbers do not match, then the cached information 
315                 is discarded and up to date information is requested directly 
316                 from the PDC.</para>
317         </sect2>
318 </sect1>
319
320
321 <sect1>
322         <title>Installation and Configuration</title>
323         
324 <para>
325 Many thanks to John Trostel <ulink 
326 url="mailto:jtrostel@snapserver.com">jtrostel@snapserver.com</ulink>
327 for providing the HOWTO for this section.
328 </para>
329
330 <para>
331 This HOWTO describes how to get winbind services up and running 
332 to control access and authenticate users on your Linux box using 
333 the winbind services which come with SAMBA 3.0.
334 </para>
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 3.0 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</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 on Linux and Solaris</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>And, in the case of Sun solaris:</para>
493 <para>
494 <prompt>root#</prompt> <userinput>ln -s /usr/lib/libnss_winbind.so /usr/lib/libnss_winbind.so.1</userinput>
495 <prompt>root#</prompt> <userinput>ln -s /usr/lib/libnss_winbind.so /usr/lib/nss_winbind.so.1</userinput>
496 <prompt>root#</prompt> <userinput>ln -s /usr/lib/libnss_winbind.so /usr/lib/nss_winbind.so.2</userinput>
497 </para>
498
499 <para>
500 Now, as root you need to edit <filename>/etc/nsswitch.conf</filename> to 
501 allow user and group entries to be visible from the <command>winbindd</command> 
502 daemon.  My <filename>/etc/nsswitch.conf</filename> file look like 
503 this after editing:
504 </para>
505
506 <para><programlisting>
507         passwd:     files winbind
508         shadow:     files 
509         group:      files winbind
510 </programlisting></para>
511
512 <para>  
513 The libraries needed by the winbind daemon will be automatically 
514 entered into the <command>ldconfig</command> cache the next time 
515 your system reboots, but it 
516 is faster (and you don't need to reboot) if you do it manually:
517 </para>
518
519 <para>
520 <prompt>root#</prompt> <command>/sbin/ldconfig -v | grep winbind</command>
521 </para>
522
523 <para>
524 This makes <filename>libnss_winbind</filename> available to winbindd 
525 and echos back a check to you.
526 </para>
527
528 </sect3>
529
530 <sect3>
531 <title>NSS Winbind on AIX</title>
532
533 <para>(This section is only for those running AIX)</para>
534
535 <para>
536 The winbind AIX identification module gets built as libnss_winbind.so in the
537 nsswitch directory of the samba source.  This file can be copied to
538 /usr/lib/security, and the AIX naming convention would indicate that it
539 should be named WINBIND.  A stanza like the following:
540 </para>
541
542 <para><programlisting>
543 WINBIND:
544         program = /usr/lib/security/WINBIND
545         options = authonly
546 </programlisting></para>
547
548 <para>can then be added to
549 <filename>/usr/lib/security/methods.cfg</filename>.  This module only
550 supports identification, but there have been success reports using the
551 standard winbind pam module for authentication.  Use caution configuring
552 loadable authentication modules as it is possible to make it impossible
553 to logon to the system.  More information about the AIX authentication
554 module API can be found at &quot;Kernel Extensions and Device Support
555 Programming Concepts for AIX&quot;: <ulink
556 url="http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/kernextc/sec_load_mod.htm">
557 Chapter 18. Loadable Authentication Module Programming Interface</ulink> 
558 and more information on administering the  modules at <ulink
559 url="http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixbman/baseadmn/iandaadmin.htm">
560 &quot;System Management Guide: Operating System and Devices&quot;</ulink>.
561 </para>
562 </sect3>
563
564 <sect3>
565 <title>Configure smb.conf</title>
566
567 <para>
568 Several parameters are needed in the smb.conf file to control 
569 the behavior of <command>winbindd</command>. Configure 
570 <filename>smb.conf</filename> These are described in more detail in 
571 the <citerefentry><refentrytitle>winbindd</refentrytitle>
572 <manvolnum>8</manvolnum></citerefentry> man page.  My 
573 <filename>smb.conf</filename> file was modified to
574 include the following entries in the [global] section:
575 </para>
576
577 <para><programlisting>
578 [global]
579      &lt;...&gt;
580      # separate domain and username with '+', like DOMAIN+username
581      <ulink url="winbindd.8.html#WINBINDSEPARATOR">winbind separator</ulink> = +
582      # use uids from 10000 to 20000 for domain users
583      <ulink url="winbindd.8.html#WINBINDUID">winbind uid</ulink> = 10000-20000
584      # use gids from 10000 to 20000 for domain groups
585      <ulink url="winbindd.8.html#WINBINDGID">winbind gid</ulink> = 10000-20000
586      # allow enumeration of winbind users and groups
587      <ulink url="winbindd.8.html#WINBINDENUMUSERS">winbind enum users</ulink> = yes
588      <ulink url="winbindd.8.html#WINBINDENUMGROUP">winbind enum groups</ulink> = yes
589      # give winbind users a real shell (only needed if they have telnet access)
590      <ulink url="winbindd.8.html#TEMPLATEHOMEDIR">template homedir</ulink> = /home/winnt/%D/%U
591      <ulink url="winbindd.8.html#TEMPLATESHELL">template shell</ulink> = /bin/bash
592 </programlisting></para>
593
594 </sect3>
595
596
597 <sect3>
598 <title>Join the SAMBA server to the PDC domain</title>
599
600 <para>
601 Enter the following command to make the SAMBA server join the 
602 PDC domain, where <replaceable>DOMAIN</replaceable> is the name of 
603 your Windows domain and <replaceable>Administrator</replaceable> is 
604 a domain user who has administrative privileges in the domain.
605 </para>
606         
607
608 <para>
609 <prompt>root#</prompt> <command>/usr/local/samba/bin/net join -S PDC -U Administrator</command>
610 </para>
611
612
613 <para>
614 The proper response to the command should be: "Joined the domain 
615 <replaceable>DOMAIN</replaceable>" where <replaceable>DOMAIN</replaceable> 
616 is your DOMAIN name.
617 </para>
618
619 </sect3>
620
621
622 <sect3>
623 <title>Start up the winbindd daemon and test it!</title>
624
625 <para>
626 Eventually, you will want to modify your smb startup script to 
627 automatically invoke the winbindd daemon when the other parts of 
628 SAMBA start, but it is possible to test out just the winbind
629 portion first.  To start up winbind services, enter the following 
630 command as root:
631 </para>
632         
633 <para>
634 <prompt>root#</prompt> <command>/usr/local/samba/bin/winbindd</command>
635 </para>
636
637 <para>
638 Winbindd can now also run in 'dual daemon mode'. This will make it 
639 run as 2 processes. The first will answer all requests from the cache,
640 thus making responses to clients faster. The other will
641 update the cache for the query that the first has just responded.
642 Advantage of this is that responses stay accurate and are faster. 
643 You can enable dual daemon mode by adding '-B' to the commandline:
644 </para>
645
646 <para>
647 <prompt>root#</prompt> <command>/usr/local/samba/bin/winbindd -B</command>
648 </para>
649
650 <para>
651 I'm always paranoid and like to make sure the daemon 
652 is really running...
653 </para>
654
655 <para>
656 <prompt>root#</prompt> <command>ps -ae | grep winbindd</command>
657 </para>
658 <para>
659 This command should produce output like this, if the daemon is running
660 </para>
661 <para>
662 3025 ?        00:00:00 winbindd
663 </para>
664
665 <para>
666 Now... for the real test, try to get some information about the 
667 users on your PDC
668 </para>
669
670 <para>
671 <prompt>root#</prompt> <command>/usr/local/samba/bin/wbinfo -u</command>
672 </para>
673
674 <para>  
675 This should echo back a list of users on your Windows users on 
676 your PDC.  For example, I get the following response:
677 </para>
678
679 <para><programlisting>
680         CEO+Administrator
681         CEO+burdell
682         CEO+Guest
683         CEO+jt-ad
684         CEO+krbtgt
685         CEO+TsInternetUser
686 </programlisting></para>
687
688 <para>
689 Obviously, I have named my domain 'CEO' and my <parameter>winbind
690 separator</parameter> is '+'.
691 </para>
692
693 <para>
694 You can do the same sort of thing to get group information from 
695 the PDC:
696 </para>
697
698 <para><programlisting>
699 <prompt>root#</prompt> <command>/usr/local/samba/bin/wbinfo -g</command>
700         CEO+Domain Admins
701         CEO+Domain Users
702         CEO+Domain Guests
703         CEO+Domain Computers
704         CEO+Domain Controllers
705         CEO+Cert Publishers
706         CEO+Schema Admins
707         CEO+Enterprise Admins
708         CEO+Group Policy Creator Owners
709 </programlisting></para>
710
711 <para>
712 The function 'getent' can now be used to get unified 
713 lists of both local and PDC users and groups.
714 Try the following command:
715 </para>
716
717 <para>
718 <prompt>root#</prompt> <command>getent passwd</command>
719 </para>
720         
721 <para>
722 You should get a list that looks like your <filename>/etc/passwd</filename> 
723 list followed by the domain users with their new uids, gids, home 
724 directories and default shells.
725 </para>
726
727 <para>
728 The same thing can be done for groups with the command
729 </para>
730
731 <para>
732 <prompt>root#</prompt> <command>getent group</command>
733 </para>
734
735 </sect3>
736
737
738 <sect3>
739 <title>Fix the init.d startup scripts</title>
740
741 <sect4>
742 <title>Linux</title>
743
744 <para>
745 The <command>winbindd</command> daemon needs to start up after the 
746 <command>smbd</command> and <command>nmbd</command> daemons are running.  
747 To accomplish this task, you need to modify the startup scripts of your system.
748 They are located at <filename>/etc/init.d/smb</filename> in RedHat and 
749 <filename>/etc/init.d/samba</filename> in Debian.
750 script to add commands to invoke this daemon in the proper sequence.  My 
751 startup script starts up <command>smbd</command>, 
752 <command>nmbd</command>, and <command>winbindd</command> from the 
753 <filename>/usr/local/samba/bin</filename> directory directly.  The 'start' 
754 function in the script looks like this:
755 </para>
756
757 <para><programlisting>
758 start() {
759         KIND="SMB"
760         echo -n $"Starting $KIND services: "
761         daemon /usr/local/samba/bin/smbd $SMBDOPTIONS
762         RETVAL=$?
763         echo
764         KIND="NMB"
765         echo -n $"Starting $KIND services: "
766         daemon /usr/local/samba/bin/nmbd $NMBDOPTIONS
767         RETVAL2=$?
768         echo
769         KIND="Winbind"
770         echo -n $"Starting $KIND services: "
771         daemon /usr/local/samba/bin/winbindd
772         RETVAL3=$?
773         echo
774         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 -a $RETVAL3 -eq 0 ] &amp;&amp; \
775                 touch /var/lock/subsys/smb || RETVAL=1
776         return $RETVAL
777 }
778 </programlisting></para>
779
780 <para>If you would like to run winbindd in dual daemon mode, replace 
781 the line 
782 <programlisting>
783         daemon /usr/local/samba/bin/winbindd
784 </programlisting>
785
786 in the example above with:
787
788 <programlisting>
789         daemon /usr/local/samba/bin/winbindd -B
790 </programlisting>.
791 </para>
792
793 <para>
794 The 'stop' function has a corresponding entry to shut down the 
795 services and looks like this:
796 </para>
797
798 <para><programlisting>
799 stop() {
800         KIND="SMB"
801         echo -n $"Shutting down $KIND services: "
802         killproc smbd
803         RETVAL=$?
804         echo
805         KIND="NMB"
806         echo -n $"Shutting down $KIND services: "
807         killproc nmbd
808         RETVAL2=$?
809         echo
810         KIND="Winbind"
811         echo -n $"Shutting down $KIND services: "
812         killproc winbindd
813         RETVAL3=$?
814         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 -a $RETVAL3 -eq 0 ] &amp;&amp; \
815                  rm -f /var/lock/subsys/smb
816         echo ""
817         return $RETVAL
818 }
819 </programlisting></para>
820 </sect4>
821
822 <sect4>
823 <title>Solaris</title>
824
825 <para>Winbind doesn't work on solaris 9, see the <link linkend="winbind-solaris9">Portability</link> chapter for details.</para>
826
827 <para>On solaris, you need to modify the 
828 <filename>/etc/init.d/samba.server</filename> startup script. It usually 
829 only starts smbd and nmbd but should now start winbindd too. If you 
830 have samba installed in <filename>/usr/local/samba/bin</filename>, 
831 the file could contains something like this:
832 </para>
833
834 <para><programlisting>
835         ##
836         ## samba.server
837         ##
838
839         if [ ! -d /usr/bin ]
840         then                    # /usr not mounted
841                 exit
842         fi
843
844         killproc() {            # kill the named process(es)
845                 pid=`/usr/bin/ps -e |
846                      /usr/bin/grep -w $1 |
847                      /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
848                 [ "$pid" != "" ] &amp;&amp; kill $pid
849         }
850          
851         # Start/stop processes required for samba server
852
853         case "$1" in
854
855         'start')
856         #
857         # Edit these lines to suit your installation (paths, workgroup, host)
858         #
859         echo Starting SMBD
860            /usr/local/samba/bin/smbd -D -s \
861                 /usr/local/samba/smb.conf
862
863         echo Starting NMBD
864            /usr/local/samba/bin/nmbd -D -l \
865                 /usr/local/samba/var/log -s /usr/local/samba/smb.conf
866
867         echo Starting Winbind Daemon
868            /usr/local/samba/bin/winbindd
869            ;;
870
871         'stop')
872            killproc nmbd
873            killproc smbd
874            killproc winbindd
875            ;;
876
877         *)
878            echo "Usage: /etc/init.d/samba.server { start | stop }"
879            ;;
880         esac
881 </programlisting></para>
882
883 <para>
884 Again, if you would like to run samba in dual daemon mode, replace 
885 <programlisting>
886         /usr/local/samba/bin/winbindd
887 </programlisting>
888
889 in the script above with:
890
891 <programlisting>
892         /usr/local/samba/bin/winbindd -B
893 </programlisting>
894 </para>
895
896 </sect4>
897
898 <sect4>
899 <title>Restarting</title>
900 <para>
901 If you restart the <command>smbd</command>, <command>nmbd</command>, 
902 and <command>winbindd</command> daemons at this point, you
903 should be able to connect to the samba server as a domain member just as
904 if you were a local user.
905 </para>
906 </sect4>
907 </sect3>
908
909 <sect3>
910 <title>Configure Winbind and PAM</title>
911
912 <para>
913 If you have made it this far, you know that winbindd and samba are working
914 together.  If you want to use winbind to provide authentication for other 
915 services, keep reading.  The pam configuration files need to be altered in
916 this step.  (Did you remember to make backups of your original 
917 <filename>/etc/pam.d</filename> files? If not, do it now.)
918 </para>
919
920 <para>
921 You will need a pam module to use winbindd with these other services.  This 
922 module will be compiled in the <filename>../source/nsswitch</filename> directory
923 by invoking the command
924 </para>
925
926 <para>
927 <prompt>root#</prompt> <command>make nsswitch/pam_winbind.so</command>
928 </para>
929
930 <para>
931 from the <filename>../source</filename> directory.  The
932 <filename>pam_winbind.so</filename> file should be copied to the location of
933 your other pam security modules.  On my RedHat system, this was the
934 <filename>/lib/security</filename> directory. On Solaris, the pam security 
935 modules reside in <filename>/usr/lib/security</filename>.
936 </para>
937
938 <para>
939 <prompt>root#</prompt> <command>cp ../samba/source/nsswitch/pam_winbind.so /lib/security</command>
940 </para>
941
942 <sect4>
943 <title>Linux/FreeBSD-specific PAM configuration</title>
944
945 <para>
946 The <filename>/etc/pam.d/samba</filename> file does not need to be changed. I 
947 just left this fileas it was:
948 </para>
949
950
951 <para><programlisting>
952         auth    required        /lib/security/pam_stack.so service=system-auth
953         account required        /lib/security/pam_stack.so service=system-auth
954 </programlisting></para>
955
956 <para>
957 The other services that I modified to allow the use of winbind 
958 as an authentication service were the normal login on the console (or a terminal 
959 session), telnet logins, and ftp service.  In order to enable these 
960 services, you may first need to change the entries in 
961 <filename>/etc/xinetd.d</filename> (or <filename>/etc/inetd.conf</filename>).  
962 RedHat 7.1 uses the new xinetd.d structure, in this case you need 
963 to change the lines in <filename>/etc/xinetd.d/telnet</filename> 
964 and <filename>/etc/xinetd.d/wu-ftp</filename> from 
965 </para>
966
967 <para><programlisting>
968         enable = no
969 </programlisting></para>
970
971 <para>
972 to
973 </para>
974
975 <para><programlisting>
976         enable = yes
977 </programlisting></para>
978
979 <para>  
980 For ftp services to work properly, you will also need to either 
981 have individual directories for the domain users already present on 
982 the server, or change the home directory template to a general
983 directory for all domain users.  These can be easily set using 
984 the <filename>smb.conf</filename> global entry 
985 <command>template homedir</command>.
986 </para>
987
988 <para>
989 The <filename>/etc/pam.d/ftp</filename> file can be changed 
990 to allow winbind ftp access in a manner similar to the
991 samba file.  My <filename>/etc/pam.d/ftp</filename> file was 
992 changed to look like this:
993 </para>
994
995 <para><programlisting>
996         auth       required     /lib/security/pam_listfile.so item=user sense=deny \
997                  file=/etc/ftpusers onerr=succeed
998         auth       sufficient   /lib/security/pam_winbind.so
999         auth       required     /lib/security/pam_stack.so service=system-auth
1000         auth       required     /lib/security/pam_shells.so
1001         account    sufficient   /lib/security/pam_winbind.so
1002         account    required     /lib/security/pam_stack.so service=system-auth
1003         session    required     /lib/security/pam_stack.so service=system-auth
1004 </programlisting></para>
1005
1006 <para>
1007 The <filename>/etc/pam.d/login</filename> file can be changed nearly the 
1008 same way.  It now looks like this:
1009 </para>
1010
1011 <para><programlisting>
1012         auth       required     /lib/security/pam_securetty.so
1013         auth       sufficient   /lib/security/pam_winbind.so
1014         auth       sufficient   /lib/security/pam_unix.so use_first_pass
1015         auth       required     /lib/security/pam_stack.so service=system-auth
1016         auth       required     /lib/security/pam_nologin.so
1017         account    sufficient   /lib/security/pam_winbind.so
1018         account    required     /lib/security/pam_stack.so service=system-auth
1019         password   required     /lib/security/pam_stack.so service=system-auth
1020         session    required     /lib/security/pam_stack.so service=system-auth
1021         session    optional     /lib/security/pam_console.so
1022 </programlisting></para>
1023
1024 <para>
1025 In this case, I added the <command>auth sufficient /lib/security/pam_winbind.so</command> 
1026 lines as before, but also added the <command>required pam_securetty.so</command> 
1027 above it, to disallow root logins over the network.  I also added a 
1028 <command>sufficient /lib/security/pam_unix.so use_first_pass</command>
1029 line after the <command>winbind.so</command> line to get rid of annoying 
1030 double prompts for passwords.
1031 </para>
1032
1033 </sect4>
1034
1035 <sect4>
1036 <title>Solaris-specific configuration</title>
1037
1038 <para>
1039 The /etc/pam.conf needs to be changed. I changed this file so that my Domain
1040 users can logon both locally as well as telnet.The following are the changes
1041 that I made.You can customize the pam.conf file as per your requirements,but
1042 be sure of those changes because in the worst case it will leave your system
1043 nearly impossible to boot.
1044 </para>
1045
1046 <para><programlisting>
1047         #
1048         #ident  "@(#)pam.conf   1.14    99/09/16 SMI"
1049         #
1050         # Copyright (c) 1996-1999, Sun Microsystems, Inc.
1051         # All Rights Reserved.
1052         #
1053         # PAM configuration
1054         #
1055         # Authentication management
1056         #
1057         login   auth required   /usr/lib/security/pam_winbind.so
1058         login   auth required   /usr/lib/security/$ISA/pam_unix.so.1 try_first_pass 
1059         login   auth required   /usr/lib/security/$ISA/pam_dial_auth.so.1 try_first_pass 
1060         #
1061         rlogin  auth sufficient /usr/lib/security/pam_winbind.so
1062         rlogin  auth sufficient /usr/lib/security/$ISA/pam_rhosts_auth.so.1
1063         rlogin  auth required   /usr/lib/security/$ISA/pam_unix.so.1 try_first_pass
1064         #
1065         dtlogin auth sufficient /usr/lib/security/pam_winbind.so
1066         dtlogin auth required   /usr/lib/security/$ISA/pam_unix.so.1 try_first_pass
1067         #
1068         rsh     auth required   /usr/lib/security/$ISA/pam_rhosts_auth.so.1
1069         other   auth sufficient /usr/lib/security/pam_winbind.so
1070         other   auth required   /usr/lib/security/$ISA/pam_unix.so.1 try_first_pass
1071         #
1072         # Account management
1073         #
1074         login   account sufficient      /usr/lib/security/pam_winbind.so
1075         login   account requisite       /usr/lib/security/$ISA/pam_roles.so.1 
1076         login   account required        /usr/lib/security/$ISA/pam_unix.so.1 
1077         #
1078         dtlogin account sufficient      /usr/lib/security/pam_winbind.so
1079         dtlogin account requisite       /usr/lib/security/$ISA/pam_roles.so.1 
1080         dtlogin account required        /usr/lib/security/$ISA/pam_unix.so.1 
1081         #
1082         other   account sufficient      /usr/lib/security/pam_winbind.so
1083         other   account requisite       /usr/lib/security/$ISA/pam_roles.so.1 
1084         other   account required        /usr/lib/security/$ISA/pam_unix.so.1 
1085         #
1086         # Session management
1087         #
1088         other   session required        /usr/lib/security/$ISA/pam_unix.so.1 
1089         #
1090         # Password management
1091         #
1092         #other   password sufficient     /usr/lib/security/pam_winbind.so
1093         other   password required       /usr/lib/security/$ISA/pam_unix.so.1 
1094         dtsession auth required /usr/lib/security/$ISA/pam_unix.so.1
1095         #
1096         # Support for Kerberos V5 authentication (uncomment to use Kerberos)
1097         #
1098         #rlogin auth optional   /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1099         #login  auth optional   /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1100         #dtlogin        auth optional   /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1101         #other  auth optional   /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1102         #dtlogin        account optional /usr/lib/security/$ISA/pam_krb5.so.1
1103         #other  account optional /usr/lib/security/$ISA/pam_krb5.so.1
1104         #other  session optional /usr/lib/security/$ISA/pam_krb5.so.1
1105         #other  password optional /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1106 </programlisting></para>
1107
1108 <para>
1109 I also added a try_first_pass line after the winbind.so line to get rid of
1110 annoying double prompts for passwords.
1111 </para>
1112
1113 <para>
1114 Now restart your Samba and try connecting through your application that you
1115 configured in the pam.conf.
1116 </para>
1117
1118 </sect4>
1119
1120 </sect3>
1121
1122 </sect2>
1123
1124 </sect1>
1125
1126 <sect1>
1127         <title>Limitations</title>
1128         
1129         <para>Winbind has a number of limitations in its current 
1130         released version that we hope to overcome in future 
1131         releases:</para>
1132
1133         <itemizedlist>
1134                 <listitem><para>Winbind is currently only available for 
1135                 the Linux, Solaris and IRIX operating systems, although ports to other operating 
1136                 systems are certainly possible. For such ports to be feasible, 
1137                 we require the C library of the target operating system to 
1138                 support the Name Service Switch and Pluggable Authentication
1139                 Modules systems. This is becoming more common as NSS and 
1140                 PAM gain        support among UNIX vendors.</para></listitem>
1141                 
1142                 <listitem><para>The mappings of Windows NT RIDs to UNIX ids 
1143                 is not made algorithmically and depends on the order in which 
1144                 unmapped users or groups are seen by winbind. It may be difficult 
1145                 to recover the mappings of rid to UNIX id mapping if the file 
1146                 containing this information is corrupted or destroyed.</para>
1147                 </listitem>
1148                 
1149                 <listitem><para>Currently the winbind PAM module does not take 
1150                 into account possible workstation and logon time restrictions 
1151                 that may be been set for Windows NT users, this is
1152                 instead up to the PDC to enforce.</para></listitem>
1153         </itemizedlist>
1154 </sect1>
1155
1156
1157 <sect1>
1158         <title>Conclusion</title>
1159
1160         <para>The winbind system, through the use of the Name Service 
1161         Switch, Pluggable Authentication Modules, and appropriate 
1162         Microsoft RPC calls have allowed us to provide seamless 
1163         integration of Microsoft Windows NT domain users on a
1164         UNIX system. The result is a great reduction in the administrative 
1165         cost of running a mixed UNIX and NT network.</para>
1166         
1167 </sect1>
1168
1169 </chapter>