Problem: how can I define and integrate my own netlogon scripts in UCS@school

Problem:

How can I define and integrate my own netlogon scripts in UCS@school?

Solution:

UCS@school uses a meta netlogon script that is able to call several other netlogon scripts upon user login.
The meta netlogon script is provided by the package ucs-school-netlogon and automatically used by the UCS@school import (upon user creation the netlogon script is stored at the user object in LDAP/AD).
The configuration of the meta netlogon script is done by Univention Configuration Registry.

The meta netlogon script is configured and created on each UCS@school slave individually (UCS@school domaincontroller master in single server environments). So UCR changes on one UCS@school system, do not affect the meta netlogon script on other servers.

To add custom netlogon scripts, the custom scripts have to be stored in the directory /var/lib/samba/netlogon of each affected UCS@school system.
The scripts to be called are defined via Univention Configuration Registry variables according to schema ucsschool/netlogon/PREFIX/script=SCRIPTNAME. The prefix for packages in the UCS@school scope of delivery is typically the package name and can otherwise be freely selected. Optional variables in the ucsschool/netlogon/PREFIX/script/priority schema can also be used to specify the processing sequence in the form of a number. The scripts are then executed in ascending order (see example below):

UCR-Variables

ucsschool/netlogon/localscript1/script: connect-to-database.bat
ucsschool/netlogon/localscript2/script/priority: 40
ucsschool/netlogon/localscript2/script: connect-printers.vbs
ucsschool/netlogon/ucs-school-netlogon-user-logonscripts/priority: 20
ucsschool/netlogon/ucs-school-netlogon-user-logonscripts/script: user\%USERNAME%.vbs

These UCR-Variables automatically generate the following content of /var/lib/samba/netlogon/ucs-school-logon.vbs:

printToLog logfile, "running connect-to-database.bat"
return = objShell.Run("connect-to-database.bat >> %TEMP%\%USERNAME%-ucs-school-netlogon.log 2>&1", 1, true)
if return <> 0  then
    MsgBox "connect-to-database.bat failed with error code: " & return
end if

printToLog logfile, "running user\%USERNAME%.vbs"
script = objFSO.BuildPath(baseName, "user\%USERNAME%.vbs")
return = objShell.run("wscript //B //Nologo " & script & " >> %TEMP%\%USERNAME%-ucs-school-netlogon.log 2>&1", 1, true)
if return <> 0  then
    MsgBox "user\%USERNAME%.vbs failed with error code: " & return
end if

printToLog logfile, "running connect-printers.vbs"
return = objShell.Run("connect-printers.vbs >> %TEMP%\%USERNAME%-ucs-school-netlogon.log 2>&1", 1, true)
if return <> 0  then
    MsgBox "connect-printers.vbs failed with error code: " & return
end if

Error messages of the logon scripts are stored on the windows client in %TEMP%\%USERNAME%-ucs-school-netlogon.log for later analysis.

Please note: the UCR variable ucsschool/import/set/netlogon/script/path on the Domaincontroller Master only specifies the name of the netlogon script that is stored upon user creation at the user LDAP object. It does not alter/affect existing users or the behaviour of UCS@school slaves.

Mastodon