home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / CHIPCD_3_98.iso / software / testsoft / exchange / webdata / global.asa < prev   
Text File  |  1997-08-25  |  5KB  |  170 lines

  1. '  Microsoft Outlook Web Access
  2. '  Global.asa
  3. '  Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.
  4.  
  5. '  WARNING! This is an unlocalised file.  No locale specific 
  6. '  strings, formats, etc. can be used here.
  7.  
  8. '  NOTE: This file does not include CONSTANT.INC. Any changes made to
  9. '  Application and Session variable names, etc. in CONSTANT.INC must be
  10. '  mirrored here.
  11.  
  12. <SCRIPT LANGUAGE=VBScript RUNAT=Server> 
  13. Sub Application_OnStart
  14.  
  15.     On Error Resume Next
  16.  
  17.     Set objRenderApp = Server.CreateObject("AMHTML.Application")
  18.     If Err = 0 Then
  19.         Set Application("RenderApplication") = objRenderApp
  20.  
  21.         ' for debugging only
  22.         Application("startupSID") = objRenderApp.SecurityID
  23.     
  24.         ' Load Registry Configuration Data
  25.         objRenderApp.LoadConfiguration 1, _
  26.             "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MSExchangeWeb\Parameters"
  27.         If Err = 0 Then
  28.             bstrVirtRoot = "/exchange"
  29.  
  30.             'Set up virtual root and message class formats
  31.             objRenderApp.VirtualRoot = bstrVirtRoot
  32.             objRenderApp.FormsRoot   = Server.MapPath(bstrVirtRoot) & "\usa"
  33.         Else
  34.             Application("startupFatal") = Err.Number
  35.             'Failed to read registry
  36.             Application("startupFatalDescription") = "1010: " & Err.Description
  37.         End If
  38.     Else
  39.         Application("startupFatal") = Err.Number
  40.         'Failed to create application object
  41.         Application("startupFatalDescription") = "1011: " & Err.Description
  42.     End If
  43.  
  44.     Application("hImp") = 0
  45.     
  46.     Err.Clear
  47.     
  48. End Sub 
  49. </SCRIPT> 
  50.  
  51.  
  52. <SCRIPT LANGUAGE=VBScript RUNAT=Server> 
  53. Sub Application_OnEnd
  54.  
  55.     Set Application("RenderApplication") = Nothing
  56.  
  57. End Sub
  58. </SCRIPT> 
  59.  
  60.  
  61. <SCRIPT LANGUAGE=VBScript RUNAT=Server> 
  62. Sub Session_OnStart
  63.  
  64.     On Error Resume Next
  65.     Dim objIDCache
  66.     Set objIDCache = CreateObject("Scripting.Dictionary")
  67.     Set Session("IDCache") = objIDCache
  68.     Session("hImp") = 0
  69.     Session("URLRequested") = Null
  70.     Session("fPublicFormats") = False
  71.     Session("fPrivateFormats") = False
  72.  
  73.     Set objRenderApp = Application("RenderApplication")
  74.     If Not objRenderApp Is Nothing Then
  75.         'Load DSA Configuration Data
  76.         objRenderApp.LoadConfiguration 2, ""
  77.  
  78.         If Err <> 0 Then
  79.             Application("startupFatal") = Err.Number
  80.             'Failed to read DS configuration
  81.             Application("startupFatalDescription") = "1012: " & Err.Description
  82.         End If
  83.     Else
  84.         Application("startupFatal") = Err.Number
  85.         
  86.         'Failed to retrieve RenderApplication from Application object
  87.         Application("startupFatalDescription") = "1013: " & Err.Description
  88.     End If
  89. End Sub 
  90. </SCRIPT> 
  91.  
  92.  
  93. <SCRIPT LANGUAGE=VBScript RUNAT=Server> 
  94. Sub Session_OnEnd
  95.  
  96.     On Error Resume Next
  97.  
  98.     set objRenderApp = Application("RenderApplication")
  99.     fRevert = FALSE
  100.  
  101.     hImp = Session("hImp")
  102.  
  103.     fOk = 1
  104.     If Not IsEmpty(hImp) Then
  105.         fOk = objRenderApp.Impersonate(hImp)
  106.     End If
  107.  
  108.     If fOk = 1 Then
  109.         ' Do our cleanup
  110.         
  111.         Set objCacheID =  Session("IDCache")
  112.        
  113.                 
  114.         rgObjectIDs = objCacheID.Items
  115.                
  116.               
  117.         For i = Lbound(rgObjectIDs) to Ubound(rgObjectIDs)
  118.                 
  119.             Set Session(rgObjectIDs(i)) = Nothing
  120.        
  121.         Next
  122.                 
  123.         Set Session("IDCache") = Nothing        
  124.         Set Session("URLRequested") = Nothing
  125.         Set Session("AMRenderObject") = Nothing
  126.         Set Session("AMRenderMessage") = Nothing
  127.         Set Session("AMRenderFolder") = Nothing
  128.         Set Session("AMRenderRecipients") = Nothing
  129.         Set Session("AMRenderAddressContainer") = Nothing
  130.         Set Session("AMRenderAddressEntry") = Nothing
  131.         Set Session("AMRenderHierarchy") = Nothing
  132.         Set Session("AMRenderCalendar") = Nothing
  133.  
  134.         Set Session("AMPrivateStore") = Nothing
  135.         Set Session("AMPublicStore") = Nothing
  136.         Set Session("AMThisFolderLink") = Nothing
  137.         
  138.         Set Session("AMPublicStoreID") = Nothing
  139.         Set Session("AMPublicStoreEntryID") = Nothing
  140.         Set Session("AMPublicStoreRootID") = Nothing
  141.         Set Session("AMDeletedItemsID") = Nothing
  142.  
  143.         Set Session("CURRENT_FOLDER") = Nothing
  144.         Set Session("CURRENT_HIERARCHY") = Nothing
  145.         Set Session("CURRENT_CONTENTS") = Nothing
  146.         Set Session("CURRENT_INDEX") = Nothing
  147.         Set Session("CURRENT_COUNT") = Nothing
  148.         Set Session("CURRENT_PAGES") = Nothing
  149.         Set Session("CURRENT_ROWS") = Nothing
  150.         Set Session("CURRENT_VIEW") = Nothing
  151.         Set Session("CURRENT_PAGE") = Nothing
  152.         Set Session("CURRENT_MESSAGE") = Nothing
  153.  
  154.         Set objOMSession = Session("AMAuthSession")
  155.         If Not objOMSession Is Nothing Then
  156.             Set Session("AMAuthSession") = Nothing
  157.             objOMSession.Logoff
  158.             Set objOMSession = Nothing
  159.         End If
  160.  
  161.         If Not IsEmpty(hImp) Then
  162.             Set Session("hImp") = Nothing
  163.             objRenderApp.CloseSysHandle(hImp)
  164.         End If
  165.     
  166.         Set Session("AMAuthenticated") = Nothing
  167.     End If
  168.     
  169. End Sub
  170. </SCRIPT>