<% '================================================== ' Microsoft Server Appliance ' ' Serves task wizard/propsheet ' ' Copyright (c) Microsoft Corporation. All rights reserved. '================================================== %> <% ' Copyright (c) Microsoft Corporation. All rights reserved. 'Task module-level variables Dim mstrPageName ' used as page identifier, e.g., "Intro" Dim mstrTaskTitle ' e.g., "Add User" Dim mstrWizPageTitle ' e.g., "Add User" Dim mstrPageTitle ' e.g., "Username and Password" Dim mstrTaskType ' "wizard", "prop" Dim mstrWizardPageType ' "intro", "standard", "finish" Dim mstrMethod ' "BACK", "NEXT", "FINISH", etc Dim mstrReturnURL ' URL to return to after ending task Dim mstrFrmwrkFormStrings ' framework form values, list of strings to exclude Dim mstrIconPath ' image for upper right header Dim mstrPanelPath ' image for left panel of intro and finish pg ' Dim mintElementIndex ' index of embedded wizard page (0 - n, -1 = no extensions) ' Dim mintElementCount ' number of embedded pages in wizard Dim mstrErrMsg ' used by SetErrMsg and GetErrMsg Dim mstrAsyncTaskName ' Task EXE name - empty if task is synchronous Dim mstrTabPropSheetTabs() Dim mintTabSelected Dim intCaptionIDTask Dim gm_sPageTitle ' SAK 2.0 Page Title variable Dim gm_sBannerText ' SAK 2.0 Banner Text mintTabSelected = CInt(Request.Form("TabSelected")) Set objLocMgr = Server.CreateObject("ServerAppliance.LocalizationManager") strSourceName = "sakitmsg.dll" If Err.number <> 0 Then If ( Err.number = &H800401F3 ) Then Response.Write("

Problem:

") Response.Write("Unable to locate a software component on the Server Appliance.
") Response.Write("The Server Appliance core software components do not appear to be installed correctly.") Else Response.Write("

Problem:

") Response.Write("Server.CreateObject(ServerAppliance.LocalizationManager) failed with error code: " + CStr(Hex(Err.Number)) + " " + Err.Description) End If Call SA_TraceOut("SH_TASK", "Server.CreateObject(ServerAppliance.LocalizationManager) failed with error code: " + CStr(Hex(Err.Number)) ) Response.End End If '----------------------------------------------------- 'START of localization content Dim L_BACK_BUTTON Dim L_BACKIE_BUTTON Dim L_NEXT_BUTTON Dim L_NEXTIE_BUTTON Dim L_FINISH_BUTTON Dim L_OK_BUTTON Dim L_CANCEL_BUTTON Dim L_BACK_ACCESSKEY Dim L_NEXT_ACCESSKEY Dim L_FINISH_ACCESSKEY L_BACK_BUTTON = objLocMgr.GetString(strSourceName, "&H4001001C",varReplacementStrings) L_BACKIE_BUTTON = objLocMgr.GetString(strSourceName, "&H4001001D",varReplacementStrings) L_NEXT_BUTTON = objLocMgr.GetString(strSourceName, "&H4001001E",varReplacementStrings) L_NEXTIE_BUTTON = objLocMgr.GetString(strSourceName, "&H4001001F",varReplacementStrings) L_FINISH_BUTTON = objLocMgr.GetString(strSourceName, "&H40010020",varReplacementStrings) L_OK_BUTTON = objLocMgr.GetString(strSourceName, "&H40010021",varReplacementStrings) L_CANCEL_BUTTON = objLocMgr.GetString(strSourceName, "&H40010022",varReplacementStrings) L_BACK_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H40010039",varReplacementStrings) L_NEXT_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H4001003A",varReplacementStrings) L_FINISH_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H4001003B",varReplacementStrings) 'End of localization content '----------------------------------------------------- 'Task Constants Const PROPERTY_TASK_NICE_NAME = "TaskNiceName" Const PROPERTY_TASK_URL = "TaskURL" Const WBEM_E_PROVIDER_NOT_CAPABLE = "&H80041024" Const WIZARD_TASK = "wizard" Const PROPSHEET_TASK = "prop" Const TAB_PROPSHEET = "TabPropSheet" Const BODY_PAGE = "standard" Const INTRO_PAGE = "intro" Const FINISH_PAGE = "finish" Const BACK_METHOD = "BACK" Const NEXT_METHOD = "NEXT" Const FINISH_METHOD = "FINISH" Const CANCEL_METHOD = "CANCEL" 'Get standard task values and initialize mstrMethod = Request.Form("Method") mstrPageName = Request("PageName") mstrReturnURL = Request("ReturnURL") If mstrReturnURL = "" Then mstrReturnURL = GetCurrentPrimaryTabURL() End If ' mintElementIndex = -1 ' set later in ServeWizardEmbeds() ' mintElementCount = Request.Form("EmbedPageCount") ' get previous value, if any ' If mintElementCount="" Then ' mintElementCount=0 ' End If mstrFrmwrkFormStrings = "!method!pagename!pagetype!tasktype!returnurl!embedpageindex!embedpagecount!commonvalues!embedvalues0!embedvalues1!embedvalues2!embedvalues3!embedvalues4!" Set objLocMgr = Server.CreateObject("ServerAppliance.LocalizationManager") '---------------------------------------------------------------------------- ' ' Function : SA_IsAsyncTaskBusy ' ' Synopsis : Determine if the async task is currently being executed ' ' Arguments: TaskName(IN) - async task name ' ' Returns : true/false ' '---------------------------------------------------------------------------- Public Function SA_IsAsyncTaskBusy(ByVal TaskName) SA_IsAsyncTaskBusy = AsyncTaskBusy(TaskName) End Function Private Function AsyncTaskBusy(ByVal TaskName) Dim objTask Set objTask = GetObject("WINMGMTS:" & SA_GetWMIConnectionAttributes() &"!\\" & GetServerName & "\root\cimv2:Microsoft_SA_Task.TaskName=" & Chr(34) & TaskName & Chr(34) ) If ( Err.Number <> 0 ) Then Call SA_TraceOut(SA_GetScriptFileName(), "Get Microsoft_SA_Task failed: " + CStr(Hex(Err.Number)) + " " + Err.Description) Exit Function End If If Not objTask.IsAvailable Then AsyncTaskBusy = True Else AsyncTaskBusy = False End If Set objTask = Nothing End Function Public Function SAI_GetBannerText() If ( SA_GetVersion() < gc_V2 ) Then SAI_GetBannerText = mstrTaskTitle Else SAI_GetBannerText = gm_sBannerText End If End Function Public Function SAI_GetPageTitle() If ( SA_GetVersion() < gc_V2 ) Then SAI_GetPageTitle = mstrTaskTitle Else SAI_GetPageTitle = gm_sPageTitle End If End Function '---------------------------------------------------------------------------- ' ' Function : SA_SetErrMsg ' ' Synopsis : Sets framework error message string ' ' Arguments: Message(IN) - error message text ' ' Returns : Nothing ' '---------------------------------------------------------------------------- Public Function SA_SetErrMsg(ByVal Message) mstrErrMsg = Message End Function Private Function SetErrMsg(ByVal Message) mstrErrMsg = Message End Function '---------------------------------------------------------------------------- ' ' Function : GetErrMsg ' ' Synopsis : Gets the current framework error message string ' ' Arguments: None ' ' Returns : None ' '---------------------------------------------------------------------------- Private Function GetErrMsg() GetErrMsg = mstrErrMsg End Function '---------------------------------------------------------------------------- ' ' Function : ServeTaskHeader ' ' Synopsis : Serve the task header based on page type ' ' Arguments: None ' ' Returns : None ' '---------------------------------------------------------------------------- Function ServeTaskHeader() Dim objItem Dim i Dim intSlack Response.Buffer = True %> <%=Server.HTMLEncode(SAI_GetPageTitle())%> <% If (mstrTaskType = PROPSHEET_TASK) then If ( SA_GetVersion() < gc_V2 ) Then Call SA_EmitAdditionalStyleSheetReferences("") End If End If %> <% If (mstrTaskType= TAB_PROPSHEET) then If ( SA_GetVersion() < gc_V2 ) Then Call ServeTabBar() End If End If If( (mstrTaskType="wizard") AND (mstrWizardPageType="intro" OR mstrWizardPageType="finish")) Then %>
<% Call ServeStandardHeaderBar(SAI_GetBannerText(), mstrIconPath) %>
 
