selftest: use "state directory" and "cache directory" options
[Samba/gebeck_regimport.git] / examples / logon / genlogon / genlogon.pl
blob4799ac8452d5c11bc849e5e57f7b826233a7f709
1 #!/usr/bin/perl
3 # genlogon.pl
5 # Perl script to generate user logon scripts on the fly, when users
6 # connect from a Windows client. This script should be called from smb.conf
7 # with the %U, %G and %L parameters. I.e:
9 # root preexec = genlogon.pl %U %G %L
11 # The script generated will perform
12 # the following:
14 # 1. Log the user connection to /var/log/samba/netlogon.log
15 # 2. Set the PC's time to the Linux server time (which is maintained
16 # daily to the National Institute of Standard's Atomic clock on the
17 # internet.
18 # 3. Connect the user's home drive to H: (H for Home).
19 # 4. Connect common drives that everyone uses.
20 # 5. Connect group-specific drives for certain user groups.
21 # 6. Connect user-specific drives for certain users.
22 # 7. Connect network printers.
24 # Log client connection
25 #($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
26 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
27 open LOG, ">>/var/log/samba/netlogon.log";
28 print LOG "$mon/$mday/$year $hour:$min:$sec - User $ARGV[0] logged into $ARGV[1]\n";
29 close LOG;
31 # Start generating logon script
32 open LOGON, ">/shared/netlogon/$ARGV[0].bat";
33 print LOGON "\@ECHO OFF\r\n";
35 # Connect shares just use by Software Development group
36 if ($ARGV[1] eq "SOFTDEV" || $ARGV[0] eq "softdev")
38 print LOGON "NET USE M: \\\\$ARGV[2]\\SOURCE\r\n";
41 # Connect shares just use by Technical Support staff
42 if ($ARGV[1] eq "SUPPORT" || $ARGV[0] eq "support")
44 print LOGON "NET USE S: \\\\$ARGV[2]\\SUPPORT\r\n";
47 # Connect shares just used by Administration staff
48 if ($ARGV[1] eq "ADMIN" || $ARGV[0] eq "admin")
50 print LOGON "NET USE L: \\\\$ARGV[2]\\ADMIN\r\n";
51 print LOGON "NET USE K: \\\\$ARGV[2]\\MKTING\r\n";
54 # Now connect Printers. We handle just two or three users a little
55 # differently, because they are the exceptions that have desktop
56 # printers on LPT1: - all other user's go to the LaserJet on the
57 # server.
58 if ($ARGV[0] eq 'jim'
59 || $ARGV[0] eq 'yvonne')
61 print LOGON "NET UsE LPT2: \\\\$ARGV[2]\\LJET3\r\n";
62 print LOGON "NET USE LPT3: \\\\$ARGV[2]\\FAXQ\r\n";
64 else
66 print LOGON "NET USE LPT1: \\\\$ARGV[2]\\LJET3\r\n";
67 print LOGON "NET USE LPT3: \\\\$ARGV[2]\\FAXQ\r\n";
70 # All done! Close the output file.
71 close LOGON;