WshShell.LogEvent 1, "CConnect Failed to Start for user " & objNet.UserName & " due to " & Err.Description, EvntServer
wscript.quit
End if
' Get Current User Count
NumberOfConnections = GetUserCount()
' Determine if the current Computer is matches the one currently in the database
If CurrentComputer() = True Then
WshShell.LogEvent 2, "User " & objNet.UserName & " has logged into a computer whose previous information existed in the SQL Server. This can only happen if the UserName and ComputerName matched the objects in the SQL Server", EvntServer
End If
' Check if the User Should be logged off
If NumberOfConnections >= ConConnection Then
WshShell.LogEvent 0, "User " & objNet.UserName & " has reached thier concurrent connection limitation. The ConCurrent Connection number is set to " & NumberOfConnections, EvntServer
WshShell.LogEvent 0, "User " & objNet.UserName & " has been successfully logged off.", evntserver
' Log the User Off
For Each os In GetObject("winmgmts:{impersonationLevel=impersonate,(shutdown,remoteshutdown)}!//" + objNet.ComputerName).InstancesOf("Win32_OperatingSystem")
retCode = os.Win32Shutdown(4, 0)
Next
Wscript.quit
End If
call AddUsers()
WshShell.LogEvent 0, "CConnect.vbs successfully ran for user " & objNet.UserName & " on computer " & objNet.computername, EvntServer