home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Special / chip-cd_2001_spec_05.zip / spec_05 / apps / cconnect / CCLogoff.vbs next >
Text File  |  1999-08-24  |  3KB  |  67 lines

  1. '********************************************************************
  2. '*
  3. '* File:           CCLogoff.vbs
  4. '* Created:        August 1999
  5. '* Version:        1.0
  6. '* Written By:     Amir Littman
  7. '*
  8. '*  Main Function:  Track Con-Current Connections
  9. '*
  10. '* Copyright (C) 1999 Microsoft Corporation
  11. '*
  12. '********************************************************************
  13.  
  14.  
  15. Set objNet = WScript.CreateObject("WScript.Network")
  16. Set WshShell = WScript.CreateObject("WScript.Shell")
  17. Set WshSysEnv = WshShell.Environment("PROCESS")
  18.  
  19. On error resume next
  20. ' Gather EventServer Name
  21.    evntserver = WshShell.RegRead("HKCU\Software\Microsoft\CConnect\EvntServer")
  22.         if err then
  23.               evntServer = ""
  24.        End if
  25.  
  26. ' Gather SQL Credentials from the reginstry
  27.  On error resume next
  28.   strSQLServerName = WshShell.RegRead("HKCU\Software\Microsoft\CConnect\SQLSERVER") 'If this fails, they will be prompted for the SQL connection info
  29.   strUserName = WshShell.RegRead("HKCU\Software\Microsoft\CConnect\SQLUSER")
  30.   strPassword = WshShell.RegRead("HKCU\Software\Microsoft\CConnect\SQLPASSWORD")
  31.         if err then
  32.               WshShell.LogEvent 1, "CConnect Failed to Start for user " & objNet.UserName & " due to " & Err.Description, EvntServer
  33.           wscript.quit
  34.        End if
  35.  
  36. 'Start SQL Connection
  37. On error resume next
  38.  Set objDBConnection = WScript.CreateObject("ADODB.Connection")
  39.   Set RS = WScript.CreateObject("ADODB.Recordset")
  40.   objDBConnection.open "DRIVER=SQL Server;UID=" + strUserName + ";Password=" + strPassword + ";SERVER=" +strSQLServerName
  41.  
  42.        if err then
  43.               WshShell.LogEvent 1, "CConnect Failed to Start for user " & objNet.UserName & " due to " & Err.Description, EvntServer
  44.           wscript.quit
  45.        End if
  46.  
  47.  
  48.  Call DropObjects()
  49.  
  50.   WshShell.LogEvent 0, "CConnect successfully removed user objects for user " & objNet.UserName, EvntServer
  51.  
  52. ' Remove the Objects from the Database
  53.  
  54.  Public Sub DropObjects()
  55. On Error Resume Next
  56.       SQLQuery1 = ""
  57.       SQLQuery1 = SQLQuery1 & " delete from SYSIAD"
  58.       SQLQuery1 = SQLQuery1 & " where username='" & objNet.UserName & "'"
  59.       SQLQuery1 = SQLQuery1 & " and computername='" & objNet.ComputerName & "'"
  60.       SQLQuery1 = SQLQuery1 & " and logonserver='" & WshSysEnv("LOGONSERVER") & "'"
  61.       Set RSSYSIAD = objDBConnection.Execute(SQLQuery1)
  62.              if err then
  63.                   WshShell.LogEvent 1, "CConnect (CCLogoff.VBS) Failed to Quit for user " & objNet.UserName & " due to " & Err.Description, EvntServer
  64.             wscript.quit
  65.              End if
  66.  
  67.   End Sub