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.

524 lines
16 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' Web_ExecutePerm.asp: Set the Execute permissions to the web sites/service
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 25-10-2000 Created date
  11. ' 15-01-2001 Modified for new Framework
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual="/admin/inc_framework.asp"--->
  15. <!-- #include virtual="/admin/wsa/inc_wsa.asp" -->
  16. <%
  17. '-------------------------------------------------------------------------
  18. ' Form Variables
  19. '-------------------------------------------------------------------------
  20. Dim F_Sites
  21. Dim F_selectActiveFormat
  22. Dim F_AllSites
  23. '-------------------------------------------------------------------------
  24. ' Global Variables
  25. '-------------------------------------------------------------------------
  26. Dim objService
  27. '-------------------------------------------------------------------------
  28. ' Start of localization content
  29. '-------------------------------------------------------------------------
  30. Dim L_EXECTASKTITLETEXT
  31. 'Dim L_WEBEXECROOTDIRHELP
  32. Dim L_APPLYTOALLIISTEXT
  33. Dim L_APPLYTOINHERITEDIISTEXT
  34. Dim L_EXECUTE_PERMISSIONS
  35. Dim L_NONE
  36. Dim L_SCRIPTS_ONLY
  37. Dim L_SCRIPTS_EXECUTABLES
  38. Dim L_FAIL_TO_SET_EXECPERMS
  39. 'Dim L_WEBEXECROOTREMDIRHELP
  40. Dim L_INFORMATION_ERRORMESSAGE
  41. L_EXECTASKTITLETEXT = GetLocString("GeneralSettings.dll", "4042002E", "")
  42. 'L_WEBEXECROOTDIRHELP = GetLocString("GeneralSettings.dll", "40420036", "")
  43. 'L_WEBEXECROOTREMDIRHELP = GetLocString("GeneralSettings.dll", "40420056", "")
  44. L_APPLYTOALLIISTEXT = GetLocString("GeneralSettings.dll", "40420035", "")
  45. L_APPLYTOINHERITEDIISTEXT = GetLocString("GeneralSettings.dll", "40420034", "")
  46. L_EXECUTE_PERMISSIONS = GetLocString("GeneralSettings.dll", "C0420033", "")
  47. L_NONE = GetLocString("GeneralSettings.dll", "40420032", "")
  48. L_SCRIPTS_ONLY = GetLocString("GeneralSettings.dll", "40420031", "")
  49. L_SCRIPTS_EXECUTABLES = GetLocString("GeneralSettings.dll", "40420030", "")
  50. L_FAIL_TO_SET_EXECPERMS = GetLocString("GeneralSettings.dll", "C042002F", "")
  51. L_INFORMATION_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C042000F", "")
  52. '-------------------------------------------------------------------------
  53. 'END of localization content
  54. '-------------------------------------------------------------------------
  55. 'Create property page
  56. Dim rc
  57. Dim page
  58. rc=SA_CreatePage(L_EXECTASKTITLETEXT,"",PT_PROPERTY,page)
  59. 'Serve the page
  60. If(rc=0) then
  61. SA_ShowPage(Page)
  62. End if
  63. '-------------------------------------------------------------------------
  64. 'Function: OnInitPage()
  65. 'Description: Called to signal first time processing for this page.
  66. ' Use this method to do first time initialization tasks
  67. 'Input Variables: PageIn,EventArg
  68. 'Output Variables: None
  69. 'Returns: True/False
  70. 'Global Variables: None
  71. '-------------------------------------------------------------------------
  72. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  73. SetVariablesFromSystem()
  74. OnInitPage = True
  75. End Function
  76. '-------------------------------------------------------------------------
  77. 'Function: OnServePropertyPage()
  78. 'Description: Called when the page needs to be served.Use this
  79. ' method to serve content
  80. 'Input Variables: PageIn,EventArg
  81. 'Output Variables: None
  82. 'Returns: True/False
  83. 'Global Variables: None
  84. '-------------------------------------------------------------------------
  85. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  86. Call ServeCommonJavaScript()
  87. Call ServePage()
  88. OnServePropertyPage = True
  89. End Function
  90. '-------------------------------------------------------------------------
  91. 'Function: OnPostBackPage()
  92. 'Description: Called to signal that the page has been posted-back.
  93. 'Input Variables: PageIn,EventArg
  94. 'Output Variables: None
  95. 'Returns: True/False
  96. 'Global Variables: None
  97. '-------------------------------------------------------------------------
  98. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  99. OnPostBackPage = True
  100. End Function
  101. '-------------------------------------------------------------------------
  102. 'Function: OnSubmitPage()
  103. 'Description: Called when the page has been submitted for processing.
  104. ' Use this method to process the submit request.
  105. 'Input Variables: PageIn,EventArg
  106. 'Output Variables: None
  107. 'Returns: True/False
  108. 'Global Variables: None
  109. '-------------------------------------------------------------------------
  110. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  111. OnSubmitPage = ServeVariablesFromForm()
  112. End Function
  113. '-------------------------------------------------------------------------
  114. 'Function: OnClosePage()
  115. 'Description: Called when the page is about closed.Use this method
  116. ' to perform clean-up processing
  117. 'Input Variables: PageIn,EventArg
  118. 'Output Variables: None
  119. 'Returns: True/False
  120. 'Global Variables: None
  121. '-------------------------------------------------------------------------
  122. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  123. OnClosePage = TRUE
  124. End Function
  125. '-------------------------------------------------------------------------
  126. 'Function: ServeCommonJavaScript
  127. 'Description: Serves in initialiging the values,setting the form
  128. ' data and validating the form values
  129. 'Input Variables: None
  130. 'Output Variables: None
  131. 'Returns: True/False
  132. 'Global Variables: None
  133. '-------------------------------------------------------------------------
  134. Function ServeCommonJavaScript()
  135. %>
  136. <!-- #include file="inc_MasterWeb.js" -->
  137. <script language="JavaScript">
  138. function ValidatePage()
  139. {
  140. // validate functions
  141. return true;
  142. }
  143. //init function
  144. function Init()
  145. {
  146. return true;
  147. }
  148. function SetData()
  149. {
  150. return true;
  151. }
  152. </script>
  153. <% End Function
  154. '-------------------------------------------------------------------------
  155. 'Function: ServePage()
  156. 'Description: For displaying outputs HTML to the user
  157. 'Input Variables: None
  158. 'Output Variables: None
  159. 'Returns: None
  160. 'Global Variables: objService
  161. '-------------------------------------------------------------------------
  162. Function ServePage
  163. %>
  164. <%
  165. Dim objSetting
  166. Dim strObjPath
  167. strObjPath = GetIISWMIProviderClassName("IIs_WebServiceSetting") & ".Name='W3SVC'"
  168. set objSetting = objService.Get(strObjPath)
  169. if Err.number <> 0 then
  170. SetErrMsg L_INFORMATION_ERRORMESSAGE
  171. exit function
  172. end if
  173. if objSetting.AccessExecute = TRUE and objSetting.AccessScript = TRUE then
  174. F_selectActiveFormat = L_SCRIPTS_EXECUTABLES
  175. elseif objSetting.AccessExecute = false and objSetting.AccessScript = TRUE then
  176. F_selectActiveFormat = L_SCRIPTS_ONLY
  177. elseif objSetting.AccessExecute = false and objSetting.AccessScript = false then
  178. F_selectActiveFormat = L_NONE
  179. elseif isnull(objSetting.AccessExecute) and isnull(objSetting.AccessScript) then
  180. F_selectActiveFormat = L_NONE
  181. end if
  182. 'Release the object
  183. set objSetting = nothing
  184. %>
  185. <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 class="TasksBody">
  186. <TR>
  187. <TD>
  188. <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 class="TasksBody">
  189. <TD class="TasksBody">
  190. <%= L_EXECUTE_PERMISSIONS %>
  191. </TD>
  192. <TD class="TasksBody">
  193. <SELECT name=selectActiveFormat class="formField" tabIndex=1 size=1>
  194. <%
  195. select case F_selectActiveFormat
  196. case L_NONE
  197. %>
  198. <OPTION selected><%= L_NONE %></OPTION>
  199. <OPTION><%= L_SCRIPTS_ONLY %></OPTION>
  200. <OPTION><%= L_SCRIPTS_EXECUTABLES %></OPTION>
  201. <% case L_SCRIPTS_ONLY %>
  202. <OPTION ><%= L_NONE %></OPTION>
  203. <OPTION selected><%= L_SCRIPTS_ONLY %></OPTION>
  204. <OPTION><%= L_SCRIPTS_EXECUTABLES %></OPTION>
  205. <% case L_SCRIPTS_EXECUTABLES %>
  206. <OPTION ><%= L_NONE %></OPTION>
  207. <OPTION ><%= L_SCRIPTS_ONLY %></OPTION>
  208. <OPTION selected><%= L_SCRIPTS_EXECUTABLES %></OPTION>
  209. <% end select %>
  210. </SELECT>
  211. </TD>
  212. </TABLE>
  213. </TD>
  214. </TR>
  215. <TR>
  216. <TD>
  217. &nbsp;
  218. </TD>
  219. </TR>
  220. <TR>
  221. <TD>
  222. <input type=radio name=optAllSites value="inheritedSites" tabIndex=2 checked onclick = "ClearErr();"> <%=L_APPLYTOINHERITEDIISTEXT%>
  223. </TD>
  224. </TR>
  225. <TR>
  226. <TD>
  227. <input type=radio name=optAllSites value="All" tabIndex=3 onclick="ClearErr();" > <%=L_APPLYTOALLIISTEXT%>
  228. </TD>
  229. </TR>
  230. </TABLE>
  231. <input type=hidden name=hdnPerms value="<%=Server.HTMLEncode(F_selectActiveFormat)%>">
  232. <input type=hidden name=selectSites>
  233. <%
  234. End Function
  235. '-------------------------------------------------------------------------
  236. 'Function name: ServeVariablesFromForm()
  237. 'Description: Serves in getting the data from Client
  238. 'Input Variables: None
  239. 'Output Variables: None
  240. 'Returns: True/False
  241. 'Global Variables: None
  242. '-------------------------------------------------------------------------
  243. Function ServeVariablesFromForm
  244. 'setting the form variables
  245. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  246. F_selectActiveFormat = Request.Form("selectActiveFormat")
  247. F_Sites = Request.Form("selectSites")
  248. F_AllSites = Request.Form("optAllSites")
  249. 'set the master settings
  250. If ExecutePerms()then
  251. ServeVariablesFromForm = true
  252. else
  253. ServeVariablesFromForm = false
  254. end if
  255. End Function
  256. '-------------------------------------------------------------------------
  257. 'Function name: SetVariablesFromSystem
  258. 'Description: Serves in Getting the data from Client
  259. 'Input Variables: None
  260. 'Output Variables: None
  261. 'Returns: None
  262. 'Global Variables: objService
  263. '-------------------------------------------------------------------------
  264. Function SetVariablesFromSystem
  265. 'Getting values from system
  266. Err.Clear
  267. on error Resume next
  268. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  269. End Function
  270. '------------------------------------------------------------------------------------
  271. 'Function name: ExecutePerms
  272. 'Description: Serves in settings the permissions to all and inherited sites
  273. 'Input Variables: None
  274. 'Output Variables: None
  275. 'Returns: boolean
  276. 'Global Variables: objService
  277. '------------------------------------------------------------------------------------
  278. Function ExecutePerms()
  279. Err.Clear
  280. on error Resume next
  281. ExecutePerms = false
  282. 'All Sites
  283. if F_AllSites = "All" then
  284. if NOT SetExecPermsForAllSites(objService) then
  285. ServeFailurePage L_FAIL_TO_SET_EXECPERMS, sReturnURL
  286. end if
  287. end if
  288. 'Inherited Sites
  289. if F_AllSites = "inheritedSites" then
  290. if NOT SetExecPermsForNewSites(objService) then
  291. ServeFailurePage L_FAIL_TO_SET_EXECPERMS, sReturnURL
  292. end if
  293. end if
  294. ExecutePerms = true
  295. 'Release the object
  296. set objService = nothing
  297. end function
  298. '------------------------------------------------------------------------------------
  299. 'Function name: SetExecPermsForNewSites
  300. 'Description: Serves in settings the permissions to only inherited sites
  301. 'Input Variables: None
  302. 'Output Variables: None
  303. 'Returns: boolean
  304. 'Global Variables: objService
  305. '------------------------------------------------------------------------------------
  306. Function SetExecPermsForNewSites(objService)
  307. Err.Clear
  308. on error Resume next
  309. Dim objWeb
  310. Dim instWeb
  311. Dim objSites
  312. Dim strObjPath
  313. SetExecPermsForNewSites =false
  314. strObjPath = GetIISWMIProviderClassName("IIs_WebServiceSetting") & ".Name='W3SVC'"
  315. set objWeb = objService.Get(strObjPath)
  316. if Err.number <> 0 then
  317. SetErrMsg L_INFORMATION_ERRORMESSAGE
  318. exit function
  319. end if
  320. if not setExecPerms(objService,objWeb) then
  321. SA_TraceOut "Web_ExecutePerms", L_FAIL_TO_SET_EXECPERMS
  322. end if
  323. 'release the object
  324. set objWeb = nothing
  325. 'set the exec perms to the appliance site
  326. 'strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name='W3SVC/1/Root'"
  327. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name='" & GetCurrentWebsiteName() & "/Root'"
  328. set objSites = objService.Get(strObjPath)
  329. if Err.number <> 0 then
  330. SetErrMsg L_INFORMATION_ERRORMESSAGE
  331. exit function
  332. end if
  333. objSites.AccessExecute = FALSE
  334. objSites.AccessScript = TRUE
  335. objSites.AccessRead = TRUE
  336. objSites.AccessSource = FALSE
  337. objSites.put_(WBEMFLAG)
  338. if Err.number <> 0 then
  339. SA_TraceOut "Web_ExecutePerms", L_FAIL_TO_SET_EXECPERMS
  340. exit function
  341. end if
  342. 'release the object
  343. set objSites = nothing
  344. SetExecPermsForNewSites =true
  345. End function
  346. '------------------------------------------------------------------------------------
  347. 'Function name: SetExecPermsForAllSites
  348. 'Description: Serves in settings the permissions to all sites
  349. 'Input Variables: None
  350. 'Output Variables: None
  351. 'Returns: boolean
  352. 'Global Variables: objService
  353. '------------------------------------------------------------------------------------
  354. Function SetExecPermsForAllSites(objService)
  355. Err.Clear
  356. on error Resume next
  357. Dim objAllSites
  358. Dim objSites
  359. Dim strObjPath
  360. Dim inst
  361. Dim arrProp(1)
  362. SetExecPermsForAllSites =false
  363. 'Set for Master site
  364. SetExecPermsForNewSites objService
  365. arrProp(0) = "AccessExecute"
  366. arrProp(1) = "AccessScript"
  367. Set objAllSites = GetNonInheritedIISSites(objService, GetIISWMIProviderClassName("IIs_WebVirtualDirSetting"),GetIISWMIProviderClassName("IIS_WebServiceSetting"), arrProp)
  368. if objAllSites.count = 0 then
  369. SetExecPermsForAllSites = true
  370. exit function
  371. end if
  372. for each inst in objAllSites
  373. if not setExecPerms(objService,inst) then
  374. SA_TraceOut "Web_ExecutePerms", L_FAIL_TO_SET_EXECPERMS
  375. end if
  376. next
  377. 'Release the object
  378. set objAllSites = nothing
  379. 'set the exec perms to the appliance site
  380. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name='" & GetCurrentWebsiteName() & "/Root'"
  381. set objSites = objService.Get(strObjPath)
  382. if Err.number <> 0 then
  383. SetErrMsg L_INFORMATION_ERRORMESSAGE
  384. exit function
  385. end if
  386. objSites.AccessExecute = FALSE
  387. objSites.AccessScript = TRUE
  388. objSites.AccessRead = TRUE
  389. objSites.AccessSource = FALSE
  390. objSites.put_(WBEMFLAG)
  391. SetExecPermsForAllSites = true
  392. End function
  393. '------------------------------------------------------------------------------------
  394. 'Function name: setExecPerms
  395. 'Description: Serves in settings the permissions
  396. 'Input Variables: objService, inst
  397. 'Output Variables: None
  398. 'Returns: boolean
  399. 'Global Variables: objService
  400. '------------------------------------------------------------------------------------
  401. Function setExecPerms(objService, inst)
  402. setExecPerms = false
  403. if F_selectActiveFormat = L_SCRIPTS_EXECUTABLES then
  404. inst.AccessRead = TRUE
  405. inst.AccessSource = TRUE
  406. inst.AccessExecute = TRUE
  407. inst.AccessScript = TRUE
  408. elseif F_selectActiveFormat = L_SCRIPTS_ONLY then
  409. inst.AccessSource = FALSE
  410. inst.AccessRead = TRUE
  411. inst.AccessExecute = FALSE
  412. inst.AccessScript = TRUE
  413. elseif F_selectActiveFormat = L_NONE then
  414. inst.AccessSource = FALSE
  415. inst.AccessRead = FALSE
  416. inst.AccessExecute = FALSE
  417. inst.AccessScript = FALSE
  418. end if
  419. inst.put_(WBEMFLAG)
  420. if Err.number <> 0 then
  421. Response.End
  422. SA_TraceOut "Web_ExecutePerms", L_FAIL_TO_SET_EXECPERMS
  423. exit function
  424. end if
  425. setExecPerms = true
  426. End function
  427. %>