Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 67
Product
SessionPro
Version
1.x
Title
Global.asa file's Sub Session_OnEnd uses different security context than may be expected
Problem
Any calls made to a Session Pro object within your Global.asa file's Sub Session_OnEnd procedure will be using a local system account to do it's processing. Thus, any calls which require network access will likely fail. For instance, the following code will fail if the HKEY_LOCAL_MACHINE\Software\SMUM\XSession\Parameters\Root key is set to a network share:
Sub Session_OnEnd
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set a = fso.CreateTextFile("c:\temp\SessionTest1.txt", True)
	a.WriteLine("This is a test.")
	a.Close

	set SASession = Server.CreateObject("SoftArtisans.SASessionPro.1")
	SASession.Delete
	Set SASession = Nothing

	Set fso = CreateObject("Scripting.FileSystemObject")
	Set a = fso.CreateTextFile("c:\temp\SessionTest2.txt", True)
	a.WriteLine("This file will not exist unless you have version 1.23 or greater.")
	a.Close
	Set fso = Nothing       

End Sub
Solution
To work around this problem, arrange for the Global.asa's code to be firing under a different security context. This can be done using SoftArtisans FileManager utility. For example, you could change the above code to read as follows:
Sub Session_OnEnd
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set a = fso.CreateTextFile("c:\temp\SessionTest1.txt", True)
	a.WriteLine("This is a test.")
	a.Close

'       Create the SoftArtisans.FileManger object.
        Set oFileMan = Server.CreateObject("SoftArtisans.FileManager")

'       Use the LogonUser method to log on a user with domain rights.
        oFileMan.LogonUser "Domain","User","Password",2

	set SASession = Server.CreateObject("SoftArtisans.SASessionPro.1")
	SASession.Delete
	Set SASession = Nothing

	Set fso = CreateObject("Scripting.FileSystemObject")
	Set a = fso.CreateTextFile("c:\temp\SessionTest2.txt", True)
	a.WriteLine("This file will not exist unless you have version 1.23 or greater.")
	a.Close
	Set fso = Nothing       

'       Have the user context revert back to normal.
        oFileMan.RevertToSelf
        Set oFileMan = Nothing
End Sub
Note: The preceeding example will not work without SoftArtisans FileManager. An evaluation of FileManager may be downloaded from http://support.softartisans.com/evalindex.asp.
Created : 12/1/2002 12:00:00 AM (last modified : 9/18/2003 11:45:04 AM)
Rate this article!
Comments