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