<%@Language=VbScript%> <% Option Explicit %> <% '------------------------------------------------------------------------- ' nicip_prop.asp : Page gets/sets the IP adresses along with ' GateWay Addresses ' ' Copyright (c) Microsoft Corporation. All rights reserved. ' ' Date Description ' 06-Mar-2001 Created date ' 10-Mar-2001 Modified date '------------------------------------------------------------------------- %> <% '------------------------------------------------------- ' Form Variables '------------------------------------------------------- Dim F_strIPAddress ' to hold IP address Dim F_strSubnetMask ' to hold subnet mask Dim F_nConnectionMetric ' to hold connection metric Dim F_strGatewayAddress ' to hold gateway address Dim F_strListIP ' to hold array of IP Dim F_strListGateway ' to hold array of Gateway Dim F_strRadIP ' to hold the radio button selected '------------------------------------------------------- ' Global Variables '------------------------------------------------------- Dim g_arrIPList ' List of IP Addresses Dim g_arrGATEWAYList ' List of Gateway Addresses Dim page ' to hold page object Dim blnDHCPEnabled ' to hold whether DHCP is enabled or not Dim g_strDeviceID ' to hold device ID Dim g_initialIPAddress Dim SOURCE_FILE SOURCE_FILE = SA_GetScriptFileName() Dim g_iTabGeneral ' to hold value of general page Dim g_iTabAdvanced ' to hold value of Advanced page Dim g_strTabValue ' to hold value of general tab Dim g_strAdvTabValue ' to hold value of Advanced tab Const G_CONST_REGISTRY_PATH ="SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces" '------------------------------------------------------- ' Entry point '------------------------------------------------------- ' Create a Property Page Call SA_CreatePage( L_TASKTITLE_TEXT, "", PT_TABBED, page ) Call SA_AddTabPage(page, L_GENERAL_TEXT, g_iTabGeneral) Call SA_AddTabPage(page, L_ADVANCED_TEXT, g_iTabAdvanced) ' Serve the page Call SA_ShowPage( page ) '------------------------------------------------------- ' Web Framework Event Handlers '------------------------------------------------------- '------------------------------------------------------------------------- '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 to indicate initialization was successful. FALSE to indicate ' errors. Returning FALSE will cause the page to be abandoned. 'Global Variables: None '------------------------------------------------------------------------- Public Function OnInitPage(ByRef PageIn, ByRef EventArg) Dim itemCount 'holds item count Dim x 'holds increment count for the loop Dim itemKey 'holds the item selected from the OTS page Call SA_TraceOut(SOURCE_FILE, "OnInitPage") itemCount = OTS_GetTableSelectionCount("") For x = 1 to itemCount If ( OTS_GetTableSelection("", x, itemKey) ) Then g_strDeviceID = itemKey ' to get the device ID Exit for End If Next OnInitPage = TRUE End Function '------------------------------------------------------------------------- 'Function: OnServeTabbedPropertyPage 'Description: Called when the page needs to be served.Use this ' method to serve content 'Input Variables: PageIn,EventArg, iTab,bIsVisible 'Output Variables: PageIn,EventArg 'Returns: TRUE to indicate not problems occured. FALSE to indicate errors. ' Returning FALSE will cause the page to be abandoned. 'Global Variables: SOURCE_FILE, g_* '------------------------------------------------------------------------- Public Function OnServeTabbedPropertyPage(ByRef PageIn, _ ByVal iTab, _ ByVal bIsVisible, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnServeTabbedPropertyPage") Select Case iTab Case g_iTabGeneral Call ServeTabGeneral(PageIn, bIsVisible) Case g_iTabAdvanced Call ServeTabAdvanced(PageIn, bIsVisible) Case Else Call SA_TraceErrorOut(SOURCE_FILE, "OnServeTabbedPropertyPage unrecognized tab id: " + CStr(iTab)) End Select OnServeTabbedPropertyPage = TRUE End Function '------------------------------------------------------------------------- 'Function: OnPostBackPage() 'Description: Called to signal a post-back. A post-back occurs as the user ' navigates through pages. This event should be used to save the ' state of the current page. 'Input Variables: PageIn,EventArg 'Output Variables: PageIn,EventArg 'Returns: True 'Global Variables: F_*,G_*,g_* '------------------------------------------------------------------------- Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnPostBackPage") g_strTabValue = Request.Form("hdnGeneralTabValue") g_strAdvTabValue = Request.Form("hdnAdvancedTabValue") g_strDeviceID = Request.Form("hdnDeviceID") g_initialIPAddress = Request.Form("hdnInitialIPValue") F_strRadIP = Request.Form("hdnRadIP") F_strListIP = Request.Form("hdnlstIP") F_strListGateway = Request.Form("hdnlstGATEWAY") F_strIPAddress = Request.Form("txtIP") F_strSubnetMask = Request.Form("txtMask") F_strGatewayAddress = Request.Form("txtGateway") F_nConnectionMetric = Request.Form("txtConnectionMetric") 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 if the submit was successful, FALSE to indicate error(s). ' Returning FALSE will cause the page to be served again using ' a call to OnServeTabbedPropertyPage. 'Global Variables: F_*, g_*, blnDHCPEnabled, '------------------------------------------------------------------------- Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage") 'checking whether DHCP is enabled If Ucase(Request.Form("radIP"))="IPDEFAULT" Then blnDHCPEnabled = TRUE Else blnDHCPEnabled = FALSE End If 'Set Individual NIC properties OnSubmitPage = setNIC() 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 to allow close, FALSE to prevent close. Returning FALSE ' will result in a call to OnServeTabbedPropertyPage. 'Global Variables: None '------------------------------------------------------------------------- Public Function OnClosePage(ByRef PageIn, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnClosePage") OnClosePage = TRUE End Function '------------------------------------------------------------------------- 'Function: ServeTabGeneral 'Description: Called when the general page needs to be served. 'Input Variables: PageIn,EventArg 'Output Variables: PageIn,EventArg 'Returns: SA_NO_ERROR 'Global Variables: SOURCE_FILE, g_*,F_* '------------------------------------------------------------------------- Private Function ServeTabGeneral(ByRef PageIn, ByVal bIsVisible) Call SA_TraceOut(SOURCE_FILE, "ServeTabGeneral(PageIn, bIsVisible="+ CStr(bIsVisible) + ")") If ( bIsVisible ) Then 'call the java script function Call ServeCommonJavaScript() Call ServeGeneralTabJavaScript() 'Serves UI for General tab Call ServeGeneralUI() Else Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") End If ServeTabGeneral = SA_NO_ERROR End Function '------------------------------------------------------------------------- 'Function: ServeTabAdvanced 'Description: Called when the Advanced page needs to be served. 'Input Variables: PageIn,EventArg 'Output Variables: PageIn,EventArg 'Returns: SA_NO_ERROR 'Global Variables: SOURCE_FILE, g_*,F_* '------------------------------------------------------------------------- Private Function ServeTabAdvanced(ByRef PageIn, ByVal bIsVisible) Call SA_TraceOut(SOURCE_FILE, "ServeTabAdvanced(PageIn, bIsVisible="+ CStr(bIsVisible) + ")") If ( bIsVisible ) Then 'Serve common javascript that is required for this page type. Call ServeCommonJavaScript() Call ServeAdvancedTabJavaScript() 'Serve UI for Advanced tab Call ServeAdvancedUI() Else Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") End If ServeTabAdvanced = SA_NO_ERROR End Function '------------------------------------------------------------------------- 'Function: ServeGeneralTabJavaScript 'Description: Serve common javascript that is required for general tab 'Input Variables: None 'Output Variables: None 'Returns: None 'Global Variables: None '------------------------------------------------------------------------- Function ServeGeneralTabJavaScript() %> <% End Function '------------------------------------------------------------------------- 'Function: ServeAdvancedTabJavaScript 'Description: Serve common javascript that is required for Advanced tab 'Input Variables: None 'Output Variables: None 'Returns: None 'Global Variables: None '------------------------------------------------------------------------- Function ServeAdvancedTabJavaScript() %> <% End Function '------------------------------------------------------------------------- 'Function: ServeCommonJavaScript 'Description: Serve common javascript that is required for this page type. 'Input Variables: None 'Output Variables: None 'Returns: None 'Global Variables: None '------------------------------------------------------------------------- Function ServeCommonJavaScript() %> <% End Function '------------------------------------------------------------------------- 'Function: ServeGeneralUI 'Description: Serves the HTML content for General tab 'Input Variables: None 'Output Variables: None 'Returns: None 'Global Variables: g_*, F_*, blnDHCPEnabled, L_* '------------------------------------------------------------------------- Function ServeGeneralUI() Call SA_TraceOut(SOURCE_FILE, "ServeGeneralUI") 'check whether DHCP is enabled Dim objService ' WMI connection object Dim objInstance ' Adapter instance 'Trying to connect to the server Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE) 'Getting the instance of the particulat NIC card object Set objInstance = getNetworkAdapterObject(objService,g_strDeviceID) ' Getting DHCP Enable/Disable and accordingly set radio values blnDHCPEnabled = isDHCPenabled(objInstance) 'Release the objects set objService = nothing set objInstance = nothing if trim(g_strTabValue) = "" or blnDHCPEnabled then Call getDefaultGeneralValues() 'Get the default values for General tab end if %>
onClick="enableIPControls(true)" > <%=L_OBTAINIPFROMDHCP_TEXT %>
onClick="enableIPControls(false)" > <%=L_CONFIGUREMANUALLY_TEXT%>

 

      <%=L_NIC_IP_IP%> <% select case blnDHCPEnabled case false %> <% case true %> <% end select %>
      <%=L_SUBNETMASK_TEXT%> <% select case blnDHCPEnabled case false %> <% case true %> <% end select %>
      <%=L_DEFAULTGATEWAY_TEXT%> <% select case blnDHCPEnabled case false %> <% case true %> <% end select %>
