|
|
|
Comparison scripts
This comparison script page shows how much scripting is required for a common task as
part of a Logon Script. When not using FastTrack Scripting Host, logon scripts are
usually made using VBScript and this page will compare typical use of these two.
In this example, we will produce the same result in VBScript
and FastTrack Scripting, which is testing if the user logging on is a member of a certain
group and connect a share in case the user is a member.
Note that the VBScript version is not checking for nested grouping, for instance if a user
is member of a SalesEurope group which again is a member of SalesStaff. The FastTrack
Script version will fully resolve all nestings, but the VBScript version would have to be
expanded with recusive code to resolve all nestings to produce the exact same functionality.
|
Related pages
|
Goes through the basics of the language.
|
|
Browse online documentation.
|
|
How to set up logon scripts with FastTrack Logon.
|
|
|
VBScript version
To determine if the user is a member of a group, we will assume there is an Active Directory
and use the LDAP provider, as this will require the least number of lines.
 |
If IsMember("SalesStaff") Then MapNetworkDrive "I:","\\AcmeServer\Sales"
Function IsMember(groupName)
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
''==== CONVERT GROUP NAME TO FULLY QUALIFIED NAME ====
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_NT4, WSHNetwork.UserDomain & "\" & groupName
strGroupDN = objTrans.Get(ADS_NAME_TYPE_1779)
strGroupDN = Replace(strGroupDN, "/", "\/")
''==== GET GROUP AND USER ====
Set objGroup = GetObject("LDAP://" & strGroupDN)
Set objADSysInfo = CreateObject("ADSystemInfo")
strUserDN = objADSysInfo.UserName
''==== DETERMINE MEMBERSHIP ====
If objGroup.IsMember("LDAP://" & strUserDN) Then
IsMember=True
Else
IsMember=False
End If
End function
Function MapNetworkDrive(letter, uncPath)
''==== DISCONNECT EXISTING DRIVE IF CONNECTED ====
Set objNetwork = CreateObject("WScript.Network")
Set objDrives = objNetwork.EnumNetworkDrives()
For objDrive = 0 To objDrives.Count - 1 Step 2
If objDrives.Item(objDrive) = letter Then
objNetwork.RemoveNetworkDrive letter, true
End If
Next
''==== MAP SHARE ====
objNetwork.MapNetworkDrive letter, uncPath, false
End function
|  |
FastTrack Script version
Using a FastTrack Script the same operation requires just one line. In case of an error,
the general error handler script (errorhandler.fsh) will be included and the script will continue.
 |
|
If UserIsMemberOf
SalesStaff Then ConnectShare
I:,\\AcmeServer\Sales
|  |
Performance note
The VBScript example will be slower and will stress your Active Directory, if there are many
computers in the network, as it will query your Active Directory over the network every time a user logs on.
The FastTrack Script version will query only against locally cached information, which the
WinLogon process has already retrieved from your domain controller.
|
Copyright 2005-2012 FastTrack Software
|
|
|
|
|
|
|