[Samba] getlogon.pl script problem
Sundaram Ramasamy
sun at percipia.com
Wed Mar 10 04:35:07 GMT 2004
Hi,
I want to generate the logon script on the fly. I want to map user home
directory into H: drive.
Genlogon.pl script executes three times for single user, each time its
getting diffract argument value.
Here is my configuration
root preexec = /netlogon/genlogon.pl %U %G %L
logon script = %U.bat
logon path =
logon drive =
logon home =
domain logons = Yes
[netlogon]
path = /netlogon
write list = ntadmin
locking = No
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, ">>/var/log/samba/netlogon.log";
print LOG "$mon/$mday/$year $hour:$min:$sec - User $ARGV[0] logged into
$ARGV[1] ==>";
print LOG " %U User $ARGV[0] : %G Group $ARGV[1] : %L Server
$ARGV[2]\n";
close LOG;
# Start generating logon script
open LOGON, ">/netlogon/$ARGV[0].bat";
print LOGON "\@ECHO OFF\r\n";
# Connect shares just use by Software Development group
if ($ARGV[1] eq "SOFTDEV" || $ARGV[0] eq "softdev")
{
print LOGON "NET USE M: \\\\$ARGV[2]\\SOURCE\r\n";
}
# Connect shares just use by Technical Support staff
if ($ARGV[1] eq "SUPPORT" || $ARGV[0] eq "support")
{
print LOGON "NET USE S: \\\\$ARGV[2]\\SUPPORT\r\n";
}
print LOGON "net time \\\\$ARGV[2] /set /y\r\n";
print LOGON "NET USE T: /delete /y\r\n";
print LOGON "NET USE T: \\\\$ARGV[2]\\tmp\r\n";
print LOGON "NET USE H: /delete /y\r\n";
print LOGON "NET USE H: \\\\$ARGV[2]\\$ARGV[0]\r\n";
# All done! Close the output file.
close LOGON;
# cat /var/log/samba/netlogon.log
2/9/104 23:24:44 - User %G logged into testpdc ==> %U User %G : %G Group
testpdc : %L Server
2/9/104 23:24:45 - User %G logged into testpdc ==> %U User %G : %G Group
testpdc : %L Server
2/9/104 23:24:47 - User user1 logged into Domain ==> %U User user1 : %G
Group Domain : %L Server Users
Generated script.
This one is wrong; it takes server name as users, correct server name is
testpdc.
mail:~ # cat /netlogon/user1.bat
@ECHO OFF
net time \\Users /set /y
NET USE T: /delete /y
NET USE T: \\Users\tmp
NET USE H: /delete /y
NET USE H: \\Users\user1
How will I generate the script with correct server name? Why this script
is executing three times with different argument values
Thanks
Sundaram
More information about the samba
mailing list