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.

333 lines
11 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' group_delete.asp: Delete slected group of local machine.
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. '15-Jan-2001 Creation date
  11. '-------------------------------------------------------------------------
  12. %>
  13. <!-- #include virtual="/admin/inc_framework.asp" -->
  14. <%
  15. '-------------------------------------------------------------------------
  16. ' Global Variables
  17. '-------------------------------------------------------------------------
  18. Dim rc 'Return value for CreatePage
  19. Dim page 'Variable that receives the output page object when
  20. 'creating a page
  21. 'Error constant
  22. Const N_COULDNOTDELETEBUILTINGROUP_ERRNO = &H8007055B
  23. '-------------------------------------------------------------------------
  24. ' Global Form Variables
  25. '-------------------------------------------------------------------------
  26. Dim F_strGroupName ' Group name from previous page
  27. Dim F_strComputername ' Local Machine name from system
  28. '-------------------------------------------------------------------------
  29. 'Start of localization Content
  30. '-------------------------------------------------------------------------
  31. Dim L_PAGETITLE_GROUPDELETE_TEXT 'Page title
  32. Dim L_DELETEGROUPNAME_TEXT
  33. Dim L_QUESTIONMARK_TEXT
  34. Dim L_NOTE_TEXT
  35. Dim L_DELETEWARNING_TEXT
  36. Dim L_DELETEWARNING_CONTINUED_TEXT
  37. Dim L_COULDNOTDELETEBUILTINGROUP_ERRORMESSAGE
  38. Dim L_GROUPNOTDELETED_ERRORMESSAGE
  39. Dim L_GROUPNOTEXISTS_ERRORMESSAGE
  40. L_PAGETITLE_GROUPDELETE_TEXT = GetLocString("usermsg.dll", "&H40310039", "")
  41. L_DELETEGROUPNAME_TEXT = GetLocString("usermsg.dll", "&H4031003A", "")
  42. L_QUESTIONMARK_TEXT = GetLocString("usermsg.dll", "&H4031003B", "")
  43. L_NOTE_TEXT = GetLocString("usermsg.dll", "&H4031003C", "")
  44. L_DELETEWARNING_TEXT = GetLocString("usermsg.dll", "&H4031003D", "")
  45. 'L_DELETEWARNING_CONT1_TEXT = GetLocString("usermsg.dll", "&H4031003E", "")
  46. L_COULDNOTDELETEBUILTINGROUP_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031003F", "")
  47. L_GROUPNOTDELETED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310040", "")
  48. L_GROUPNOTEXISTS_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310041", "")
  49. '-------------------------------------------------------------------------
  50. ' END of localization content
  51. '-------------------------------------------------------------------------
  52. 'Create property page
  53. rc=SA_CreatePage(L_PAGETITLE_GROUPDELETE_TEXT,"",PT_PROPERTY,page)
  54. If (rc=SA_NO_ERROR) Then
  55. 'Serve the page
  56. SA_ShowPage(page)
  57. End If
  58. '-------------------------------------------------------------------------
  59. 'Function: OnInitPage()
  60. 'Description: Called to signal first time processing for this page.
  61. 'Input Variables: PageIn,EventArg
  62. 'Output Variables: None
  63. 'Returns: True/False
  64. 'Global Variables: None
  65. '-------------------------------------------------------------------------
  66. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  67. 'Getting local machine name.
  68. F_strComputername = GetComputerName()
  69. 'Function to check the group existence
  70. Dim iItemCount
  71. Dim x
  72. Dim itemKey
  73. Dim sessionItem
  74. iItemCount = OTS_GetTableSelectionCount("")
  75. For x = 1 To iItemCount
  76. If ( OTS_GetTableSelection("", x, itemKey) ) Then
  77. 'isGroupExisting(itemKey)
  78. End If
  79. sessionItem = "Item" + CStr(x)
  80. Session(sessionItem) = itemKey
  81. Next
  82. OnInitPage = TRUE
  83. End Function
  84. '-------------------------------------------------------------------------
  85. 'Function: OnServePropertyPage()
  86. 'Description: Called when the page needs to be served.
  87. 'Input Variables: PageIn,EventArg
  88. 'Output Variables: None
  89. 'Returns: True to indicate no problems occured. False to indicate erros.
  90. 'Global Variables: None
  91. '-------------------------------------------------------------------------
  92. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  93. Call ServeCommonJavaScript()
  94. Call ServePage()
  95. OnServePropertyPage = True
  96. End Function
  97. '-------------------------------------------------------------------------
  98. 'Function: OnPostBackPage()
  99. 'Description: Called to signal that the page has been posted-back.
  100. 'Input Variables: PageIn,EventArg
  101. 'Output Variables: None
  102. 'Returns: True/False
  103. 'Global Variables: None
  104. '-------------------------------------------------------------------------
  105. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  106. OnPostBackPage = True
  107. End Function
  108. '-------------------------------------------------------------------------
  109. 'Function: OnSubmitPage()
  110. 'Description: Called when the page has been submitted for processing.
  111. 'Input Variables: PageIn,EventArg
  112. 'Output Variables: None
  113. 'Returns: True/False
  114. 'Global Variables: None
  115. '-------------------------------------------------------------------------
  116. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  117. 'Get computer name from the hidden variable
  118. F_strComputername = Request.Form("hdnComputername")
  119. OnSubmitPage = setLocalGroupProperties()
  120. End Function
  121. '-------------------------------------------------------------------------
  122. 'Function: OnClosePage()
  123. 'Description: Called when the page is about closed.
  124. 'Input Variables: PageIn,EventArg
  125. 'Output Variables: None
  126. 'Returns: True/False
  127. 'Global Variables: None
  128. '-------------------------------------------------------------------------
  129. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  130. OnClosePage = TRUE
  131. End Function
  132. '-------------------------------------------------------------------------
  133. 'Function: ServeCommonJavaScript
  134. 'Description: Serves in initialiging the values,setting the form
  135. ' data and validating the form values
  136. 'Input Variables: None
  137. 'Output Variables: None
  138. 'Returns: True/False
  139. 'Global Variables: None
  140. '-------------------------------------------------------------------------
  141. Function ServeCommonJavaScript()
  142. %>
  143. <script language="JavaScript">
  144. //Dummy function for framework
  145. function Init()
  146. {
  147. }
  148. //Dummy function for framework
  149. function ValidatePage()
  150. {
  151. return true;
  152. }
  153. //Dummy function for framework
  154. function SetData()
  155. {
  156. }
  157. </script>
  158. <%
  159. End Function
  160. '-------------------------------------------------------------------------
  161. 'Function: ServePage()
  162. 'Description: For displaying outputs HTML to the user
  163. 'Input Variables: None
  164. 'Output Variables: None
  165. 'Returns: None
  166. 'Global Variables: L_(*)
  167. '-------------------------------------------------------------------------
  168. Function ServePage
  169. Dim iItemCount
  170. Dim x
  171. Dim itemKey
  172. Dim sessionItem
  173. iItemCount = OTS_GetTableSelectionCount("PKey")
  174. Response.Write "<TABLE WIDTH=530 VALIGN=middle ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class='TasksBody'>"
  175. For x=1 To iItemCount
  176. If ( OTS_GetTableSelection("PKey", x, itemKey) ) Then
  177. Response.Write "<TR>" & "<TD>"
  178. Response.Write L_DELETEGROUPNAME_TEXT & Chr(34) & itemKey & Chr(34) & L_QUESTIONMARK_TEXT
  179. Response.Write "</TD>" & "</TR>"
  180. End If
  181. sessionItem = "Item" + CStr(x)
  182. Session(sessionItem) = itemKey
  183. Next
  184. %>
  185. <TR>
  186. <TD>
  187. &nbsp;
  188. </TD>
  189. </TR>
  190. <TR>
  191. <TD>
  192. <B><%=L_NOTE_TEXT %></B>
  193. </TD>
  194. </TR>
  195. <TR>
  196. <TD nowrap>
  197. <%=L_DELETEWARNING_TEXT & L_DELETEWARNING_CONTINUED_TEXT%>
  198. </TD>
  199. </TR>
  200. </TABLE>
  201. <INPUT NAME="hdnComputername" TYPE="hidden" VALUE="<%=Server.HTMLEncode(F_strComputername)%>"></INPUT>
  202. <%
  203. End Function
  204. '-------------------------------------------------------------------------
  205. ' Function Name: isGroupExisting
  206. ' Description: To check whether the local group is existing.
  207. ' Input Variables: None
  208. ' Output Variables: None
  209. ' Returns: None
  210. ' Global Variables: In: F_strGroupName - Local Group name
  211. ' In: F_strComputername - Local machine name.
  212. ' In: L_GROUPNOTEXISTS_ERRORMESSAGE
  213. ' Checks for group name existence. On error displays servefailurepage.
  214. '-------------------------------------------------------------------------
  215. Function isGroupExisting(ByRef itemKey)
  216. Err.Clear
  217. On Error Resume Next
  218. Dim objLocator
  219. 'Checking whether the group exists or not
  220. Set objLocator = GetObject("WinNT://" & F_strComputername & "/" & itemKey & ",group")
  221. 'Set to Nothing
  222. Set objLocator=Nothing
  223. If Err.number <> 0 Then
  224. ServeFailurePage L_GROUPNOTEXISTS_ERRORMESSAGE
  225. End If
  226. End Function
  227. '-------------------------------------------------------------------------
  228. ' Function Name: setLocalGroupProperties
  229. ' Description: Deletes the Group name
  230. ' Input Variables: None
  231. ' Output Variables: None
  232. ' Returns: True on Successfull deletion of group Otherwise false.
  233. ' Global Variables: In: F_strGroupName - Local Group name
  234. ' In: F_strComputername - Local machine name.
  235. ' In: L_COULDNOTDELETEBUILTINGROUP_ERRORMESSAGE
  236. ' In: L_GROUPNOTDELETED_ERRORMESSAGE
  237. ' Deletes Groupname. On error displays using servefailure page or
  238. ' SetErrMsg with error description.On successfull deletion returns value
  239. ' True else False.
  240. '-------------------------------------------------------------------------
  241. Function setLocalGroupProperties()
  242. Err.Clear
  243. On Error Resume Next
  244. Dim objGroup
  245. Dim iItemCount
  246. Dim x
  247. Dim sessionItem
  248. 'Gets the groupNameObject from the system
  249. Set objGroup = GetObject("WinNT://" & F_strComputername & ",computer")
  250. iItemCount = OTS_GetTableSelectionCount("")
  251. For x=1 To iItemCount
  252. If ( OTS_GetTableSelection("", x, F_strGroupName ) ) Then
  253. 'delete the groupname from the System
  254. objGroup.Delete "Group" , F_strGroupName
  255. End If
  256. If Err.Number <> 0 Then
  257. ' Error number to handle the deletion of Builtin Groups
  258. If Err.Number = N_COULDNOTDELETEBUILTINGROUP_ERRNO Then
  259. SetErrMsg L_COULDNOTDELETEBUILTINGROUP_ERRORMESSAGE & "(" & F_strGroupName & ")"
  260. Else
  261. SetErrMsg L_GROUPNOTDELETED_ERRORMESSAGE & "(" & F_strGroupName & ")"
  262. End If
  263. setLocalGroupProperties = FALSE
  264. Exit Function
  265. End IF
  266. sessionItem = "Item" + CStr(x)
  267. Session(sessionItem) = F_strGroupName
  268. Next
  269. 'Set to nothing
  270. Set objGroup =Nothing
  271. 'Returns true if group has deleted successfully.
  272. setLocalGroupProperties = TRUE
  273. End Function
  274. %>