home *** CD-ROM | disk | FTP | other *** search
- '********************************************************************
- '*
- '* File: CCLogoff.vbs
- '* Created: August 1999
- '* Version: 1.0
- '* Written By: Amir Littman
- '*
- '* Main Function: Track Con-Current Connections
- '*
- '* Copyright (C) 1999 Microsoft Corporation
- '*
- '********************************************************************
-
-
- Set objNet = WScript.CreateObject("WScript.Network")
- Set WshShell = WScript.CreateObject("WScript.Shell")
- Set WshSysEnv = WshShell.Environment("PROCESS")
-
- On error resume next
- ' Gather EventServer Name
- evntserver = WshShell.RegRead("HKCU\Software\Microsoft\CConnect\EvntServer")
- if err then
- evntServer = ""
- End if
-
- ' Gather SQL Credentials from the reginstry
- On error resume next
- strSQLServerName = WshShell.RegRead("HKCU\Software\Microsoft\CConnect\SQLSERVER") 'If this fails, they will be prompted for the SQL connection info
- strUserName = WshShell.RegRead("HKCU\Software\Microsoft\CConnect\SQLUSER")
- strPassword = WshShell.RegRead("HKCU\Software\Microsoft\CConnect\SQLPASSWORD")
- if err then
- WshShell.LogEvent 1, "CConnect Failed to Start for user " & objNet.UserName & " due to " & Err.Description, EvntServer
- wscript.quit
- End if
-
- 'Start SQL Connection
- On error resume next
- Set objDBConnection = WScript.CreateObject("ADODB.Connection")
- Set RS = WScript.CreateObject("ADODB.Recordset")
- objDBConnection.open "DRIVER=SQL Server;UID=" + strUserName + ";Password=" + strPassword + ";SERVER=" +strSQLServerName
-
- if err then
- WshShell.LogEvent 1, "CConnect Failed to Start for user " & objNet.UserName & " due to " & Err.Description, EvntServer
- wscript.quit
- End if
-
-
- Call DropObjects()
-
- WshShell.LogEvent 0, "CConnect successfully removed user objects for user " & objNet.UserName, EvntServer
-
- ' Remove the Objects from the Database
-
- Public Sub DropObjects()
- On Error Resume Next
- SQLQuery1 = ""
- SQLQuery1 = SQLQuery1 & " delete from SYSIAD"
- SQLQuery1 = SQLQuery1 & " where username='" & objNet.UserName & "'"
- SQLQuery1 = SQLQuery1 & " and computername='" & objNet.ComputerName & "'"
- SQLQuery1 = SQLQuery1 & " and logonserver='" & WshSysEnv("LOGONSERVER") & "'"
- Set RSSYSIAD = objDBConnection.Execute(SQLQuery1)
- if err then
- WshShell.LogEvent 1, "CConnect (CCLogoff.VBS) Failed to Quit for user " & objNet.UserName & " due to " & Err.Description, EvntServer
- wscript.quit
- End if
-
- End Sub