Hi all, Just a quick question about login scripts for a large number of users who change rooms a lot. I have several rooms each with a printer, and nearly a thousand users divided into two main groups - pupils and teachers who change rooms on a routine basis. Is it possible to set up multiple login scripts that would be executed in sequence i.e. run by user is %u, and machine is %m is it possible to say run %u to set up shares followed by %m to set up the right printers for the room their in? Thanks in advance... Cheers, Jpb -- Julian Pilfold-Bagwell Borden Grammar School Avenue of Remembrance Sittingbourne Kent ME10 4DB Tel: (+44)1795 424192 ext 121
Julian Pilfold-Bagwell wrote:>Hi all, > >Just a quick question about login scripts for a large number of users who >change rooms a lot. > >I have several rooms each with a printer, and nearly a thousand users divided >into two main groups - pupils and teachers who change rooms on a routine >basis. Is it possible to set up multiple login scripts that would be executed >in sequence i.e. run by user is %u, and machine is %m is it possible to say >run %u to set up shares followed by %m to set up the right printers for the >room their in? > >Dear Julian, you might have a look at "http://www.kixtart.org". It should do, what you need. Best Joachim
Julian Pilfold-Bagwell schrieb:> Hi all, > > Just a quick question about login scripts for a large number of users who > change rooms a lot. > > I have several rooms each with a printer, and nearly a thousand users divided > into two main groups - pupils and teachers who change rooms on a routine > basis. Is it possible to set up multiple login scripts that would be executed > in sequence i.e. run by user is %u, and machine is %m is it possible to say > run %u to set up shares followed by %m to set up the right printers for the > room their in?what if you put into each user's script something like: \\server\scripts\machines\%COMPUTERNAME%.bat (computer-specific script)? -- Tomek http://wpkg.org WPKG - software deployment and upgrades with Samba
> basis. Is it possible to set up multiple login scripts that > would be executed > in sequence i.e. run by user is %u, and machine is %m is it > possible to say > run %u to set up shares followed by %m to set up the right > printers for the > room their in?With some clever scripting, anything is possible. Some folks like to use the built in dos scripting methods to do flow control, some like to use kixtart(spelling?) and some like to use server side scripting to generate static login scripts. I can only comment on the latter. We have a perl script set in the prelogon section of netlogon that will determine lots of fun stuff about the user and where they are coming from. Once the script has determined who/what is connecting and where from, it will write out a batch file into the netlogon share that the user then executes, since our logon script variable is something like %U.bat If that gets you thinking, great, if not post back.
Julian Pilfold-Bagwell wrote:> I have several rooms each with a printer, and nearly a thousand users divided > into two main groups - pupils and teachers who change rooms on a routine > basis. Is it possible to set up multiple login scripts that would be executed > in sequence i.e. run by user is %u, and machine is %m is it possible to say > run %u to set up shares followed by %m to set up the right printers for the > room their in?How about something like logonscript="%u.bat %m" and a %u.bat ending with call %1.bat which calls %m.bat? You can easyly extend this, for example: logonscript="%g.bat %u %m" for calling first the group batch %g.bat for the groups pupils and teachers, then at the end from %g.bat you are calling first the user batch %u.bat with call %1.bat and then the machine batch %m.bat with call %2.bat Nothing special is needed, no kixstart or perl scripting. der tom
Julian Pilfold-Bagwell schrieb:>Hi all, > >Just a quick question about login scripts for a large number of users who >change rooms a lot. > >I have several rooms each with a printer, and nearly a thousand users divided >into two main groups - pupils and teachers who change rooms on a routine >basis. Is it possible to set up multiple login scripts that would be executed >in sequence i.e. run by user is %u, and machine is %m is it possible to say >run %u to set up shares followed by %m to set up the right printers for the >room their in? > >Thanks in advance... > >Cheers, > >Jpb > >Hi, jep it can be done , use ifmember.exe from the resource kit, and install printers by group membership like this #defautllogin.bat @echo off ifmember /v /l "YOURDOMAINNAME\teachers" if errorlevel 1 call teachers.bat #teachers.bat @echo off REM install the pdfwriter rundll32 printui.dll,PrintUIEntry /dn /n "\\pdc\pdfwriter" /q rundll32 printui.dll,PrintUIEntry /in /n "\\pdc\pdfwriter" REM install Lexmark t630 Laserprinter rundll32 printui.dll,PrintUIEntry /dn /n "\\pdc\lext630" /q rundll32 printui.dll,PrintUIEntry /in /n "\\pdc\lext630" this works if you install the printer drivers on samba, how to in smb faqs you can do any jobs by having a default login.bat for every domain user and lead to others bats by lead from ifmember.exe so there are many combinations thinkable Regards
Paul Gienger wrote:>>basis. Is it possible to set up multiple login scripts that >>would be executed >>in sequence i.e. run by user is %u, and machine is %m is it >>possible to say >>run %u to set up shares followed by %m to set up the right >>printers for the >>room their in? >> >> >We have a perl script set in the prelogon section of netlogon that will >determine lots of fun stuff about the user and where they are coming from. >Once the script has determined who/what is connecting and where from, it >will write out a batch file into the netlogon share that the user then >executes, since our logon script variable is something like %U.bat > >I do nearly the same at my site, except that i get the info from ldap for which i wrote a little schema with a "script" attribute. I extract that attributes with preexec in [netlogon] using a util written in C (_starts_ faster than perl) and write static logon scripts as well. I put the scripts in user (machine), group and artificial "room" entries. I would never claim that this is the most clever solution, but it works for me. Your choice! Kind regards, Malte
Hello,> >Just a quick question about login scripts for a large number of users who > >change rooms a lot. > > > >I have several rooms each with a printer, and nearly a thousand users divided > >into two main groups - pupils and teachers who change rooms on a routine > >basis. Is it possible to set up multiple login scripts that would be executed > >in sequence i.e. run by user is %u, and machine is %m is it possible to say > >run %u to set up shares followed by %m to set up the right printers for the > >room their in?I have been using a lightly modified version of the perl logon script in the samba contrib directory. Perhaps it can help you with that. The advantage of this script is that the secondary unix groups are automatically mapped to windows units (M:, J:, ...) based in their membership to those unix groups. For you case simply add %m to the list of netlogon parameters and write the desired configuration. regards, smb.conf: ========[global] logon script = %U.bat [netlogon] ... root preexec = " /usr/local/bin/logon.pl %U %G %L" /----/ logon.pl: ========#!/usr/bin/perl $usuario = $ARGV[0] ; $grupoPrimario = $ARGV[1] ; $servidor = $ARGV[2] ; # log login activity ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); open LOG, ">>/var/log/samba/netlogon.log"; print LOG "$year/$mon/$mday $hour:$min:$sec"; print LOG " - User $ARGV[0] logged into $ARGV[1]\n"; close LOG; # check the presence of a home directory $idnum = (getpwnam ($usuario))[2]; $gidnum = (getpwnam ($usuario))[3]; $homedir = (getpwnam ($usuario))[7]; if ( ! -d $homedir) { mkdir(${homedir},0700) || die "No pude crear $homedir: $!"; chown($idnum , $gidnum , ${homedir} ); } # Start generating logon script open LOGON, ">/var/lib/samba/netlogon/${usuario.bat}"; print LOGON "\@ECHO OFF\r\n"; # generic stuff. print LOGON "NET USE /persistent:no\r\n"; print LOGON "NET TIME \\\\$servidor /set /yes \r\n"; print LOGON "NET USE U: /HOME \r\n"; print LOGON "NET USE F: \\\\$servidor\\publico \r\n"; # specific user maps if ($usuario eq "jefazo") { print LOGON "NET USE z: \\\\$servidor\\CEO\r\n"; } # primary group maps if ($grupoPrimario eq "informatic") { print LOGON "NET USE H: \\\\$servidor\\$grupoPrimario \r\n"; } # secondary group maps while (($grupoSecundario, $passwd, $gid, $members) = getgrent) { if ( grep /\b$ARGV[0]\b/, $members ) { if ( $grupoSecundario eq "telefonia" ) { print LOGON "NET USE N: \\\\$servidor\\$grupoSecundario \r\n"; } } } close LOGON; -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/IT d- s+:+() a31 C+++ UBL+++$ P+ L+++ E--- W++ N+ o++ K- w--- O+ M+ V- PS+ PE+ Y++ PGP+>+++ t+ 5 X+$ R- tv-- b+++ DI D++>+++ G++ e- h+(++) !r !z ------END GEEK CODE BLOCK------
Jos? M. Fandi?o schrieb:>Hello, > > > >>>Just a quick question about login scripts for a large number of users who >>>change rooms a lot. >>> >>>I have several rooms each with a printer, and nearly a thousand users divided >>>into two main groups - pupils and teachers who change rooms on a routine >>>basis. Is it possible to set up multiple login scripts that would be executed >>>in sequence i.e. run by user is %u, and machine is %m is it possible to say >>>run %u to set up shares followed by %m to set up the right printers for the >>>room their in? >>> >>> > >I have been using a lightly modified version of the perl logon >script in the samba contrib directory. Perhaps it can help you >with that. > >The advantage of this script is that the secondary unix groups >are automatically mapped to windows units (M:, J:, ...) based >in their membership to those unix groups. > >For you case simply add %m to the list of netlogon parameters >and write the desired configuration. > >regards, > >smb.conf: >========>[global] >logon script = %U.bat > >[netlogon] >... >root preexec = " /usr/local/bin/logon.pl %U %G %L" > > /----/ > >logon.pl: >========>#!/usr/bin/perl >$usuario = $ARGV[0] ; >$grupoPrimario = $ARGV[1] ; >$servidor = $ARGV[2] ; > ># log login activity >($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); >open LOG, ">>/var/log/samba/netlogon.log"; >print LOG "$year/$mon/$mday $hour:$min:$sec"; >print LOG " - User $ARGV[0] logged into $ARGV[1]\n"; >close LOG; > ># check the presence of a home directory >$idnum = (getpwnam ($usuario))[2]; >$gidnum = (getpwnam ($usuario))[3]; >$homedir = (getpwnam ($usuario))[7]; >if ( ! -d $homedir) { > mkdir(${homedir},0700) || die "No pude crear $homedir: $!"; > chown($idnum , $gidnum , ${homedir} ); >} > ># Start generating logon script >open LOGON, ">/var/lib/samba/netlogon/${usuario.bat}"; >print LOGON "\@ECHO OFF\r\n"; > ># generic stuff. >print LOGON "NET USE /persistent:no\r\n"; >print LOGON "NET TIME \\\\$servidor /set /yes \r\n"; >print LOGON "NET USE U: /HOME \r\n"; >print LOGON "NET USE F: \\\\$servidor\\publico \r\n"; > > ># specific user maps >if ($usuario eq "jefazo") >{ > print LOGON "NET USE z: \\\\$servidor\\CEO\r\n"; >} > ># primary group maps >if ($grupoPrimario eq "informatic") { > print LOGON "NET USE H: \\\\$servidor\\$grupoPrimario \r\n"; >} > ># secondary group maps >while (($grupoSecundario, $passwd, $gid, $members) = getgrent) { > if ( grep /\b$ARGV[0]\b/, $members ) > { > if ( $grupoSecundario eq "telefonia" ) { > print LOGON "NET USE N: \\\\$servidor\\$grupoSecundario \r\n"; > } > } >} >close LOGON; > > >Hi this scripts are very usefull if you want things coming up on demand, but for every change this has to be rewritten, ifmember.exe in an default logon.bat is more flexible as it is only one file in one place which has to be edited and it needs no prexec. After all every win admin can rewrite it too, some of them hat deep problems with perl Regards
look for samba mailing list for command-line-printer-installation (it was here, but I missed the link, actually it will work on w2k and above) also, we use the following in our logon scripts (not sure it will work for nt4 and 9x, never tried it): -----<cut here>--- if "%COMPUTERNAME%" == "TERMINAL" goto noprinthlp ... :noprinthlp ... ---<cut here>---> Hi all, > > Just a quick question about login scripts for a large number of users who > change rooms a lot. > > I have several rooms each with a printer, and nearly a thousand users divided > into two main groups - pupils and teachers who change rooms on a routine > basis. Is it possible to set up multiple login scripts that would be executed > in sequence i.e. run by user is %u, and machine is %m is it possible to say > run %u to set up shares followed by %m to set up the right printers for the > room their in? > > Thanks in advance... > > Cheers, > > Jpb > -- > > Julian Pilfold-Bagwell > Borden Grammar School > Avenue of Remembrance > Sittingbourne > Kent > ME10 4DB > > Tel: (+44)1795 424192 ext 121 > -- > To unsubscribe from this list go to the following URL and read the > instructions: https://lists.samba.org/mailman/listinfo/samba >