#!/usr/bin/perl
my ($user) = @ARGV;
my $drives = {F => "NET USE F: \\\\SKYLINE\\SKYLINEF\r\n",
H => "NET USE H: \\\\SKYLINE\\SHARE\r\n",
I => "NET USE I: \\\\SHIPPING1\\INVENTORY\r\n",
M => "NET USE M: \\\\SKYLINE\\SKYLINEM\r\n",
S => "NET USE S: \\\\SHIPPING1\\SHOP\r\n",
Y => "NET USE Y: \\\\ACCOUNTING\\FLTSCHOOL\r\n",
Z => "NET USE Z: \\\\ACCOUNTING\\MAINT\r\n"};
my $which = {accounting => "F H I M S Y Z", mech => "I M S Z", dispatch => "M", instructors => "M"};
my $groups = `cat /etc/group | grep ${user} | cut -d ':' -f 1`;
$groups =~ s/\n/\:/sg;
# Start generating logon script #open LOGON, ">/usr/local/samba/netlogon/${user}.bat"; open LOGON, ">/tmp/${user}.bat"; print LOGON "[EMAIL PROTECTED] OFF\r\n";
foreach $group (split /:/, $groups) { foreach $drive (split / /, $which->{$group}) { print LOGON $drives->{$drive}; } }
close LOGON; system "cat /tmp/${user}.bat | sort -u > /usr/local/samba/netlogon/${user}.bat";
rruegner wrote:
Hi, here is an example start this script with root prexec in the netlogon share it will create netlogon bat files for users and groups which can the orginal file is genlogon.pl which is part of samba, read the doku, all other stuff is done by netlogon bat files ( there are several examples in the web ) Best Regards
#!/usr/bin/perl # # login.pl # creation on the fly logon scripts by [EMAIL PROTECTED] inspired by genlogon.pl # Log client connection #($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); open LOG, ">>/smbmonitor/user/netlogon.txt"; print LOG "$mon/$mday/$year $hour:$min:$sec - User $ARGV[0] Group $ARGV[1]\n from $ARGV[2] in $ARGV[3]"; close LOG;
# Start generating logon script for user open LOGON, ">/var/lib/samba/netlogon/$ARGV[0].bat"; print LOGON "[EMAIL PROTECTED] OFF\r\n echo %USERNAME%\r\n call send.bat\r\n";
# Start generating logon script for machine for different security monitoring open LOGON, ">/var/lib/samba/netlogon/$ARGV[2].bat"; print LOGON "[EMAIL PROTECTED] OFF\r\n call chkdir.bat\r\n call listapp.bat > \\\\$ARGV[3]\\smbmonitor\\machines\\$ARGV[2]\\software\\$A$
# Start generating logon script for group open LOGON, ">/var/lib/samba/netlogon/$ARGV[1].bat"; print LOGON "[EMAIL PROTECTED] OFF\r\n";
# Connect shares for group users if ($ARGV[1] eq "users") { print LOGON "NET USE X: \\\\$ARGV[3]\\files\r\n"; }
# Connect shares for group ntadmin if ($ARGV[1] eq "ntadmin") { print LOGON "NET USE Y: \\\\$ARGV[3]\\smbmonitor\r\n"; }
----- Original Message ----- From: "Andrew Gaffney" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 09, 2003 6:02 PM
Subject: [Samba] netlogon script generation
Can anyone point me to a doc or a script that shows how to generate
netlogon script on the
fly and supports users having multiple groups? I tried the Perl script
referenced at
<http://us2.samba.org/samba/docs/man/AdvancedNetworkManagement.html> but I
believe it only
supports the user being a member of one group.
-- Andrew Gaffney
-- To unsubscribe from this list go to the following URL and read the instructions: http://lists.samba.org/mailman/listinfo/samba
-- Andrew Gaffney
-- To unsubscribe from this list go to the following URL and read the instructions: http://lists.samba.org/mailman/listinfo/samba