<% End Function '------------------------------------------------------------------------- 'Function: ServeAdvancedUI 'Description: Serves the HTML content for Advanced tab 'Input Variables: None 'Output Variables: None 'Returns: None 'Global Variables: g_*, F_*, L_* '------------------------------------------------------------------------- Function ServeAdvancedUI() Call SA_TraceOut(SOURCE_FILE, "ServeAdvancedUI") if trim(g_strAdvTabValue) = "" then getDefaultAdvancedvalues() 'Get the default values for Advanced tab else UpdateDefaultValues() 'Update the values when navigated between tabs end if %>

<%=L_NIC_IP_IP%>


<%=L_NIC_IP_IP%>

<%=L_ADVSUBNETMASK_TEXT%>
<% Call SA_ServeOnClickButtonEx(L_BUTTON_ADD_TEXT,"","addIPtoListBox(lstIP,txtAdvIP,txtAdvMask,btnRemoveIP)",90,0,"DISABLED","btnAddIP")%>



<% Call SA_ServeOnClickButtonEx(L_BUTTON_REMOVE_TEXT,"","removeListBoxItems(lstIP,btnRemoveIP);enableAdvIPControls()",90,0,"ENABLED","btnRemoveIP")%>

<%=L_GATEWAYADDRESS_TEXT%>

