26 Feb
Posted by Roberto as Scripts
This vbs script consist into two verifications to restrict access of users from internet in Citrix XenApp (Presentation Server/Metaframe) servers or Terminal Services, to be included in the session initialization. The idea of this script allow access from users from Internet just if they are in a specific Active Directory group.
In the first verification, the script checks if the current user belongs to a group called “Remote Workers. If yes, the script jumps to the end. If no, the script goes to the second verification.
The second verification sees if is possible to ping the user workstation from the server. If the ping replies, means that the user is using the local network, then the script jumps to the end. If the ping doesn’t reply, the script will understand that the user is trying to access from internet, them he will be logged off from the server.
See the flow below to see better how this script works:


And follow the script bellow:
On Error Resume Next
Dim group_validation, target, ping_result
Set objNetwork = CreateObject(”WScript.Network”)
set objShell = CreateObject(”WScript.Shell”)
Set objUser = GetObject(”WinNT://” & objNetwork.UserDomain & “/” & objNetwork.UserName)group_validation = false
For each oGroup in objUser.Groups
if instr(oGroup.Name,”Remote Workers”) then group_validation = true
NextIf group_validation = false then
strTarget = objShell.ExpandEnvironmentStrings(”%ClientName%”)
Set objExec = objShell.Exec(”ping -n 2 -w 1000 ” & strTarget)
ping_result = LCase(objExec.StdOut.ReadAll)If InStr(ping_result, “reply from”)=0 Then
msgbox “Access denied”
objShell.run(”logoff”)
End if
End If‘msgbox “done”
Things to consider when you are going to use this script:
RSS feed for comments on this post · TrackBack URI
Leave a reply