% @Language=VbScript%>
<% Option Explicit %>
<% '----------------------------------------------------------------------------
' nicRename_prop.asp: change the connecion name
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' Date Description
'28-Feb-01 Creation date
'09-Mar-01 Modified date
'-----------------------------------------------------------------------------
%>
<%
'-------------------------------------------------------------------------
' Global Variables
'-------------------------------------------------------------------------
Dim G_objService 'Object to SWBEM service
Dim G_strConnName 'Connection name
Dim G_intAdapterID 'Adapter ID
Dim page 'Variable that receives the output page object when
'creating a page
Dim rc 'Return value for CreatePage
'Create property page
rc=SA_CreatePage(L_RENAMETASKTITLE_TEXT,"",PT_PROPERTY,page)
'Serve the page
If(rc=0) then
SA_ShowPage(Page)
End if
'-------------------------------------------------------------------------
'Function: OnInitPage()
'Description: Called to signal first time processing for this page.
' Use this method to do first time initialization tasks
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: None
'-------------------------------------------------------------------------
Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
G_strConnName = GetConnectionName() ' Gets the connection name
OnInitPage = True
End Function
'-------------------------------------------------------------------------
'Function: OnServePropertyPage()
'Description: Called when the page needs to be served.Use this
' method to serve content
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: G_*,L_*
'-------------------------------------------------------------------------
Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
Call ServeCommonJavaScript()
%>
<%=G_strConnName%>
<%=L_CONNNAME_TEXT%>
<%
OnServePropertyPage = True
End Function
'-------------------------------------------------------------------------
'Function: OnPostBackPage()
'Description: Called to signal that the page has been posted-back.
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: None
'-------------------------------------------------------------------------
Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
G_strConnName = Request.Form("hdnConnectionName")
OnPostBackPage = True
End Function
'-------------------------------------------------------------------------
'Function: OnSubmitPage()
'Description: Called when the page has been submitted for processing.
' Use this method to process the submit request.
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: None
'-------------------------------------------------------------------------
Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
Dim strConnName 'to hold connection name
Dim strAdapterID 'to hold adapter ID
strConnName = Request.Form("hdnConnectionName")
strAdapterID = Request.Form("hdnAdapterID")
OnSubmitPage = SetConnectionName(strAdapterID,strConnName)
End Function
'-------------------------------------------------------------------------
'Function: OnClosePage()
'Description: Called when the page is about closed.Use this method
' to perform clean-up processing
'Input Variables: PageIn,EventArg
'Output Variables: PageIn,EventArg
'Returns: True/False
'Global Variables: None
'-------------------------------------------------------------------------
Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
OnClosePage = TRUE
End Function
'-------------------------------------------------------------------------
'Function: ServeCommonJavaScript
'Description: Serves in initialiging the values,setting the form
' data and validating the form values
'Input Variables: None
'Output Variables: None
'Returns: True/False
'Global Variables: None
'-------------------------------------------------------------------------
Function ServeCommonJavaScript()
Err.Clear
On Error Resume Next
%>
<%
End Function
'-------------------------------------------------------------------------
'Function: GetConnectionName
'Description: gets the connection name
'Input Variables: None
'Output Variables: None
'Returns: None
'Global Variables: G_strConnName, G_intAdapterID
'-------------------------------------------------------------------------
Function GetConnectionName()
Dim itemCount 'holds the item count
Dim x 'holds count for loop
Dim itemKey 'holds the item selected from OTS
itemCount = OTS_GetTableSelectionCount("")
For x = 1 to itemCount
If ( OTS_GetTableSelection("", x, itemKey) ) Then
G_intAdapterID = itemKey
GetConnectionName = GetNicName(itemKey) 'gets the NIC card name
End If
Next
End Function
'-------------------------------------------------------------------------
'Function: SetConnectionName
'Description: sets the connection name
'Input Variables: Adapter ID,Connection Name
'Output Variables: None
'Returns: Boolean
'Global Variables: None
'-------------------------------------------------------------------------
Function SetConnectionName(strAdapterID,strConnName)
Err.Clear
on error resume next
Dim objService 'holds connection object
Dim objNICAdapterCollection 'holds adapter collection
Dim objNICAdapter 'holds each instance of the collection
Dim intRetVal 'holds return value
Dim objNicName 'holds nicname object
Set objService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
Set objNICAdapterCollection = objService.ExecQuery("SELECT * from Win32_NetworkAdapter where DeviceID="+CStr(strAdapterID))
For each objNICAdapter in objNICAdapterCollection
Set objNicName = Server.CreateObject("Microsoft.NAS.NicName")
intRetVal = objNicName.Set(objNICAdapter.PNPDeviceID,strConnName)
if Err.number <> 0 then
SA_SetErrMsg L_UNABLETOSETCONNNAME_ERRORMESSAGE & "(" & Hex(Err.Number) & ")"
SetConnectionName = false
exit function
end if
Next
SetConnectionName = true
'Release the objects
Set objNicName = nothing
Set objNICAdapterCollection = nothing
set objService = nothing
End Function
%>