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