Merge over Alexanders' conversion to XML
[Samba/gebeck_regimport.git] / docs / docbook / projdoc / winbind.sgml
blob05460e1a618026418e3cc2875332541d466e21e7
1 <chapter id="winbind">
3 <chapterinfo>
4 <authorgroup>
5 <author>
6 <firstname>Tim</firstname><surname>Potter</surname>
7 <affiliation>
8 <orgname>Samba Team</orgname>
9 <address><email>tpot@linuxcare.com.au</email></address>
10 </affiliation>
11 </author>
12 &author.tridge;
13 &author.jht;
14 <author>
15 <firstname>Naag</firstname><surname>Mummaneni</surname>
16 <affiliation>
17 <address><email>getnag@rediffmail.com</email></address>
18 </affiliation>
19 </author>
20 &author.jelmer;
21 &author.jht;
22 </authorgroup>
23 <pubdate>27 June 2002</pubdate>
24 </chapterinfo>
26 <title>Unified Logons between Windows NT and UNIX using Winbind</title>
28 <sect1>
29 <title>Abstract</title>
31 <para>Integration of UNIX and Microsoft Windows NT through
32 a unified logon has been considered a "holy grail" in heterogeneous
33 computing environments for a long time. We present
34 <emphasis>winbind</emphasis>, a component of the Samba suite
35 of programs as a solution to the unified logon problem. Winbind
36 uses a UNIX implementation
37 of Microsoft RPC calls, Pluggable Authentication Modules, and the Name
38 Service Switch to allow Windows NT domain users to appear and operate
39 as UNIX users on a UNIX machine. This paper describes the winbind
40 system, explaining the functionality it provides, how it is configured,
41 and how it works internally.</para>
42 </sect1>
45 <sect1>
46 <title>Introduction</title>
48 <para>It is well known that UNIX and Microsoft Windows NT have
49 different models for representing user and group information and
50 use different technologies for implementing them. This fact has
51 made it difficult to integrate the two systems in a satisfactory
52 manner.</para>
54 <para>One common solution in use today has been to create
55 identically named user accounts on both the UNIX and Windows systems
56 and use the Samba suite of programs to provide file and print services
57 between the two. This solution is far from perfect however, as
58 adding and deleting users on both sets of machines becomes a chore
59 and two sets of passwords are required both of which
60 can lead to synchronization problems between the UNIX and Windows
61 systems and confusion for users.</para>
63 <para>We divide the unified logon problem for UNIX machines into
64 three smaller problems:</para>
66 <itemizedlist>
67 <listitem><para>Obtaining Windows NT user and group information
68 </para></listitem>
70 <listitem><para>Authenticating Windows NT users
71 </para></listitem>
73 <listitem><para>Password changing for Windows NT users
74 </para></listitem>
75 </itemizedlist>
78 <para>Ideally, a prospective solution to the unified logon problem
79 would satisfy all the above components without duplication of
80 information on the UNIX machines and without creating additional
81 tasks for the system administrator when maintaining users and
82 groups on either system. The winbind system provides a simple
83 and elegant solution to all three components of the unified logon
84 problem.</para>
85 </sect1>
88 <sect1>
89 <title>What Winbind Provides</title>
91 <para>Winbind unifies UNIX and Windows NT account management by
92 allowing a UNIX box to become a full member of a NT domain. Once
93 this is done the UNIX box will see NT users and groups as if
94 they were native UNIX users and groups, allowing the NT domain
95 to be used in much the same manner that NIS+ is used within
96 UNIX-only environments.</para>
98 <para>The end result is that whenever any
99 program on the UNIX machine asks the operating system to lookup
100 a user or group name, the query will be resolved by asking the
101 NT domain controller for the specified domain to do the lookup.
102 Because Winbind hooks into the operating system at a low level
103 (via the NSS name resolution modules in the C library) this
104 redirection to the NT domain controller is completely
105 transparent.</para>
107 <para>Users on the UNIX machine can then use NT user and group
108 names as they would use "native" UNIX names. They can chown files
109 so that they are owned by NT domain users or even login to the
110 UNIX machine and run a UNIX X-Window session as a domain user.</para>
112 <para>The only obvious indication that Winbind is being used is
113 that user and group names take the form DOMAIN\user and
114 DOMAIN\group. This is necessary as it allows Winbind to determine
115 that redirection to a domain controller is wanted for a particular
116 lookup and which trusted domain is being referenced.</para>
118 <para>Additionally, Winbind provides an authentication service
119 that hooks into the Pluggable Authentication Modules (PAM) system
120 to provide authentication via a NT domain to any PAM enabled
121 applications. This capability solves the problem of synchronizing
122 passwords between systems since all passwords are stored in a single
123 location (on the domain controller).</para>
125 <sect2>
126 <title>Target Uses</title>
128 <para>Winbind is targeted at organizations that have an
129 existing NT based domain infrastructure into which they wish
130 to put UNIX workstations or servers. Winbind will allow these
131 organizations to deploy UNIX workstations without having to
132 maintain a separate account infrastructure. This greatly
133 simplifies the administrative overhead of deploying UNIX
134 workstations into a NT based organization.</para>
136 <para>Another interesting way in which we expect Winbind to
137 be used is as a central part of UNIX based appliances. Appliances
138 that provide file and print services to Microsoft based networks
139 will be able to use Winbind to provide seamless integration of
140 the appliance into the domain.</para>
141 </sect2>
142 </sect1>
146 <sect1>
147 <title>How Winbind Works</title>
149 <para>The winbind system is designed around a client/server
150 architecture. A long running <command>winbindd</command> daemon
151 listens on a UNIX domain socket waiting for requests
152 to arrive. These requests are generated by the NSS and PAM
153 clients and processed sequentially.</para>
155 <para>The technologies used to implement winbind are described
156 in detail below.</para>
158 <sect2>
159 <title>Microsoft Remote Procedure Calls</title>
161 <para>Over the last few years, efforts have been underway
162 by various Samba Team members to decode various aspects of
163 the Microsoft Remote Procedure Call (MSRPC) system. This
164 system is used for most network related operations between
165 Windows NT machines including remote management, user authentication
166 and print spooling. Although initially this work was done
167 to aid the implementation of Primary Domain Controller (PDC)
168 functionality in Samba, it has also yielded a body of code which
169 can be used for other purposes.</para>
171 <para>Winbind uses various MSRPC calls to enumerate domain users
172 and groups and to obtain detailed information about individual
173 users or groups. Other MSRPC calls can be used to authenticate
174 NT domain users and to change user passwords. By directly querying
175 a Windows PDC for user and group information, winbind maps the
176 NT account information onto UNIX user and group names.</para>
177 </sect2>
179 <sect2>
180 <title>Microsoft Active Directory Services</title>
182 <para>
183 Since late 2001, Samba has gained the ability to
184 interact with Microsoft Windows 2000 using its 'Native
185 Mode' protocols, rather than the NT4 RPC services.
186 Using LDAP and Kerberos, a domain member running
187 winbind can enumerate users and groups in exactly the
188 same way as a Win2k client would, and in so doing
189 provide a much more efficient and
190 effective winbind implementation.
191 </para>
192 </sect2>
194 <sect2>
195 <title>Name Service Switch</title>
197 <para>The Name Service Switch, or NSS, is a feature that is
198 present in many UNIX operating systems. It allows system
199 information such as hostnames, mail aliases and user information
200 to be resolved from different sources. For example, a standalone
201 UNIX workstation may resolve system information from a series of
202 flat files stored on the local filesystem. A networked workstation
203 may first attempt to resolve system information from local files,
204 and then consult a NIS database for user information or a DNS server
205 for hostname information.</para>
207 <para>The NSS application programming interface allows winbind
208 to present itself as a source of system information when
209 resolving UNIX usernames and groups. Winbind uses this interface,
210 and information obtained from a Windows NT server using MSRPC
211 calls to provide a new source of account enumeration. Using standard
212 UNIX library calls, one can enumerate the users and groups on
213 a UNIX machine running winbind and see all users and groups in
214 a NT domain plus any trusted domain as though they were local
215 users and groups.</para>
217 <para>The primary control file for NSS is
218 <filename>/etc/nsswitch.conf</filename>.
219 When a UNIX application makes a request to do a lookup
220 the C library looks in <filename>/etc/nsswitch.conf</filename>
221 for a line which matches the service type being requested, for
222 example the "passwd" service type is used when user or group names
223 are looked up. This config line species which implementations
224 of that service should be tried and in what order. If the passwd
225 config line is:</para>
227 <para><command>passwd: files example</command></para>
229 <para>then the C library will first load a module called
230 <filename>/lib/libnss_files.so</filename> followed by
231 the module <filename>/lib/libnss_example.so</filename>. The
232 C library will dynamically load each of these modules in turn
233 and call resolver functions within the modules to try to resolve
234 the request. Once the request is resolved the C library returns the
235 result to the application.</para>
237 <para>This NSS interface provides a very easy way for Winbind
238 to hook into the operating system. All that needs to be done
239 is to put <filename>libnss_winbind.so</filename> in <filename>/lib/</filename>
240 then add "winbind" into <filename>/etc/nsswitch.conf</filename> at
241 the appropriate place. The C library will then call Winbind to
242 resolve user and group names.</para>
243 </sect2>
245 <sect2>
246 <title>Pluggable Authentication Modules</title>
248 <para>Pluggable Authentication Modules, also known as PAM,
249 is a system for abstracting authentication and authorization
250 technologies. With a PAM module it is possible to specify different
251 authentication methods for different system applications without
252 having to recompile these applications. PAM is also useful
253 for implementing a particular policy for authorization. For example,
254 a system administrator may only allow console logins from users
255 stored in the local password file but only allow users resolved from
256 a NIS database to log in over the network.</para>
258 <para>Winbind uses the authentication management and password
259 management PAM interface to integrate Windows NT users into a
260 UNIX system. This allows Windows NT users to log in to a UNIX
261 machine and be authenticated against a suitable Primary Domain
262 Controller. These users can also change their passwords and have
263 this change take effect directly on the Primary Domain Controller.
264 </para>
266 <para>PAM is configured by providing control files in the directory
267 <filename>/etc/pam.d/</filename> for each of the services that
268 require authentication. When an authentication request is made
269 by an application the PAM code in the C library looks up this
270 control file to determine what modules to load to do the
271 authentication check and in what order. This interface makes adding
272 a new authentication service for Winbind very easy, all that needs
273 to be done is that the <filename>pam_winbind.so</filename> module
274 is copied to <filename>/lib/security/</filename> and the PAM
275 control files for relevant services are updated to allow
276 authentication via winbind. See the PAM documentation
277 for more details.</para>
278 </sect2>
281 <sect2>
282 <title>User and Group ID Allocation</title>
284 <para>When a user or group is created under Windows NT
285 is it allocated a numerical relative identifier (RID). This is
286 slightly different to UNIX which has a range of numbers that are
287 used to identify users, and the same range in which to identify
288 groups. It is winbind's job to convert RIDs to UNIX id numbers and
289 vice versa. When winbind is configured it is given part of the UNIX
290 user id space and a part of the UNIX group id space in which to
291 store Windows NT users and groups. If a Windows NT user is
292 resolved for the first time, it is allocated the next UNIX id from
293 the range. The same process applies for Windows NT groups. Over
294 time, winbind will have mapped all Windows NT users and groups
295 to UNIX user ids and group ids.</para>
297 <para>The results of this mapping are stored persistently in
298 an ID mapping database held in a tdb database). This ensures that
299 RIDs are mapped to UNIX IDs in a consistent way.</para>
300 </sect2>
303 <sect2>
304 <title>Result Caching</title>
306 <para>An active system can generate a lot of user and group
307 name lookups. To reduce the network cost of these lookups winbind
308 uses a caching scheme based on the SAM sequence number supplied
309 by NT domain controllers. User or group information returned
310 by a PDC is cached by winbind along with a sequence number also
311 returned by the PDC. This sequence number is incremented by
312 Windows NT whenever any user or group information is modified. If
313 a cached entry has expired, the sequence number is requested from
314 the PDC and compared against the sequence number of the cached entry.
315 If the sequence numbers do not match, then the cached information
316 is discarded and up to date information is requested directly
317 from the PDC.</para>
318 </sect2>
319 </sect1>
322 <sect1>
323 <title>Installation and Configuration</title>
325 <para>
326 Many thanks to John Trostel <ulink
327 url="mailto:jtrostel@snapserver.com">jtrostel@snapserver.com</ulink>
328 for providing the HOWTO for this section.
329 </para>
331 <para>
332 This HOWTO describes how to get winbind services up and running
333 to control access and authenticate users on your Linux box using
334 the winbind services which come with SAMBA 2.2.2.
335 </para>
337 <sect2>
338 <title>Introduction</title>
340 <para>
341 This HOWTO describes the procedures used to get winbind up and
342 running on my RedHat 7.1 system. Winbind is capable of providing access
343 and authentication control for Windows Domain users through an NT
344 or Win2K PDC for 'regular' services, such as telnet a nd ftp, as
345 well for SAMBA services.
346 </para>
348 <para>
349 This HOWTO has been written from a 'RedHat-centric' perspective, so if
350 you are using another distribution, you may have to modify the instructions
351 somewhat to fit the way your distribution works.
352 </para>
355 <itemizedlist>
356 <listitem>
357 <para>
358 <emphasis>Why should I to this?</emphasis>
359 </para>
361 <para>This allows the SAMBA administrator to rely on the
362 authentication mechanisms on the NT/Win2K PDC for the authentication
363 of domain members. NT/Win2K users no longer need to have separate
364 accounts on the SAMBA server.
365 </para>
366 </listitem>
368 <listitem>
369 <para>
370 <emphasis>Who should be reading this document?</emphasis>
371 </para>
373 <para>
374 This HOWTO is designed for system administrators. If you are
375 implementing SAMBA on a file server and wish to (fairly easily)
376 integrate existing NT/Win2K users from your PDC onto the
377 SAMBA server, this HOWTO is for you. That said, I am no NT or PAM
378 expert, so you may find a better or easier way to accomplish
379 these tasks.
380 </para>
381 </listitem>
382 </itemizedlist>
383 </sect2>
386 <sect2>
387 <title>Requirements</title>
389 <para>
390 If you have a samba configuration file that you are currently
391 using... <emphasis>BACK IT UP!</emphasis> If your system already uses PAM,
392 <emphasis>back up the <filename>/etc/pam.d</filename> directory
393 contents!</emphasis> If you haven't already made a boot disk,
394 <emphasis>MAKE ONE NOW!</emphasis>
395 </para>
397 <para>
398 Messing with the pam configuration files can make it nearly impossible
399 to log in to yourmachine. That's why you want to be able to boot back
400 into your machine in single user mode and restore your
401 <filename>/etc/pam.d</filename> back to the original state they were in if
402 you get frustrated with the way things are going. ;-)
403 </para>
405 <para>
406 The latest version of SAMBA (version 3.0 as of this writing), now
407 includes a functioning winbindd daemon. Please refer to the
408 <ulink url="http://samba.org/">main SAMBA web page</ulink> or,
409 better yet, your closest SAMBA mirror site for instructions on
410 downloading the source code.
411 </para>
413 <para>
414 To allow Domain users the ability to access SAMBA shares and
415 files, as well as potentially other services provided by your
416 SAMBA machine, PAM (pluggable authentication modules) must
417 be setup properly on your machine. In order to compile the
418 winbind modules, you should have at least the pam libraries resident
419 on your system. For recent RedHat systems (7.1, for instance), that
420 means <filename>pam-0.74-22</filename>. For best results, it is helpful to also
421 install the development packages in <filename>pam-devel-0.74-22</filename>.
422 </para>
424 </sect2>
427 <sect2>
428 <title>Testing Things Out</title>
430 <para>
431 Before starting, it is probably best to kill off all the SAMBA
432 related daemons running on your server. Kill off all <command>smbd</command>,
433 <command>nmbd</command>, and <command>winbindd</command> processes that may
434 be running. To use PAM, you will want to make sure that you have the
435 standard PAM package (for RedHat) which supplies the <filename>/etc/pam.d</filename>
436 directory structure, including the pam modules are used by pam-aware
437 services, several pam libraries, and the <filename>/usr/doc</filename>
438 and <filename>/usr/man</filename> entries for pam. Winbind built better
439 in SAMBA if the pam-devel package was also installed. This package includes
440 the header files needed to compile pam-aware applications. For instance,
441 my RedHat system has both <filename>pam-0.74-22</filename> and
442 <filename>pam-devel-0.74-22</filename> RPMs installed.
443 </para>
445 <sect3>
446 <title>Configure and compile SAMBA</title>
448 <para>
449 The configuration and compilation of SAMBA is pretty straightforward.
450 The first three steps may not be necessary depending upon
451 whether or not you have previously built the Samba binaries.
452 </para>
454 <para><programlisting>
455 <prompt>root#</prompt> <command>autoconf</command>
456 <prompt>root#</prompt> <command>make clean</command>
457 <prompt>root#</prompt> <command>rm config.cache</command>
458 <prompt>root#</prompt> <command>./configure</command>
459 <prompt>root#</prompt> <command>make</command>
460 <prompt>root#</prompt> <command>make install</command>
461 </programlisting></para>
464 <para>
465 This will, by default, install SAMBA in <filename>/usr/local/samba</filename>.
466 See the main SAMBA documentation if you want to install SAMBA somewhere else.
467 It will also build the winbindd executable and libraries.
468 </para>
470 </sect3>
472 <sect3>
473 <title>Configure <filename>nsswitch.conf</filename> and the
474 winbind libraries</title>
476 <para>
477 The libraries needed to run the <command>winbindd</command> daemon
478 through nsswitch need to be copied to their proper locations, so
479 </para>
481 <para>
482 <prompt>root#</prompt> <command>cp ../samba/source/nsswitch/libnss_winbind.so /lib</command>
483 </para>
485 <para>
486 I also found it necessary to make the following symbolic link:
487 </para>
489 <para>
490 <prompt>root#</prompt> <command>ln -s /lib/libnss_winbind.so /lib/libnss_winbind.so.2</command>
491 </para>
493 <para>And, in the case of Sun solaris:</para>
494 <para>
495 <prompt>root#</prompt> <command>ln -s /usr/lib/libnss_winbind.so /usr/lib/libnss_winbind.so.1</command>
496 <prompt>root#</prompt> <command>ln -s /usr/lib/libnss_winbind.so /usr/lib/nss_winbind.so.1</command>
497 <prompt>root#</prompt> <command>ln -s /usr/lib/libnss_winbind.so /usr/lib/nss_winbind.so.2</command>
498 </para>
500 <para>
501 Now, as root you need to edit <filename>/etc/nsswitch.conf</filename> to
502 allow user and group entries to be visible from the <command>winbindd</command>
503 daemon. My <filename>/etc/nsswitch.conf</filename> file look like
504 this after editing:
505 </para>
507 <para><programlisting>
508 passwd: files winbind
509 shadow: files
510 group: files winbind
511 </programlisting></para>
513 <para>
514 The libraries needed by the winbind daemon will be automatically
515 entered into the <command>ldconfig</command> cache the next time
516 your system reboots, but it
517 is faster (and you don't need to reboot) if you do it manually:
518 </para>
520 <para>
521 <prompt>root#</prompt> <command>/sbin/ldconfig -v | grep winbind</command>
522 </para>
524 <para>
525 This makes <filename>libnss_winbind</filename> available to winbindd
526 and echos back a check to you.
527 </para>
529 </sect3>
532 <sect3>
533 <title>Configure smb.conf</title>
535 <para>
536 Several parameters are needed in the smb.conf file to control
537 the behavior of <command>winbindd</command>. Configure
538 <filename>smb.conf</filename> These are described in more detail in
539 the <ulink url="winbindd.8.html">winbindd(8)</ulink> man page. My
540 <filename>smb.conf</filename> file was modified to
541 include the following entries in the [global] section:
542 </para>
544 <para><programlisting>
545 [global]
546 &lt;...&gt;
547 # separate domain and username with '+', like DOMAIN+username
548 <ulink url="winbindd.8.html#WINBINDSEPARATOR">winbind separator</ulink> = +
549 # use uids from 10000 to 20000 for domain users
550 <ulink url="winbindd.8.html#WINBINDUID">winbind uid</ulink> = 10000-20000
551 # use gids from 10000 to 20000 for domain groups
552 <ulink url="winbindd.8.html#WINBINDGID">winbind gid</ulink> = 10000-20000
553 # allow enumeration of winbind users and groups
554 <ulink url="winbindd.8.html#WINBINDENUMUSERS">winbind enum users</ulink> = yes
555 <ulink url="winbindd.8.html#WINBINDENUMGROUP">winbind enum groups</ulink> = yes
556 # give winbind users a real shell (only needed if they have telnet access)
557 <ulink url="winbindd.8.html#TEMPLATEHOMEDIR">template homedir</ulink> = /home/winnt/%D/%U
558 <ulink url="winbindd.8.html#TEMPLATESHELL">template shell</ulink> = /bin/bash
559 </programlisting></para>
561 </sect3>
564 <sect3>
565 <title>Join the SAMBA server to the PDC domain</title>
567 <para>
568 Enter the following command to make the SAMBA server join the
569 PDC domain, where <replaceable>DOMAIN</replaceable> is the name of
570 your Windows domain and <replaceable>Administrator</replaceable> is
571 a domain user who has administrative privileges in the domain.
572 </para>
575 <para>
576 <prompt>root#</prompt> <command>/usr/local/samba/bin/net join -S PDC -U Administrator</command>
577 </para>
580 <para>
581 The proper response to the command should be: "Joined the domain
582 <replaceable>DOMAIN</replaceable>" where <replaceable>DOMAIN</replaceable>
583 is your DOMAIN name.
584 </para>
586 </sect3>
589 <sect3>
590 <title>Start up the winbindd daemon and test it!</title>
592 <para>
593 Eventually, you will want to modify your smb startup script to
594 automatically invoke the winbindd daemon when the other parts of
595 SAMBA start, but it is possible to test out just the winbind
596 portion first. To start up winbind services, enter the following
597 command as root:
598 </para>
600 <para>
601 <prompt>root#</prompt> <command>/usr/local/samba/bin/winbindd</command>
602 </para>
604 <para>
605 Winbindd can now also run in 'dual daemon mode'. This will make it
606 run as 2 processes. The first will answer all requests from the cache,
607 thus making responses to clients faster. The other will
608 update the cache for the query that the first has just responded.
609 Advantage of this is that responses stay accurate and are faster.
610 You can enable dual daemon mode by adding '-B' to the commandline:
611 </para>
613 <para>
614 <prompt>root#</prompt> <command>/usr/local/samba/bin/winbindd -B</command>
615 </para>
617 <para>
618 I'm always paranoid and like to make sure the daemon
619 is really running...
620 </para>
622 <para>
623 <prompt>root#</prompt> <command>ps -ae | grep winbindd</command>
624 </para>
625 <para>
626 This command should produce output like this, if the daemon is running
627 </para>
628 <para>
629 3025 ? 00:00:00 winbindd
630 </para>
632 <para>
633 Now... for the real test, try to get some information about the
634 users on your PDC
635 </para>
637 <para>
638 <prompt>root#</prompt> <command>/usr/local/samba/bin/wbinfo -u</command>
639 </para>
641 <para>
642 This should echo back a list of users on your Windows users on
643 your PDC. For example, I get the following response:
644 </para>
646 <para><programlisting>
647 CEO+Administrator
648 CEO+burdell
649 CEO+Guest
650 CEO+jt-ad
651 CEO+krbtgt
652 CEO+TsInternetUser
653 </programlisting></para>
655 <para>
656 Obviously, I have named my domain 'CEO' and my <parameter>winbind
657 separator</parameter> is '+'.
658 </para>
660 <para>
661 You can do the same sort of thing to get group information from
662 the PDC:
663 </para>
665 <para><programlisting>
666 <prompt>root#</prompt> <command>/usr/local/samba/bin/wbinfo -g</command>
667 CEO+Domain Admins
668 CEO+Domain Users
669 CEO+Domain Guests
670 CEO+Domain Computers
671 CEO+Domain Controllers
672 CEO+Cert Publishers
673 CEO+Schema Admins
674 CEO+Enterprise Admins
675 CEO+Group Policy Creator Owners
676 </programlisting></para>
678 <para>
679 The function 'getent' can now be used to get unified
680 lists of both local and PDC users and groups.
681 Try the following command:
682 </para>
684 <para>
685 <prompt>root#</prompt> <command>getent passwd</command>
686 </para>
688 <para>
689 You should get a list that looks like your <filename>/etc/passwd</filename>
690 list followed by the domain users with their new uids, gids, home
691 directories and default shells.
692 </para>
694 <para>
695 The same thing can be done for groups with the command
696 </para>
698 <para>
699 <prompt>root#</prompt> <command>getent group</command>
700 </para>
702 </sect3>
705 <sect3>
706 <title>Fix the init.d startup scripts</title>
708 <sect4>
709 <title>Linux</title>
711 <para>
712 The <command>winbindd</command> daemon needs to start up after the
713 <command>smbd</command> and <command>nmbd</command> daemons are running.
714 To accomplish this task, you need to modify the startup scripts of your system.
715 They are located at <filename>/etc/init.d/smb</filename> in RedHat and
716 <filename>/etc/init.d/samba</filename> in Debian.
717 script to add commands to invoke this daemon in the proper sequence. My
718 startup script starts up <command>smbd</command>,
719 <command>nmbd</command>, and <command>winbindd</command> from the
720 <filename>/usr/local/samba/bin</filename> directory directly. The 'start'
721 function in the script looks like this:
722 </para>
724 <para><programlisting>
725 start() {
726 KIND="SMB"
727 echo -n $"Starting $KIND services: "
728 daemon /usr/local/samba/bin/smbd $SMBDOPTIONS
729 RETVAL=$?
730 echo
731 KIND="NMB"
732 echo -n $"Starting $KIND services: "
733 daemon /usr/local/samba/bin/nmbd $NMBDOPTIONS
734 RETVAL2=$?
735 echo
736 KIND="Winbind"
737 echo -n $"Starting $KIND services: "
738 daemon /usr/local/samba/bin/winbindd
739 RETVAL3=$?
740 echo
741 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 -a $RETVAL3 -eq 0 ] &amp;&amp; \
742 touch /var/lock/subsys/smb || RETVAL=1
743 return $RETVAL
745 </programlisting></para>
747 <para>If you would like to run winbindd in dual daemon mode, replace
748 the line
749 <programlisting>
750 daemon /usr/local/samba/bin/winbindd
751 </programlisting>
753 in the example above with:
755 <programlisting>
756 daemon /usr/local/samba/bin/winbindd -B
757 </programlisting>.
758 </para>
760 <para>
761 The 'stop' function has a corresponding entry to shut down the
762 services and looks like this:
763 </para>
765 <para><programlisting>
766 stop() {
767 KIND="SMB"
768 echo -n $"Shutting down $KIND services: "
769 killproc smbd
770 RETVAL=$?
771 echo
772 KIND="NMB"
773 echo -n $"Shutting down $KIND services: "
774 killproc nmbd
775 RETVAL2=$?
776 echo
777 KIND="Winbind"
778 echo -n $"Shutting down $KIND services: "
779 killproc winbindd
780 RETVAL3=$?
781 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 -a $RETVAL3 -eq 0 ] &amp;&amp; \
782 rm -f /var/lock/subsys/smb
783 echo ""
784 return $RETVAL
786 </programlisting></para>
787 </sect4>
789 <sect4>
790 <title>Solaris</title>
792 <para>Winbind doesn't work on solaris 9, see the <link linkend="winbind-solaris9">Portability</link> chapter for details.</para>
794 <para>On solaris, you need to modify the
795 <filename>/etc/init.d/samba.server</filename> startup script. It usually
796 only starts smbd and nmbd but should now start winbindd too. If you
797 have samba installed in <filename>/usr/local/samba/bin</filename>,
798 the file could contains something like this:
799 </para>
801 <para><programlisting>
803 ## samba.server
806 if [ ! -d /usr/bin ]
807 then # /usr not mounted
808 exit
811 killproc() { # kill the named process(es)
812 pid=`/usr/bin/ps -e |
813 /usr/bin/grep -w $1 |
814 /usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
815 [ "$pid" != "" ] &amp;&amp; kill $pid
818 # Start/stop processes required for samba server
820 case "$1" in
822 'start')
824 # Edit these lines to suit your installation (paths, workgroup, host)
826 echo Starting SMBD
827 /usr/local/samba/bin/smbd -D -s \
828 /usr/local/samba/smb.conf
830 echo Starting NMBD
831 /usr/local/samba/bin/nmbd -D -l \
832 /usr/local/samba/var/log -s /usr/local/samba/smb.conf
834 echo Starting Winbind Daemon
835 /usr/local/samba/bin/winbindd
838 'stop')
839 killproc nmbd
840 killproc smbd
841 killproc winbindd
845 echo "Usage: /etc/init.d/samba.server { start | stop }"
847 esac
848 </programlisting></para>
850 <para>
851 Again, if you would like to run samba in dual daemon mode, replace
852 <programlisting>
853 /usr/local/samba/bin/winbindd
854 </programlisting>
856 in the script above with:
858 <programlisting>
859 /usr/local/samba/bin/winbindd -B
860 </programlisting>
861 </para>
863 </sect4>
865 <sect4>
866 <title>Restarting</title>
867 <para>
868 If you restart the <command>smbd</command>, <command>nmbd</command>,
869 and <command>winbindd</command> daemons at this point, you
870 should be able to connect to the samba server as a domain member just as
871 if you were a local user.
872 </para>
873 </sect4>
874 </sect3>
876 <sect3>
877 <title>Configure Winbind and PAM</title>
879 <para>
880 If you have made it this far, you know that winbindd and samba are working
881 together. If you want to use winbind to provide authentication for other
882 services, keep reading. The pam configuration files need to be altered in
883 this step. (Did you remember to make backups of your original
884 <filename>/etc/pam.d</filename> files? If not, do it now.)
885 </para>
887 <para>
888 You will need a pam module to use winbindd with these other services. This
889 module will be compiled in the <filename>../source/nsswitch</filename> directory
890 by invoking the command
891 </para>
893 <para>
894 <prompt>root#</prompt> <command>make nsswitch/pam_winbind.so</command>
895 </para>
897 <para>
898 from the <filename>../source</filename> directory. The
899 <filename>pam_winbind.so</filename> file should be copied to the location of
900 your other pam security modules. On my RedHat system, this was the
901 <filename>/lib/security</filename> directory. On Solaris, the pam security
902 modules reside in <filename>/usr/lib/security</filename>.
903 </para>
905 <para>
906 <prompt>root#</prompt> <command>cp ../samba/source/nsswitch/pam_winbind.so /lib/security</command>
907 </para>
909 <sect4>
910 <title>Linux/FreeBSD-specific PAM configuration</title>
912 <para>
913 The <filename>/etc/pam.d/samba</filename> file does not need to be changed. I
914 just left this fileas it was:
915 </para>
918 <para><programlisting>
919 auth required /lib/security/pam_stack.so service=system-auth
920 account required /lib/security/pam_stack.so service=system-auth
921 </programlisting></para>
923 <para>
924 The other services that I modified to allow the use of winbind
925 as an authentication service were the normal login on the console (or a terminal
926 session), telnet logins, and ftp service. In order to enable these
927 services, you may first need to change the entries in
928 <filename>/etc/xinetd.d</filename> (or <filename>/etc/inetd.conf</filename>).
929 RedHat 7.1 uses the new xinetd.d structure, in this case you need
930 to change the lines in <filename>/etc/xinetd.d/telnet</filename>
931 and <filename>/etc/xinetd.d/wu-ftp</filename> from
932 </para>
934 <para><programlisting>
935 enable = no
936 </programlisting></para>
938 <para>
940 </para>
942 <para><programlisting>
943 enable = yes
944 </programlisting></para>
946 <para>
947 For ftp services to work properly, you will also need to either
948 have individual directories for the domain users already present on
949 the server, or change the home directory template to a general
950 directory for all domain users. These can be easily set using
951 the <filename>smb.conf</filename> global entry
952 <command>template homedir</command>.
953 </para>
955 <para>
956 The <filename>/etc/pam.d/ftp</filename> file can be changed
957 to allow winbind ftp access in a manner similar to the
958 samba file. My <filename>/etc/pam.d/ftp</filename> file was
959 changed to look like this:
960 </para>
962 <para><programlisting>
963 auth required /lib/security/pam_listfile.so item=user sense=deny \
964 file=/etc/ftpusers onerr=succeed
965 auth sufficient /lib/security/pam_winbind.so
966 auth required /lib/security/pam_stack.so service=system-auth
967 auth required /lib/security/pam_shells.so
968 account sufficient /lib/security/pam_winbind.so
969 account required /lib/security/pam_stack.so service=system-auth
970 session required /lib/security/pam_stack.so service=system-auth
971 </programlisting></para>
973 <para>
974 The <filename>/etc/pam.d/login</filename> file can be changed nearly the
975 same way. It now looks like this:
976 </para>
978 <para><programlisting>
979 auth required /lib/security/pam_securetty.so
980 auth sufficient /lib/security/pam_winbind.so
981 auth sufficient /lib/security/pam_unix.so use_first_pass
982 auth required /lib/security/pam_stack.so service=system-auth
983 auth required /lib/security/pam_nologin.so
984 account sufficient /lib/security/pam_winbind.so
985 account required /lib/security/pam_stack.so service=system-auth
986 password required /lib/security/pam_stack.so service=system-auth
987 session required /lib/security/pam_stack.so service=system-auth
988 session optional /lib/security/pam_console.so
989 </programlisting></para>
991 <para>
992 In this case, I added the <command>auth sufficient /lib/security/pam_winbind.so</command>
993 lines as before, but also added the <command>required pam_securetty.so</command>
994 above it, to disallow root logins over the network. I also added a
995 <command>sufficient /lib/security/pam_unix.so use_first_pass</command>
996 line after the <command>winbind.so</command> line to get rid of annoying
997 double prompts for passwords.
998 </para>
1000 </sect4>
1002 <sect4>
1003 <title>Solaris-specific configuration</title>
1005 <para>
1006 The /etc/pam.conf needs to be changed. I changed this file so that my Domain
1007 users can logon both locally as well as telnet.The following are the changes
1008 that I made.You can customize the pam.conf file as per your requirements,but
1009 be sure of those changes because in the worst case it will leave your system
1010 nearly impossible to boot.
1011 </para>
1013 <para><programlisting>
1015 #ident "@(#)pam.conf 1.14 99/09/16 SMI"
1017 # Copyright (c) 1996-1999, Sun Microsystems, Inc.
1018 # All Rights Reserved.
1020 # PAM configuration
1022 # Authentication management
1024 login auth required /usr/lib/security/pam_winbind.so
1025 login auth required /usr/lib/security/$ISA/pam_unix.so.1 try_first_pass
1026 login auth required /usr/lib/security/$ISA/pam_dial_auth.so.1 try_first_pass
1028 rlogin auth sufficient /usr/lib/security/pam_winbind.so
1029 rlogin auth sufficient /usr/lib/security/$ISA/pam_rhosts_auth.so.1
1030 rlogin auth required /usr/lib/security/$ISA/pam_unix.so.1 try_first_pass
1032 dtlogin auth sufficient /usr/lib/security/pam_winbind.so
1033 dtlogin auth required /usr/lib/security/$ISA/pam_unix.so.1 try_first_pass
1035 rsh auth required /usr/lib/security/$ISA/pam_rhosts_auth.so.1
1036 other auth sufficient /usr/lib/security/pam_winbind.so
1037 other auth required /usr/lib/security/$ISA/pam_unix.so.1 try_first_pass
1039 # Account management
1041 login account sufficient /usr/lib/security/pam_winbind.so
1042 login account requisite /usr/lib/security/$ISA/pam_roles.so.1
1043 login account required /usr/lib/security/$ISA/pam_unix.so.1
1045 dtlogin account sufficient /usr/lib/security/pam_winbind.so
1046 dtlogin account requisite /usr/lib/security/$ISA/pam_roles.so.1
1047 dtlogin account required /usr/lib/security/$ISA/pam_unix.so.1
1049 other account sufficient /usr/lib/security/pam_winbind.so
1050 other account requisite /usr/lib/security/$ISA/pam_roles.so.1
1051 other account required /usr/lib/security/$ISA/pam_unix.so.1
1053 # Session management
1055 other session required /usr/lib/security/$ISA/pam_unix.so.1
1057 # Password management
1059 #other password sufficient /usr/lib/security/pam_winbind.so
1060 other password required /usr/lib/security/$ISA/pam_unix.so.1
1061 dtsession auth required /usr/lib/security/$ISA/pam_unix.so.1
1063 # Support for Kerberos V5 authentication (uncomment to use Kerberos)
1065 #rlogin auth optional /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1066 #login auth optional /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1067 #dtlogin auth optional /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1068 #other auth optional /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1069 #dtlogin account optional /usr/lib/security/$ISA/pam_krb5.so.1
1070 #other account optional /usr/lib/security/$ISA/pam_krb5.so.1
1071 #other session optional /usr/lib/security/$ISA/pam_krb5.so.1
1072 #other password optional /usr/lib/security/$ISA/pam_krb5.so.1 try_first_pass
1073 </programlisting></para>
1075 <para>
1076 I also added a try_first_pass line after the winbind.so line to get rid of
1077 annoying double prompts for passwords.
1078 </para>
1080 <para>
1081 Now restart your Samba and try connecting through your application that you
1082 configured in the pam.conf.
1083 </para>
1085 </sect4>
1087 </sect3>
1089 </sect2>
1091 </sect1>
1093 <sect1>
1094 <title>Limitations</title>
1096 <para>Winbind has a number of limitations in its current
1097 released version that we hope to overcome in future
1098 releases:</para>
1100 <itemizedlist>
1101 <listitem><para>Winbind is currently only available for
1102 the Linux, Solaris and IRIX operating systems, although ports to other operating
1103 systems are certainly possible. For such ports to be feasible,
1104 we require the C library of the target operating system to
1105 support the Name Service Switch and Pluggable Authentication
1106 Modules systems. This is becoming more common as NSS and
1107 PAM gain support among UNIX vendors.</para></listitem>
1109 <listitem><para>The mappings of Windows NT RIDs to UNIX ids
1110 is not made algorithmically and depends on the order in which
1111 unmapped users or groups are seen by winbind. It may be difficult
1112 to recover the mappings of rid to UNIX id mapping if the file
1113 containing this information is corrupted or destroyed.</para>
1114 </listitem>
1116 <listitem><para>Currently the winbind PAM module does not take
1117 into account possible workstation and logon time restrictions
1118 that may be been set for Windows NT users, this is
1119 instead up to the PDC to enforce.</para></listitem>
1120 </itemizedlist>
1121 </sect1>
1124 <sect1>
1125 <title>Conclusion</title>
1127 <para>The winbind system, through the use of the Name Service
1128 Switch, Pluggable Authentication Modules, and appropriate
1129 Microsoft RPC calls have allowed us to provide seamless
1130 integration of Microsoft Windows NT domain users on a
1131 UNIX system. The result is a great reduction in the administrative
1132 cost of running a mixed UNIX and NT network.</para>
1134 </sect1>
1136 </chapter>