<%=Server.HTMLEncode(mstrWizPageTitle)%>

<% Else If (mstrTaskType= TAB_PROPSHEET) Then %>
<% Call ServeStandardHeaderBar(SAI_GetBannerText(), mstrIconPath) %>
<% If IsIE() Then %> <% Else %>
<% End If %>
<% intSlack = UBound(mstrTabPropSheetTabs) - LBound(mstrTabPropSheetTabs) intSlack = 100 - (2 * intSlack) If intSlack <= 0 Then intSlack = 5 End If For i = LBound(mstrTabPRopSheetTabs) to UBound(mstrTabPropSheetTabs)-1 Response.Write(""+vbCrLf) If mintTabSelected=i Then Response.Write(""+vbCrLf) Response.Write(""+vbCrLf) Next %>
"+vbCrLf) Else Response.Write(""+vbCrLf) End If 'Response.Write(""+vbCrLf) Response.Write("") If mintTabSelected=i Then Response.Write("") Else Response.Write("") End If Response.Write(Server.HTMLEncode(mstrTabPropSheetTabs(i))) Response.Write("") Response.Write(""+vbCrLf) Response.Write("
 
<% If IsIE() Then %> <% Else %>
<% End If %>
<% ' ' Wizard Page Type ' ElseIf (mstrTaskType="wizard") Then %>
<% Call ServeStandardHeaderBar(SAI_GetBannerText(), mstrIconPath) %>
<%=Server.HTMLEncode(mstrWizPageTitle)%>
<% ' ' Property page ' Else If ( SA_GetVersion() < gc_V2 ) Then Call SA_ServeStatusBar() Call ServeTabBar() End If %> <% End If %> <% If (mstrTaskType= TAB_PROPSHEET) then %>
<% Call ServeStandardHeaderBar(SAI_GetBannerText(), mstrIconPath) %>
<% =mstrPageTitle %>
") If GetErrMsg <> "" Then ErrMessage = "
<% End If End If %>
<% ServeTaskHeader = True End Function '---------------------------------------------------------------------------- ' ' Function : ServeTaskFooter ' ' Synopsis : Serve the task footer (navigation buttons & error div) ' Note: The function relies on the following module-level variables: ' mstrTaskType - prop wizard ' mstrWizardPageType - standard intro finish failure ' ' Arguments: None ' ' Returns : None ' '---------------------------------------------------------------------------- Function ServeTaskFooter() dim ErrMessage Response.write("
" & GetErrMsg & "
" SetErrMsg "" else ErrMessage ="" End If If( (mstrWizardPageType<>"intro_xxx") AND (mstrWizardPageType<>"finish_zzzz") ) Then If (IsIE()) Then %>
<%=ErrMessage%>
<% Else %>
<% End If %> <% End If %> <% If Not IsIE() Then %> <%=ErrMessage%> <% End If %> <% Response.Write "" End Function '---------------------------------------------------------------------------- ' ' Function : ServeFailurePage ' ' Synopsis : Serve the page which redirects the browser to the err_view.asp ' failure page ' ' Arguments: Message(IN) - message to be displayed by err_view.asp ' intTab(IN) - Tab to be highlighted by err_view.asp ' ' Returns : None ' '---------------------------------------------------------------------------- Function ServeFailurePage(Message, intTab) Call SA_ServeFailurePage(Message) Exit Function End Function '---------------------------------------------------------------------------- ' ' Function : ServeClose ' ' Synopsis : Redirect user to the page from which the wizard was launched ' ' Arguments: None ' ' Returns : None ' '---------------------------------------------------------------------------- Sub ServeClose %>   <% End Sub '---------------------------------------------------------------------------- ' ' Function SA_ExecuteTask ' ' Synopsis Executes an Appliance Task backend object. Normally, backend Tasks ' are executed synchronously. The bExecuteAsync parameter allows overriding ' the default behavior. ' ' If the oTaskContext object has not been created and initialized, this function ' will create a default oTaskContext and will initialize it by creating task ' parameters using all input form fields from the current Request object. This ' makes it easy to pass an HTML form to the appliance task. ' ' If an error is encountered the really is no reasonable recovery that a ' scripting client can make. ' ' Arguments [in] TaskName Name of task to execute ' ' [in] bExecuteAsync Flag indicating if Task should be executed ' synchronisly (default, FALSE) or async (TRUE). ' ' [in/out] oTaskContext TaskContext object for the appliance task. The TaskContext ' object can be used to pass input arguments to the Task. ' ' Returns: ' SA_NO_ERROR ' The call succeeded, no errors occured ' ' SA_ERROR_CREATE_OBJECT_FAILED ' Unable to create one of the required backend objects, this indicates that either the ' components were not installed correctly or that the Appliance Manager service ' is not running. ' ' SA_ERROR_INITIALIZE_OBJECT_FAILED ' The Task object encountered an unrecoverable error during it's internal initialization. ' This is probably not recoverable and likely indicates a problem with either the expected ' inputs or the current state of the Appliance task. ' ' All other cases ' The HRESULT return value recieved from the Task ' ' ' Example 1 - Create TaskContext and set input parameters: ' Dim oTaskContext ' Dim rc ' ' Set oTaskContext = CreateObject("Taskctx.TaskContext") ' If Err.Number <> 0 Then ' ' Handle the error ' Exit Function ' End If ' ' Call oTaskContext.SetParameter("Method Name", strMethodName) ' Call oTaskContext.SetParameter("LanguageID", strLANGID) ' Call oTaskContext.SetParameter("AutoConfig", "y") ' ' rc = SA_ExecuteTask("ChangeLanguage", FALSE, oTaskContext) ' If ( rc <> SA_NO_ERROR ) Then ' ' Handle the error ' End If ' ' Example 2 - Use the current input form (Request object) as input to the task ' Dim rc ' Dim oTaskContext ' Set oTaskContext = nothing ' rc = SA_ExecuteTask("MyApplianceTask", FALSE, oTaskContext) ' If ( rc <> SA_NO_ERROR ) Then ' ' Handle the error ' End If '---------------------------------------------------------------------------- ' ' Following signature has been deprecated in SAK 2.0 - See SA_ExecuteTask Private Function ExecuteTask(ByVal TaskName, ByRef oTaskContext) ExecuteTask = SA_ExecuteTask(TaskName, FALSE, oTaskContext) End Function Public Function SA_ExecuteTask(ByVal TaskName, ByVal bExecuteAsync, ByRef oTaskContext) on error resume next Err.Clear Dim objAS Dim objValue Dim objElementCol Dim objElement Dim oField Dim rc SA_ExecuteTask = SA_NO_ERROR ' ' Create default TaskContext object if necessary ' If (NOT IsObject(oTaskContext)) Then Call SA_TraceOut("SH_TASK", "SA_ExecuteTask - Creating default TaskContext") Set oTaskContext = Server.CreateObject("Taskctx.TaskContext") If (Err.Number <> 0) Then Call SA_TraceErrorOut(SA_GetScriptFileName(), "Server.CreateObject(Taskctx.TaskContext) failed: " + CStr(Hex(Err.Number)) + " " + Err.Description) SA_ExecuteTask = SA_ERROR_CREATE_OBJECT_FAILED Exit Function End If ' ' Set default value of parameters For Each oField in Request.Form oTaskContext.SetParameter oField, CStr(Request.Form(oField)) Next End If ' ' Get interface to ApplianceServices interface, the object that allows us to invoke tasks Set objAS = Server.CreateObject("Appsrvcs.ApplianceServices") If (Err.Number <> 0) Then Call SA_TraceErrorOut(SA_GetScriptFileName(), "Server.CreateObject(Appsrvcs.ApplianceServices) failed: " + CStr(Hex(Err.Number)) + " " + Err.Description) SA_ExecuteTask = SA_ERROR_CREATE_OBJECT_FAILED Exit Function End If ' ' Initialize ApplianceServices object objAS.Initialize() If (Err.Number <> 0) Then Call SA_TraceErrorOut(SA_GetScriptFileName(), "objAS.Initialize() for object Appsrvcs.ApplianceServices failed: " + CStr(Hex(Err.Number)) + " " + Err.Description) SA_ExecuteTask = SA_ERROR_INITIALIZE_OBJECT_FAILED Exit Function End If ' ' Initialize context parameters oTaskContext.SetParameter PROPERTY_TASK_NICE_NAME, mstrTaskTitle oTaskContext.SetParameter PROPERTY_TASK_URL, m_VirtualRoot + GetScriptPath() Err.Clear If ( TRUE = bExecuteAsync ) Then 'Call SA_TraceOut("SH_TASK", "Calling objAS.ExecuteTaskAsync("+TaskName+", oTaskContext)") Call objAS.ExecuteTaskAsync(TaskName, oTaskContext) Else 'Call SA_TraceOut("SH_TASK", "Calling objAS.ExecuteTask("+TaskName+", oTaskContext)") Call objAS.ExecuteTask(TaskName, oTaskContext) End If If ( Err.Number <> 0 ) Then SA_ExecuteTask = Err.Number Call SA_TraceErrorOut(SA_GetScriptFileName(), "Task execution returned failure code: " + CStr(Hex(Err.Number)) + " " + Err.Description) End If objAS.Shutdown() Err.Clear Set objAS = Nothing End Function Private Function SA_TaskToPageType() If ( mstrTaskType = "prop" ) Then SA_TaskToPageType = "Property Page" ElseIf ( mstrTaskType = TAB_PROPSHEET) Then SA_TaskToPageType = "Tabbed Property Page" ElseIf ( mstrTaskType = "wizard") Then SA_TaskToPageType = "Wizard Page" Else SA_TaskToPageType = "Unknown Page Type" End If End Function %>