<% Call SA_ServeOnClickButtonEx(L_BUTTON_ADD_TEXT,"","addGATEWAYtoListBox(lstGATEWAY,txtAdvGATEWAY,txtGATEWAYMetric,btnRemoveGATEWAY)",90,0,"DISABLED","btnAddGATEWAY")%>



<% Call SA_ServeOnClickButtonEx(L_BUTTON_REMOVE_TEXT,"","removeListBoxItems(lstGATEWAY,btnRemoveGATEWAY); enableGatewayControls();",90,0,"ENABLED","btnRemoveGATEWAY")%>
<%=L_GATEWAY_TEXT %>

<%=L_GATEWAYMETRIC_TEXT%>

<%=L_IPCONNECTIONMETRIC_TEXT%>
<%= L_METRICDESC_TEXT %>
<% End Function '------------------------------------------------------------------------- 'Sub routine name: ServeListValues 'Description: Serves in Loading the IP's/Gateways into the list box 'Input Variables: In - strList->list of the addresses with concatination ' character as ; ' In - ERRORMESSAGE->Error message for that particular call 'Output Variables: None 'Returns: None 'Global Variables: None '------------------------------------------------------------------------- Sub ServeListValues(strList,ERRORMESSAGE,nMaxcount) Err.Clear On Error Resume Next Dim arrTempList 'holds the array of items Dim i 'holds the increment count Dim nCountVal 'holds the count of items to limit the items in the listbox Call SA_TraceOut(SOURCE_FILE, "ServeListValues") ' splitting the string into array arrTempList=split(strList,";",-1,1) nCountVal =0 'Printing the array values into the listbox For i=Lbound(arrTempList) To Ubound(arrTempList) nCountVal = nCountVal + 1 ' checking for empty and if the string is ":" dont display in the list box If arrTempList(i) <> "" AND arrTempList(i) <> ":" Then If i=Lbound(arrTempList) Then Response.Write "" Else Response.Write "" End if End If if nCountVal = nMaxcount then exit for Next If Err.number <> 0 Then Call SA_TraceOut(SOURCE_FILE, "ServeListValues failed") SA_SetErrMsg ERRORMESSAGE & "(" & Hex(Err.Number) & ")" End If End Sub '------------------------------------------------------------------------- 'Function name: getDefaultGeneralValues 'Description: Serves in Getting the Default values from the System 'Input Variables: None 'Output Variables: None 'Returns: True/False 'Global Variables: In:G_CONST_REGISTRY_PATH-Reg path ' In:CONST_WMI_WIN32_NAMESPACE ' In:L_* -Localized strings ' Out:F_* - Form variables ' 'Called several functions regConnection, 'getNetworkAdapterObject,isDHCPenabled,getRegkeyvalue 'which will be helpful in getting the NIC information '------------------------------------------------------------------------- Function getDefaultGeneralValues() Err.Clear On Error Resume Next Dim objService Dim objInstance Dim arrIPList 'hold array IP list Dim arrSubnetList 'hold array Subnet list Dim nCount Dim strSettingID 'hold setting id Dim arrGATEWAYList 'hold gateway array list Dim objRegistry Call SA_TraceOut(SOURCE_FILE, "getDefaultGeneralValues") 'Trying to connect to the server Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE) 'Connect to registry Set objRegistry=regConnection() 'Getting the instance of the particulat NIC card object Set objInstance = getNetworkAdapterObject(objService,g_strDeviceID) ' Getting DHCP Enable/Disable and accordingly set radio values blnDHCPEnabled = isDHCPenabled(objInstance) 'Getting the SettingID strSettingID=objInstance.SettingID 'Getting IP values from the registry by giving the complete path arrIPList = objInstance.IPAddress 'Getting subnet values from the registry by giving the complete path arrSubnetList = objInstance.IPSubnet 'Getting GATEWAY values from the registry by giving the complete path arrGATEWAYList=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _ & strSettingID,"DefaultGateway",CONST_MULTISTRING) 'Forming the string of IP+ SubnetMask list For nCount=LBound(arrIPList) To UBound(arrIPList) F_strIPAddress = arrIPList(nCount) g_initialIPAddress = arrIPList(nCount) F_strSubnetMask = arrSubnetList(nCount) F_strGatewayAddress = arrGATEWAYList(nCount) Exit for Next getDefaultGeneralValues = true 'release objects Set objInstance = Nothing Set objService = Nothing Set objRegistry = Nothing End Function '------------------------------------------------------------------------- 'Function name: getDefaultAdvancedvalues 'Description: Serves in Getting the Default values from the System 'Input Variables: None 'Output Variables: None 'Returns: True/False 'Global Variables: In:G_CONST_REGISTRY_PATH-Reg path ' Out:F_nConnectionMetric-IP connection ' metric(from Registry) ' Out:g_arrIPList-List of Ips& subnetmask ' Out:G_arrGATEWAYList-List of Gateways& Metrics ' In :L_* -Localized strings ' 'Called several functions regConnection, 'getNetworkAdapterObject,isDHCPenabled,getRegkeyvalue 'which will be helpful in getting the NIC information '------------------------------------------------------------------------- Function getDefaultAdvancedvalues() Err.Clear On Error Resume Next Dim objInstance Dim objRegistry Dim objService 'holds WMI Connection Dim arrIPList 'holds IP array list Dim arrSubnetList 'holds subnet array Dim arrGATEWAYList 'holds gateway array Dim arrGATEWAYMetricList 'holds gateway metric list Dim strSettingID 'holds setting ID Dim nCount g_strAdvTabValue = "true" Call SA_TraceOut(SOURCE_FILE, "getDefaultAdvancedvalues") 'Trying to connect to the server Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE) if Err.number <> 0 then SA_ServeFailurePage L_WMI_CONNECTIONFAIL_ERRORMESSAGE getDefaultAdvancedvalues = False Exit Function end if 'Connecting to default namespace to carry registry operations Set objRegistry=regConnection() If (objRegistry is Nothing) Then SA_ServeFailurePage L_SERVERCONNECTIONFAIL_ERRORMESSAGE getDefaultAdvancedvalues = False Exit Function End If 'Getting the instance of the particulat NIC card object Set objInstance = getNetworkAdapterObject(objService,g_strDeviceID) 'Getting the SettingID strSettingID=objInstance.SettingID 'Getting IP values from the registry by giving the complete path 'arrIPList=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _ '& strSettingID,"IPAddress",CONST_MULTISTRING) arrIPList = objInstance.IPAddress 'Getting subnet values from the registry by giving the complete path 'arrSubnetList=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _ '& strSettingID,"SubnetMask",CONST_MULTISTRING) arrSubnetList = objInstance.IPSubnet if trim(F_strIPAddress) <> "" then g_arrIPList = F_strIPAddress & ":" & F_strSubnetMask & ";" 'Forming the string of IP+ SubnetMask list For nCount=LBound(arrIPList) + 1 To UBound(arrIPList) g_arrIPList=g_arrIPList+arrIPList(nCount)+":"+arrSubnetList(nCount)+";" Next else 'Forming the string of IP+ SubnetMask list if F_strRadIP = 1 then For nCount=LBound(arrIPList)+1 To UBound(arrIPList) g_arrIPList=g_arrIPList+arrIPList(nCount)+":"+arrSubnetList(nCount)+";" Next end if if F_strRadIP = 0 then For nCount=LBound(arrIPList) To UBound(arrIPList) g_arrIPList=g_arrIPList+arrIPList(nCount)+":"+arrSubnetList(nCount)+";" Next end if end if 'Getting GATEWAY values from the registry by giving the complete path arrGATEWAYList=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" _ & strSettingID,"DefaultGateway",CONST_MULTISTRING) 'Getting GateWayCostMetric from registry by giving the complete path arrGATEWAYMetricList =getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH _ & "\" & strSettingID,"DefaultGatewayMetric",CONST_MULTISTRING) if F_strRadIP <> 0 then if F_strGatewayAddress <> "" then g_arrGATEWAYList = F_strGatewayAddress & " "+L_METRIC_TEXT+" 1;" 'Forming the string of gateway+ metric list For nCount=LBound(arrGATEWAYList) + 1 To UBound(arrGATEWAYList) g_arrGATEWAYList = g_arrGATEWAYList+arrGATEWAYList(nCount)+ _ " "+L_METRIC_TEXT+" "+arrGATEWAYMetricList(nCount)+";" Next else 'Forming the string of gateway+ metric list For nCount=LBound(arrGATEWAYList) To UBound(arrGATEWAYList) g_arrGATEWAYList = g_arrGATEWAYList+arrGATEWAYList(nCount)+ _ " "+L_METRIC_TEXT+" "+arrGATEWAYMetricList(nCount)+";" Next end if 'Getting InterfaceMetric from the registry by giving the complete path F_nConnectionMetric=getRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH _ & "\" & strSettingID ,"InterfaceMetric",CONST_DWORD) 'Set to Nothing Set objService=Nothing Set objRegistry=Nothing Set objInstance=Nothing getDefaultAdvancedvalues = true End Function '------------------------------------------------------------------------- 'Function: UpdateDefaultValues 'Description: Updates the state of fields when navigated from one tab ' to another 'Input Variables: None 'Output Variables: None 'Returns: string 'Global Variables: F_*,g_* '------------------------------------------------------------------------- Function UpdateDefaultValues() Dim arrTempList 'holds temporary array Dim i 'holds increment count Call SA_TraceOut(SOURCE_FILE, "UpdateDefaultValues") arrTempList=split(F_strListGateway,";",-1,1) if F_strRadIP = 1 then if F_strGatewayAddress <> "" then g_arrGATEWAYList = F_strGatewayAddress & " "+L_METRIC_TEXT+" 1;" For i=Lbound(arrTempList)+ 1 To Ubound(arrTempList) g_arrGATEWAYList = g_arrGATEWAYList & arrTempList(i) & ";" next end if if F_strRadIP = 0 then For i=Lbound(arrTempList) To Ubound(arrTempList) g_arrGATEWAYList = g_arrGATEWAYList & arrTempList(i) & ";" next End if arrTempList=split(F_strListIP,";",-1,1) if F_strIPAddress <> "" then g_arrIPList = F_strIPAddress & ":" & F_strSubnetMask & ";" if F_strRadIP = 1 then For i=Lbound(arrTempList)+ 1 To Ubound(arrTempList) g_arrIPList = g_arrIPList & arrTempList(i) & ";" next end if elseif F_strIPAddress = "" then if F_strRadIP = 0 then For i=Lbound(arrTempList) To Ubound(arrTempList) g_arrIPList = g_arrIPList & arrTempList(i) & ";" next end if end if End Function '------------------------------------------------------------------------- 'Function name: setNIC 'Description: serves in Setting new IP & gateway values 'Input Variables: None 'Output Variables: 'Returns: Boolean - Returns ( True/Flase ) 'Global Variables: In - blnDHCPEnabled -Radio button value ' In - G_CONST_REGISTRY_PATH -Reg path ' In - L_* - Localized strings 'Called registry related functions to update the values and displays the 'corresponding error if any. '------------------------------------------------------------------------- Function setNIC() Err.Clear On Error resume next Dim objInstance Dim objService Dim objRegistry 'holds registry connection object Dim arrIPList Dim arrSubnetList 'holds subnet array list Dim arrGATEWAYList() 'holds gateway array list Dim arrTemp Dim arrMetricList Dim strSettingID 'holds setting ID Dim StrIP Dim strSubnet Dim strGATEWAY Dim strMetric Dim strTmpIP Dim strTmpGATEWAY Dim i Dim intReturnValue Dim arrGATEWAY Dim strRetURL Dim retVal Redim arrIPList(0) Redim arrGATEWAYList(0) Redim arrSubnetList(0) 'Initializing to FALSE setNIC = FALSE Call SA_TraceOut(SOURCE_FILE, "setNIC") 'Connecting to the server Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE) if Err.number <> 0 then SA_ServeFailurePage L_WMI_CONNECTIONFAIL_ERRORMESSAGE Exit Function end if 'Checks whether ServerAppliance IP Address is equal to IPAddress entered 'Added check to only validate IP when we are specifying it (Static IP) if (NOT(F_strRadIP = 0)) AND (trim(g_initialIPAddress) <> trim(F_strIPAddress)) then ' ' Check to see if address is in-use if ( TRUE = Ping(F_strIPAddress) ) then call SA_SetActiveTabPage(page,g_iTabGeneral) SA_SetErrMsg L_IP_INUSE_ERRORMESSAGE exit function end if end if 'Getting the instance of the particulat NIC card Set objInstance = getNetworkAdapterObject(objService,g_strDeviceID) If ( F_strRadIP = 0 ) Then Call SA_TraceOut(SOURCE_FILE, "Enabled DHCP") if ( Not objInstance.DHCPEnabled ) then intReturnValue = enableDHCP(objInstance) end if 'Connecting to default namespace to carry registry operations Set objRegistry=regConnection() If (objRegistry is Nothing) Then SA_ServeFailurePage L_SERVERCONNECTIONFAIL_ERRORMESSAGE Exit Function End If 'Getting the SettingID strSettingID=objInstance.SettingID 'Set Interface metric intReturnValue=updateRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" & strSettingID ,"InterfaceMetric",F_nConnectionMetric,CONST_DWORD) If intReturnValue = FALSE Then SA_SetErrMsg L_NIC_IP_ERR_COULDNOTSETIPCONNECTIONMETRIC & "(" & Hex(Err.Number) & ")" Exit Function End If setNIC = TRUE 'Release the objects Set objInstance = Nothing Set objRegistry=Nothing Exit Function End If 'Connecting to default namespace to carry registry operations Set objRegistry=regConnection() if F_strListIP = "" then F_strListIP = F_strIPAddress & ":" & F_strSubnetMask end if if F_strListGateway = "" then F_strListGateway = F_strGatewayAddress & " "+L_METRIC_TEXT+" 1;" end if If (objRegistry is Nothing) Then SA_ServeFailurePage L_SERVERCONNECTIONFAIL_ERRORMESSAGE Exit Function End If 'Getting the SettingID strSettingID=objInstance.SettingID Dim arrNewIp Dim arrNewSubnet Dim nPos 'Split Ip List into arrays of Ip and Subnet mask nPos = InStr(F_strListIP, ";") if( Cint(nPos) = 0 ) then ReDim strTmpIP(0) strTmpIP(0) = F_strListIP else strTmpIP = Split(F_strListIP, ";",-1,1) end if ReDim arrNewIp(UBound(strTmpIp)) ReDim arrNewSubnet(UBound(strTmpIp)) 'Loop to pack Ip's and subnetmasks in different variables For i= 0 To UBound(strTmpIp) arrTemp = Split(strTmpIP(i),":",-1,1) arrNewIp(i) = arrTemp(0) arrNewSubnet(i) = arrTemp(1) Next 'Split Gateway List into arrays of gateway and metric strTmpGATEWAY = Split(F_strListGateway, ";", -1, 1) redim arrGATEWAY(UBound(strTmpGATEWAY)) 'Loop to pack Gateways's and Metrics in different variables For i= 0 to Ubound(strTmpGATEWAY) if strTmpGATEWAY(i) = "" then exit for end if arrTemp = Split(strTmpGATEWAY(i)," "+L_METRIC_TEXT+" ",-1,1) If (isnull (strGATEWAY)) Then strGATEWAY = arrTemp(0) & ";" Else strGATEWAY = strGATEWAY & arrTemp(0) & ";" End If If (isnull (strMetric)) Then strMetric = arrTemp(1) & ";" Else strMetric = strMetric & arrTemp(1) & ";" End If Next 'call wmi method EnableStatic in win32_networkadapterconfiguration to set the static ip 'sets the ip and subnet Call objInstance.EnableStatic(arrNewIp, arrNewSubnet) If Err.Number <> 0 Then SA_SetErrMsg L_NIC_IP_ERR_COULDNOTSETIP & objInstance.Description & "(" & Hex(Err.Number) & ")" Exit Function end if if strGATEWAY <> "" then strGATEWAY=Mid(strGATEWAY,1,(Len(strGATEWAY)-1)) end if 'Splitting the string into array of GATEWAYS redim arrGATEWAY(UBound(strTmpGATEWAY)) arrGATEWAY = split(strGATEWAY, ";", -1 ,1) if strMetric <> "" then strMetric=Mid(strMetric,1,(Len(strMetric)-1)) end if 'Splitting the string into array of GATEWAYMetrics arrMetricList= split(strMetric, ";", -1 ,1) 'Sets gateway and connection metric intReturnValue=objInstance.SetGateways(arrGATEWAY,arrMetricList) If intReturnValue <> 0 Then SA_SetErrMsg L_NIC_IP_ERR_COULDNOTSETGATEWAY & objInstance.Description & "(" & Hex(Err.Number) & ")" Exit Function end if 'Sets Interface metric intReturnValue=updateRegkeyvalue(objRegistry,G_CONST_REGISTRY_PATH & "\" & strSettingID ,"InterfaceMetric",F_nConnectionMetric,CONST_DWORD) If intReturnValue = FALSE Then SA_SetErrMsg L_NIC_IP_ERR_COULDNOTSETIPCONNECTIONMETRIC & "(" & Hex(Err.Number) & ")" Exit Function End If 'Set to Nothing Set objService=Nothing Set objRegistry=Nothing Set objInstance=Nothing setNIC = TRUE End Function '------------------------------------------------------------------------- 'Function: GetReturnURL 'Description: Forms new URL for changed IP 'Input Variables: strNewIP 'Output Variables: strRetURL 'returns newly formed URL 'Returns: string 'Global Variables: None '------------------------------------------------------------------------- Function GetReturnURL(strNewIp) Err.Clear On Error Resume Next GetReturnURL = "" Dim strRetURL Dim strBase Dim strTab strBase = SA_GetNewHostURLBase(strNewIp, SA_DEFAULT, FALSE, SA_DEFAULT) strRetURL = strBase & "network/nicinterface_prop.asp" strTab = GetTab1() If ( Len(strTab) > 0 ) Then Call SA_MungeURL(strRetURL, "Tab1", strTab) End If strTab = GetTab2() If ( Len(strTab) > 0 ) Then Call SA_MungeURL(strRetURL, "Tab2", strTab) End If Call SA_TraceOut(SOURCE_FILE, strRetURL) GetReturnURL = strRetURL End Function Function Ping(ByVal sIP) on error resume next err.Clear() Dim oHelper Ping = FALSE Set oHelper = CreateObject("ComHelper.NetworkTools") if ( Err.Number <> 0 ) Then Call SA_TraceOut("INC_GLOBAL", "Error creating ComHelper.NetworkTools object, error: " + CStr(Hex(Err.Number))) Exit Function End If Ping = oHelper.Ping(sIP) if ( Err.Number <> 0 ) Then Ping = FALSE Call SA_TraceOut("INC_GLOBAL", "oHelper.Ping(), error: " + CStr(Hex(Err.Number)) + " " + Err.Description) Exit Function End If if ( Ping > 0 ) Then Ping = TRUE End If Set oHelper = Nothing End Function %>