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