Automated logon scripts [long listing]

Chip Spencer ma_spencer at lgca.org
Thu May 27 14:19:54 GMT 1999


Hi,

I am trying to implement automated logon scripts. Based on the users primary group different drive mappings are used. i essentially have two primary groups based on job roles ane user groups that are classroom based. I.e., admin for administrators, teachers for teachers, and the classroom groups are the building abbreviation+classroom number (rbe29, rbe2, etc.) I need automated logon scripts because I don't  want to hand edit 600+ individual logon scripts for the school district. I used the sample script in John Blair's book as a starting point. I am just getting started with Perl, so be gentle if I've made a stupid programming error. What is happening is when a user logs onto the samba server, an entry is made in /var/log/netlogon.log stating the username, machine, and group info. Then what is supposed to happen is the logon script is to be written with the correct drive mappings for that group. There is a root prexec statement in the [NETLOGON] section of my smb.conf file that passes %U %m %G to the perl script. So the line reads:

......<snip>
    [NETLOGON]
           root preexec = /usr/bin/makelogonscript %U %m %G
......<snip>



here is the perl script "makelogonscript"

#!/usr/bin/perl

#

# Automated logon scripts. Logs user to server. Then determines what group 

# the user belongs to. Sets up the net drives acoordingly. 

# 

($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);

$month = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Sep', 'Oct', 'Nov', 'Dec') [$mon];

open LOG, ">>/var/log/netlogon.log";

print LOG "$month $mday $hour:$min:$sec $ARGV[0] logged into $ARGV[1]\n";

print LOG "User: $ARGV[0] - Machine: $ARGV[1] - Group: $ARGV[2]\n";

close LOG;

open LOGON, ">/usr/local/samba/netlogon/$ARGV[0].bat";

#determine the user's group and setup net drives

if ($ARGV[2] = "admin") {


# print LOGON "@echo off \r\n";

print LOGON ("NET USE H: \\\\RBE\\$ARGV[0]\r\n");

print LOGON ("NET USE P: \\\\RBE\\PUBLIC\r\n");

close LOGON;


} elsif ($ARGV[2] = "teachers") {

# print LOGON "@echo off\r\n";

print LOGON ("NET USE H: \\\\RBE\\$ARGV[0]\r\n");

print LOGON ("NET USE P: \\\\RBE\\PUBLIC\r\n");

close LOGON;

} else {


# print LOGON "@echo off\r\n";

print LOGON ("NET USE S: \\\\RBE\\$ARGV[0]\r\n");

print LOGON ("NET USE P: \\\\RBE\\students\r\n");

close LOGON;

}





now, with me being new to perl, could someone help me debug this code and point me in the right direction.



Thanks 

Chip Spencer

Madison Local School district

ma_spencer at lgca.org



-------------- next part --------------
HTML attachment scrubbed and removed


More information about the samba-ntdom mailing list