Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

339 lines
10 KiB

  1. <%@ Language=VBScript%>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' nfsclientgroups.asp: nfsclientgroups page - lists all the nfs
  6. ' client groups,and provides links for creating new
  7. ' nfs client group,editing and deleting client group
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Date Description
  11. ' 20-Sept-2000 Creation date
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual="/admin/inc_framework.asp"-->
  15. <!-- #include virtual="/admin/ots_main.asp" -->
  16. <!-- #include file="loc_NFSSvc.asp" -->
  17. <!-- #include file="inc_NFSSvc.asp" -->
  18. <%
  19. Const ENABLE_TRACING = FALSE
  20. 'Define the global vars
  21. Dim g_iSortCol
  22. Dim g_sSortSequence
  23. g_iSortCol = 1
  24. g_sSortSequence = "A"
  25. '-------------------------------------------------------------------------
  26. ' Create the page and Event handler
  27. '-------------------------------------------------------------------------
  28. Dim page
  29. Dim rc
  30. rc = SA_CreatePage(L_PAGE_TITLE_TEXT, "", PT_AREA, page)
  31. If rc = 0 Then
  32. SA_ShowPage( page )
  33. End If
  34. Public Function OnInitPage( ByRef PageIn, ByRef EventArg)
  35. OnInitPage = True
  36. End Function
  37. Public Function OnServeAreaPage( ByRef PageIn, ByRef EventArg)
  38. if not isServiceInstalled(getWMIConnection( _
  39. CONST_WMI_WIN32_NAMESPACE _
  40. ),"nfssvc") then
  41. SA_ServeFailurePage L_NFSNOTINSTALLED_ERRORMESSAGE
  42. end if
  43. Response.Write("<blockquote>")
  44. ClientGroupsObjectPicker()
  45. Response.Write("</blockquote>")
  46. OnServeAreaPage = True
  47. End Function
  48. Function ServeCommonJavaScript()
  49. %>
  50. <script language = "JavaScript" src = "<%=m_VirtualRoot%>inc_global.js">
  51. </script>
  52. <script language = "JavaScript">
  53. function Init()
  54. {
  55. var strClientGroupName
  56. var nIndex
  57. var objForm
  58. //Selects a ClientGroup Name depending on the Task type.
  59. strClientGroupName = '<%=request.QueryString("PKey")%>'
  60. if(document.TVData!=null)
  61. {
  62. objForm = eval("document.TVData.TVItem_Table1")
  63. if ( typeof( objForm ) == "undefined" )
  64. {
  65. return;
  66. }
  67. if(strClientGroupName == "")
  68. {
  69. return
  70. }
  71. objForm[0].checked = false
  72. document.TVData.tSelectedItem.value = "";
  73. document.TVData.tSelectedItemNumber.value = "";
  74. for(nIndex =0 ; nIndex < objForm.length ; nIndex++)
  75. {
  76. if (unescape(objForm[nIndex].value) == strClientGroupName)
  77. {
  78. objForm[nIndex].checked = true
  79. objForm[nIndex].focus()
  80. document.TVData.tSelectedItem.value = strClientGroupName ;
  81. document.TVData.tSelectedItemNumber.value = nIndex;
  82. return
  83. }
  84. }
  85. }
  86. }
  87. function ValidatePage()
  88. {
  89. return true;
  90. }
  91. function SetData()
  92. {
  93. }
  94. </script>
  95. <%
  96. End Function
  97. '---------------------------------------------------------------------
  98. ' Function: OnSortNotify()
  99. ' Function name: GetServices
  100. ' Description: Sorting notification event handler.
  101. ' Input Variables: PageIn,EventArg,sortCol,sortSeq
  102. ' Output Variables: PageIn,EventArg
  103. ' Return Values: Always returns TRUE
  104. ' Global Variables: G_*
  105. '---------------------------------------------------------------------
  106. Public Function OnSortNotify(ByRef PageIn, _
  107. ByRef EventArg, _
  108. ByVal sortCol, _
  109. ByVal sortSeq )
  110. OnSortNotify = TRUE
  111. '
  112. ' User pressed column sort
  113. '
  114. If SA_IsChangeEvent(EventArg) Then
  115. If ( ENABLE_TRACING ) Then
  116. Call SA_TraceOut(SOURCE_FILE, "OnSortNotify() Change Event Fired")
  117. End If
  118. g_iSortCol = sortCol
  119. g_sSortSequence = sortSeq
  120. '
  121. ' User presed the search GO button OR clicked either the page next or page prev button
  122. ElseIf SA_IsPostBackEvent(EventArg) Then
  123. If ( ENABLE_TRACING ) Then
  124. Call SA_TraceOut(SOURCE_FILE, "OnSortNotify() Postback Event Fired")
  125. End If
  126. g_iSortCol = sortCol
  127. g_sSortSequence = sortSeq
  128. '
  129. ' Unknown event source
  130. Else
  131. If ( ENABLE_TRACING ) Then
  132. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  133. End If
  134. End IF
  135. If ( ENABLE_TRACING ) Then
  136. Call SA_TraceOut(SOURCE_FILE, "Sort col: " + CStr(sortCol) + " sequence: " + sortSeq)
  137. End If
  138. End Function
  139. '-------------------------------------------------------------------------
  140. ' Function name: ClientGroupsObjectPicker
  141. ' Description: Gets NFS Client Groups from local machine.
  142. ' Input Variables: None.
  143. ' Output Variables: None.
  144. ' Return Values: None.
  145. ' Global Variables: in: L_* -
  146. ' Gets NFS Client Groups from localmachine and outputs to the Client Groups
  147. ' Objectpicker control.
  148. ' On error of creating or displaying of rows,columns and table an
  149. ' appropriate error message is displayed by calling SA_ServeFailurePage.
  150. '-------------------------------------------------------------------------
  151. Function ClientGroupsObjectPicker()
  152. Err.Clear
  153. On Error Resume Next
  154. Dim objTableClientGroups
  155. Dim nReturnValue
  156. Dim strUrlBase
  157. Dim rc
  158. Dim objClientGroups
  159. Dim intGroup
  160. Dim intGroupsCount
  161. Dim strAllGroups
  162. Dim arrGroups
  163. strUrlBase = m_VirtualRoot
  164. 'Create Appliance Nfs ClientGroups table
  165. objTableClientGroups = OTS_CreateTable(L_PAGE_TITLE_TEXT, _
  166. L_CLIENTGROUPS_DESCTIPITON_TEXT)
  167. 'Create and add the columns
  168. nReturnValue = OTS_AddTableColumn( objTableClientGroups, _
  169. OTS_CreateColumn( _
  170. L_KEYCOLUMN_CLIENTGROUPNAME_TEXT, _
  171. "left", _
  172. (OTS_COL_FLAG_HIDDEN OR _
  173. OTS_COL_FLAG_KEY)))
  174. If nReturnValue <> gc_ERR_SUCCESS Then
  175. SA_ServeFailurePage L_FAILEDTOADDCOLOUMN_ERRORMESSAGE
  176. End IF
  177. nReturnValue = OTS_AddTableColumn(objTableClientGroups, _
  178. OTS_CreateColumn(_
  179. L_COLUMN_CLIENTGROUPNAME_TEXT , _
  180. "left", _
  181. OTS_COL_FLAG_KEY OR OTS_COL_FLAG_SORT))
  182. If nReturnValue <> gc_ERR_SUCCESS Then
  183. SA_ServeFailurePage L_FAILEDTOADDCOLOUMN_ERRORMESSAGE
  184. End IF
  185. If Err.number<>0 then
  186. SA_ServeFailurePage L_FAILEDTOCREATEOBJECT_ERRORMESSAGE
  187. End IF
  188. strAllGroups = NFS_EnumGroups()
  189. arrGroups = split( strAllGroups, chr(1) )
  190. intGroupsCount = ubound(arrGroups)
  191. For intGroup = 0 to Cint(intGroupsCount)-1
  192. nReturnValue =OTS_AddTableRow(objTableClientGroups, _
  193. Array(arrGroups( intGroup ),arrGroups( intGroup )))
  194. If nReturnValue <> gc_ERR_SUCCESS Then
  195. SA_ServeFailurePage L_FAILEDTOADDROW_ERRORMESSAGE
  196. End IF
  197. next
  198. 'Add Tasks
  199. rc = OTS_SetTableTasksTitle(objTableClientGroups,L_TASKS_TEXT)
  200. nReturnValue = OTS_AddTableTask( objTableClientGroups, _
  201. OTS_CreateTask( _
  202. L_SERVEAREABUTTON_NEW_TEXT, _
  203. L_NEW_ROLLOVERTEXT_TEXT , _
  204. strUrlBase + _
  205. "nfs/nfsclientgroups_new.asp", _
  206. OTS_PAGE_TYPE_SIMPLE_PROPERTY))
  207. If nReturnValue <> gc_ERR_SUCCESS Then
  208. SA_ServeFailurePage L_FAILEDTOADDTASK_ERRORMESSAGE
  209. End IF
  210. If intGroupsCount > 0 then
  211. nReturnValue = OTS_AddTableTask( objTableClientGroups, _
  212. OTS_CreateTask( _
  213. L_SERVEAREABUTTON_DELETE_TEXT, _
  214. L_DELETE_ROLLOVERTEXT_TEXT, _
  215. strUrlBase + _
  216. "nfs/nfsclientgroups_delete_prop.asp", _
  217. OTS_PAGE_TYPE_SIMPLE_PROPERTY))
  218. If nReturnValue <> gc_ERR_SUCCESS Then
  219. SA_ServeFailurePage L_FAILEDTOADDTASK_ERRORMESSAGE
  220. End IF
  221. nReturnValue = OTS_AddTableTask( objTableClientGroups, _
  222. OTS_CreateTask( _
  223. L_SERVEAREABUTTON_EDIT_TEXT, _
  224. L_EDIT_ROLLOVERTEXT_TEXT, _
  225. strUrlBase + _
  226. "nfs/nfsclientgroups_edit_prop.asp", _
  227. OTS_PAGE_TYPE_SIMPLE_PROPERTY))
  228. If nReturnValue <> gc_ERR_SUCCESS Then
  229. SA_ServeFailurePage L_FAILEDTOADDTASK_ERRORMESSAGE
  230. End IF
  231. End IF
  232. 'Sort the table
  233. nReturnValue = OTS_EnableTableSort(objTableClientGroups, true)
  234. If nReturnValue <> gc_ERR_SUCCESS Then
  235. SA_ServeFailurePage L_FAILEDTOSORT_ERRORMESSAGE
  236. End IF
  237. Call OTS_SortTable(objTableClientGroups, g_iSortCol, g_sSortSequence, SA_RESERVED)
  238. 'Render the table
  239. nReturnValue = OTS_ServeTaskViewTable(objTableClientGroups)
  240. If nReturnValue <> gc_ERR_SUCCESS OR Err.number <> 0 Then
  241. SA_ServeFailurePage L_FAILEDTOSHOW_ERRORMESSAGE
  242. End IF
  243. 'Destroying dynamically created objects.
  244. Set objClientGroups=Nothing
  245. End Function
  246. '-------------------------------------------------------------------------
  247. 'Function name: isServiceInstalled
  248. 'Description:helper Function to chek whether the function is there or not
  249. 'Input Variables: objService - object to WMI
  250. ' strServiceName - Service name
  251. 'Output Variables: None
  252. 'Returns: (True/Flase)
  253. 'GlobalVariables: None
  254. '-------------------------------------------------------------------------
  255. Function isServiceInstalled(ObjWMI,strServiceName)
  256. Err.clear
  257. on error resume next
  258. Dim strService
  259. strService = "name=""" & strServiceName & """"
  260. isServiceInstalled = IsValidWMIInstance(ObjWMI,"Win32_Service",strService)
  261. end Function
  262. '-------------------------------------------------------------------------
  263. 'Function name: IsValidWMIInstance
  264. 'Description: Checks the instance for valid ness.
  265. 'Input Variables: objService - object to WMI
  266. ' strClassName - WMI class name
  267. ' strPropertyName - Property name of the class
  268. '
  269. 'Output Variables: None
  270. 'Returns: Returns true on Valid Instance ,
  271. ' False on invalid and also on Error
  272. ' Checks whether the given instance is valid in WMI.Returns true on valid
  273. ' false on invalid or Error.
  274. '-------------------------------------------------------------------------
  275. Function IsValidWMIInstance(objService,strClassName,strPropertyName)
  276. Err.Clear
  277. On Error Resume Next
  278. Dim strInstancePath
  279. Dim objInstance
  280. strInstancePath = strClassName & "." & strPropertyName
  281. Set objInstance = objservice.Get(strInstancePath)
  282. if NOT isObject(objInstance) or Err.number <> 0 Then
  283. IsValidWMIInstance = FALSE
  284. Err.Clear
  285. Else
  286. IsValidWMIInstance = TRUE
  287. End If
  288. 'clean objects
  289. Set objInstance = nothing
  290. End Function
  291. %>