Fix typos.
[Samba.git] / docs / Samba-HOWTO-Collection / TOSHARG-AdvancedNetworkAdmin.xml
blob66b4c27406af6b07b19107a6db988f20aed7d0bb
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="AdvancedNetworkManagement">
4 <chapterinfo>
5         &author.jht;
6     <pubdate>April 3 2003</pubdate>
7 </chapterinfo>
9 <title>Advanced Network Management</title>
11 <para>
12 This section documents peripheral issues that are of great importance to network
13 administrators who want to improve network resource access control, to automate the user
14 environment and to make their lives a little easier.
15 </para>
17 <sect1>
18 <title>Features and Benefits</title>
20 <para>
21 Often the difference between a working network environment and a well appreciated one can
22 best be measured by the <emphasis>little things</emphasis> that make everything work more
23 harmoniously. A key part of every network environment solution is the
24 ability to remotely
25 manage MS Windows workstations, remotely access the Samba server, provide customized
26 logon scripts, as well as other housekeeping activities that help to sustain more reliable
27 network operations.
28 </para>
30 <para>
31 This chapter presents information on each of these areas. They are placed here, and not in
32 other chapters, for ease of reference.
33 </para>
35 </sect1>
37 <sect1>
38 <title>Remote Server Administration</title>
41 <para><quote>How do I get `User Manager' and `Server Manager'?</quote></para>
43 <para>
44 <indexterm><primary>User Manager</primary></indexterm>
45 <indexterm><primary>Server Manager</primary></indexterm>
46 <indexterm><primary>Event Viewer</primary></indexterm>
47 Since I do not need to buy an <application>NT4 Server</application>, how do I get the `User Manager for Domains'
48 and the `Server Manager'?
49 </para>
51 <para>
52 <indexterm><primary>Nexus.exe</primary></indexterm>
53 Microsoft distributes a version of these tools called <filename>Nexus.exe</filename> for installation 
54 on <application>Windows 9x/Me</application> systems. The tools set includes:
55 </para>
57 <itemizedlist>
58         <listitem><para>Server Manager</para></listitem>
59         <listitem><para>User Manager for Domains</para></listitem>
60         <listitem><para>Event Viewer</para></listitem>
61 </itemizedlist>
63 <para>
64 Download the archived file at <ulink noescape="1" url="ftp://ftp.microsoft.com/Softlib/MSLFILES/NEXUS.EXE">ftp://ftp.microsoft.com/Softlib/MSLFILES/NEXUS.EXE.</ulink>
65 </para>
67 <para>
68 <indexterm><primary>SRVTOOLS.EXE</primary></indexterm>
69 The <application>Windows NT 4.0</application> version of the `User Manager for 
70 Domains' and `Server Manager' are available from Microsoft <ulink url="ftp://ftp.microsoft.com/Softlib/MSLFILES/SRVTOOLS.EXE">via ftp</ulink>.
71 </para>
73 </sect1>
75 <sect1>
76 <title>Remote Desktop Management</title>
78 <para>
79 There are a number of possible remote desktop management solutions that range from free
80 through costly. Do not let that put you off. Sometimes the most costly solution is the
81 most cost effective. In any case, you will need to draw your own conclusions as to which
82 is the best tool in your network environment.
83 </para>
85         <sect2>
86         <title>Remote Management from NoMachine.Com</title>
88         <para>
89         <indexterm><primary>NoMachine.Com</primary></indexterm>
90         The following information was posted to the Samba mailing list at Apr 3 23:33:50 GMT 2003.
91         It is presented in slightly edited form (with author details omitted for privacy reasons).
92         The entire answer is reproduced below with some comments removed.
93         </para>
95                 <para><quote>
96                 I have a wonderful Linux/Samba server running as pdc for a network. Now I would like to add remote
97                 desktop capabilities so users outside could login to the system and get their desktop up from home or
98                 another country.
99                 </quote></para>
101                 <para><quote>
102                 Is there a way to accomplish this? Do I need a Windows Terminal Server?  Do I need to configure it so
103                 it is a member of the domain or a BDC,PDC? Are there any hacks for MS Windows XP to enable remote login
104                 even if the computer is in a domain?
105                 </quote></para>
107                 <para>
108                 Answer provided: Check out the new offer of <quote>NX</quote> software from
109                 <ulink noescape="1" url="http://www.nomachine.com/">NoMachine</ulink>.
110                 </para>
112         <para>
113         It implements an easy-to-use interface to the Remote X protocol as
114         well as incorporating VNC/RFB and rdesktop/RDP into it, but at a speed
115         performance much better than anything you may have ever seen.
116         </para>
118         <para>
119         Remote X is not new at all, but what they did achieve successfully is
120         a new way of compression and caching technologies that makes the thing
121         fast enough to run even over slow modem/ISDN connections.
122         </para>
124         <para>
125         I could test drive their (public) Red Hat machine in Italy, over a loaded
126         Internet connection, with enabled thumbnail previews in KDE konqueror
127         which popped up immediately on <quote>mouse-over</quote>. From inside that (remote X)
128         session I started a rdesktop session on another, a Windows XP machine.
129         To test the performance, I played Pinball. I am proud to announce
130         that my score was 631750 points at first try.
131         </para>
133         <para>
134         NX performs better on my local LAN than any of the other <quote>pure</quote>
135         connection methods I am using from time to time: TightVNC, rdesktop or
136         Remote X. It is even faster than a direct crosslink connection between
137         two nodes.
138         </para>
140         <para>
141         I even got sound playing from the Remote X app to my local boxes, and
142         had a working <quote>copy'n'paste</quote> from an NX  window (running a KDE session
143         in Italy) to my Mozilla mailing agent. These guys are certainly doing
144         something right!
145         </para>
147         <para>
148         I recommend to test drive NX to anybody with a only a passing interest in remote computing
149         <ulink noescape="1" url="http://www.nomachine.com/testdrive.php">http://www.nomachine.com/testdrive.php</ulink>.
150         </para>
152         <para>
153         Just download the free of charge client software (available for Red Hat,
154         SuSE, Debian and Windows) and be up and running within five minutes (they
155         need to send you your account data, though, because you are assigned
156         a real UNIX account on their testdrive.nomachine.com box.
157         </para>
159         <para>
160         They plan to get to the point were you can have NX application servers
161         running as a cluster of nodes, and users simply start an NX session locally,
162         and can select applications to run transparently (apps may even run on
163         another NX node, but pretend to be on the same as used for initial login,
164         because it displays in the same window. You also can run it
165         full-screen, and after a short time you forget that it is a remote session
166         at all).
167         </para>
169         <para>
170         Now the best thing for last: All the core compression and caching
171         technologies are released under the GPL and available as source code
172         to anybody who wants to build on it! These technologies are working,
173         albeit started from the command line only (and very inconvenient to
174         use in order to get a fully running remote X session up and running.)
175         </para>
177         <para>
178         To answer your questions:
179         </para>
181         <itemizedlist>
182                 <listitem><para>
183                 You do not need to install a terminal server; XP has RDP support built in.
184                 </para></listitem>
186                 <listitem><para>
187                 NX is much cheaper than Citrix &smbmdash; and comparable in performance, probably faster.
188                 </para></listitem>
190                 <listitem><para>
191                 You do not need to hack XP &smbmdash; it just works.
192                 </para></listitem>
194                 <listitem><para>
195                 You log into the XP box from remote transparently (and I think there is no
196                 need to change anything to get a connection, even if authentication is against a domain).
197                 </para></listitem>
199                 <listitem><para>
200                 The NX core technologies are all Open Source and released under the GPL &smbmdash;
201                 you can now use a (very inconvenient) command-line at no cost,
202                 but you can buy a comfortable (proprietary) NX GUI front end for money.
203                 </para></listitem>
205                 <listitem><para>
206                 NoMachine are encouraging and offering help to OSS/Free Software implementations
207                 for such a front end too, even if it means competition to them (they have written
208                 to this effect even to the LTSP, KDE and GNOME developer mailing lists).
209                 </para></listitem>
210         </itemizedlist>
212         </sect2>
214 </sect1>
216 <sect1>
217 <title>Network Logon Script Magic</title>
219 <para>
220 There are several opportunities for creating a custom network startup configuration environment.
221 </para>
223 <itemizedlist>
224         <listitem><para>No Logon Script.</para></listitem>
225         <listitem><para>Simple universal Logon Script that applies to all users.</para></listitem>
226         <listitem><para>Use of a conditional Logon Script that applies per user or per group attributes.</para></listitem>
227         <listitem><para>Use of Samba's preexec and postexec functions on access to the NETLOGON share to create
228                 a custom logon script and then execute it.</para></listitem>
229         <listitem><para>User of a tool such as KixStart.</para></listitem>
230 </itemizedlist>
232 <para>
233 The Samba source code tree includes two logon script generation/execution tools.
234 See <filename>examples</filename> directory <filename>genlogon</filename> and
235 <filename>ntlogon</filename> subdirectories.
236 </para>
238 <para>
239 The following listings are from the genlogon directory.
240 </para>
243 <para>
244 <indexterm><primary>genlogon.pl</primary></indexterm>
245 This is the <filename>genlogon.pl</filename> file:
247 <smbfile name="genlogon.pl">
248 <programlisting>
249         #!/usr/bin/perl
250         #
251         # genlogon.pl
252         #
253         # Perl script to generate user logon scripts on the fly, when users
254         # connect from a Windows client. This script should be called from 
255         # smb.conf with the %U, %G and %L parameters. I.e:
256         #
257         #       root preexec = genlogon.pl %U %G %L
258         #
259         # The script generated will perform
260         # the following:
261         #
262         # 1. Log the user connection to /var/log/samba/netlogon.log
263         # 2. Set the PC's time to the Linux server time (which is maintained
264         #    daily to the National Institute of Standards Atomic clock on the
265         #    internet.
266         # 3. Connect the user's home drive to H: (H for Home).
267         # 4. Connect common drives that everyone uses.
268         # 5. Connect group-specific drives for certain user groups.
269         # 6. Connect user-specific drives for certain users.
270         # 7. Connect network printers.
272         # Log client connection
273         #($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
274         ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
275         open LOG, ">>/var/log/samba/netlogon.log";
276         print LOG "$mon/$mday/$year $hour:$min:$sec";
277         print LOG " - User $ARGV[0] logged into $ARGV[1]\n";
278         close LOG;
280         # Start generating logon script
281         open LOGON, ">/shared/netlogon/$ARGV[0].bat";
282         print LOGON "\@ECHO OFF\r\n";
284         # Connect shares just use by Software Development group
285         if ($ARGV[1] eq "SOFTDEV" || $ARGV[0] eq "softdev")
286         {
287                 print LOGON "NET USE M: \\\\$ARGV[2]\\SOURCE\r\n";
288         }
290         # Connect shares just use by Technical Support staff
291         if ($ARGV[1] eq "SUPPORT" || $ARGV[0] eq "support")
292         {
293                 print LOGON "NET USE S: \\\\$ARGV[2]\\SUPPORT\r\n";
294         }
296         # Connect shares just used by Administration staff
297         If ($ARGV[1] eq "ADMIN" || $ARGV[0] eq "admin")
298         {
299                 print LOGON "NET USE L: \\\\$ARGV[2]\\ADMIN\r\n";
300                 print LOGON "NET USE K: \\\\$ARGV[2]\\MKTING\r\n";
301         }
303         # Now connect Printers. We handle just two or three users a little
304         # differently, because they are the exceptions that have desktop
305         # printers on LPT1: - all other user's go to the LaserJet on the
306         # server.
307         if ($ARGV[0] eq 'jim'
308             || $ARGV[0] eq 'yvonne')
309         {
310                 print LOGON "NET USE LPT2: \\\\$ARGV[2]\\LJET3\r\n";
311                 print LOGON "NET USE LPT3: \\\\$ARGV[2]\\FAXQ\r\n";
312         }
313         else
314         {
315                 print LOGON "NET USE LPT1: \\\\$ARGV[2]\\LJET3\r\n";
316                 print LOGON "NET USE LPT3: \\\\$ARGV[2]\\FAXQ\r\n";
317         }
319         # All done! Close the output file.
320         close LOGON;
321 </programlisting>
322 </smbfile>
323 </para>
325 <para>
326 Those wishing to use more elaborate or capable logon processing system should check out these sites:
327 </para>
329 <itemizedlist>
330         <listitem><para><ulink noescape="1" url="http://www.craigelachie.org/rhacer/ntlogon">http://www.craigelachie.org/rhacer/ntlogon</ulink></para></listitem>
331         <listitem><para><ulink noescape="1" url="http://www.kixtart.org">http://www.kixtart.org</ulink></para></listitem>
332 </itemizedlist>
334 <sect2>
335 <title>Adding Printers without User Intervention</title>
338 <para>
339 <indexterm><primary>rundll32</primary></indexterm>
340 Printers may be added automatically during logon script processing through the use of:
342 <screen>
343 &dosprompt;<userinput>rundll32 printui.dll,PrintUIEntry /?</userinput>
344 </screen>
346 See the documentation in the <ulink url="http://support.microsoft.com/default.asp?scid=kb;en-us;189105">Microsoft knowledgebase article 189105.</ulink>
347 </para>
348 </sect2>
350 <sect2>
351         <title>Limiting Logon Connections</title>
353         <para>
354                 Sometimes it is necessary to limit the number of concurrent connections to a
355                 Samba shared resource. For example, a site may wish to permit only one network
356                 logon per user.
357         </para>
359         <para>
360                 The Samba <parameter>preexec script</parameter> parameter can be used to permit only one
361                 connection per user. Though this method is not fool-proof, and may have side-effects
362                 the following contributed method may inspire someone to provide a better solution.
363         </para>
365         <para>
366                 This is not a perfect solution because Windows clients can drop idle connections
367                 with an auto-reconnect capability that could result in the appearance that a share
368                 is no longer in use, while actually it is. Even so, it demonstrates the principle
369                 of use of the <parameter>preexec script</parameter> parameter.
370         </para>
372         <para>
373                 The following share configuration demonstrates use of the script shown in <link linkend="Tpees"/>:
374                 <programlisting>
375 [myshare]
376         ...
377         preexec script = /sbin/PermitSingleLogon.sh
378         preexec close = Yes
379         ...
380                 </programlisting>
381         </para>
383 <example id="Tpees">
384         <title>Script to Enforce Single Resource Logon</title>
385 <screen>
386 #!/bin/bash
388 IFS="-"
389 RESULT=$(smbstatus -S -u $1 2> /dev/null | awk 'NF > 6 {print $1}' | sort | uniq -d)
391 if [ "X${RESULT}" == X  ]; then
392   exit 0
393 else
394   exit 1
396 </screen>
397 </example>
399 </sect2>
401 </sect1>
403 </chapter>