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.

787 lines
28 KiB

  1. <%
  2. '-------------------------------------------------------------------------
  3. ' sharecifs_prop.asp: Serves in modifying CIFS share properties.
  4. '
  5. ' Copyright (c) Microsoft Corporation. All rights reserved.
  6. '
  7. ' Date Description
  8. ' 12 March 2001 Creation Date.
  9. '-------------------------------------------------------------------------
  10. '-------------------------------------------------------------------------
  11. 'Form Variables
  12. '-------------------------------------------------------------------------
  13. Dim F_strUserlimitcheck_y 'Allow users radio status value
  14. Dim F_strUserlimitcheck_n 'Allow users radio status value
  15. Dim F_nUserLimit 'Allow User Limit value
  16. Dim F_strUservaluedisable 'Allow user textbox status value
  17. Dim F_strCachinglimitcheck 'Folder caching checkbox status value
  18. Dim F_strLocalUsers 'All local users and groups
  19. Dim F_nCacheOption 'value of the folder cache option
  20. Dim F_UserAccessMaskMaster '* seperated string having access control list of user
  21. Dim F_flagDisable 'Form controls status value used for Hidden shares
  22. Dim F_strPermittedMembers 'Currently selected users and groups
  23. Dim F_strAllowUsersData ', seperated string of allowuser flag and value
  24. Dim F_strComment 'cifs comment
  25. F_strUserlimitcheck_y = "CHECKED"
  26. F_strUserlimitcheck_n = ""
  27. F_nUserLimit = 0
  28. F_strUservaluedisable = "DISABLED"
  29. F_strCachinglimitcheck = "CHECKED"
  30. F_nCacheOption = "0"
  31. F_UserAccessMaskMaster =""
  32. F_strPermittedMembers =""
  33. F_strAllowUsersData =""
  34. F_flagDisable =""
  35. '-------------------------------------------------------------------------
  36. 'Global Variables
  37. '-------------------------------------------------------------------------
  38. Dim G_objService 'object to WMI service
  39. Dim G_strLocalmachinename 'Local machine name
  40. Dim G_strTemp 'Allow user temp array
  41. set G_objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  42. G_strLocalmachinename = GetComputerName()
  43. %>
  44. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js"></script>
  45. <script language="JavaScript" >
  46. // Set the initial form values
  47. function CIFSInit()
  48. {
  49. var objForm
  50. var nCachevalue
  51. objForm = eval("document.frmTask")
  52. //If Domain member listbox is empty then disable listbox add button
  53. if(objForm.lstDomainMembers.length != 0 )
  54. {
  55. objForm.lstDomainMembers.options[0].selected = true;
  56. objForm.btnAddMember.disabled = false;
  57. }
  58. else
  59. {
  60. objForm.btnRemoveMember.disabled = true;
  61. objForm.btnAddMember.disabled = true;
  62. }
  63. /*If selected member listbox is not empty then
  64. select first member else disable remove button and enable add button*/
  65. if(objForm.lstPermittedMembers.length != 0 )
  66. {
  67. objForm.btnAddMember.disabled = false;
  68. objForm.lstPermittedMembers.options[0].selected=true;
  69. setUsermask('<%=G_strLocalmachinename%>');
  70. }
  71. else
  72. {
  73. objForm.btnRemoveMember.disabled = true;
  74. objForm.btnAddMember.disabled = false;
  75. }
  76. //Disable Add button until a charecter is pressed
  77. disableAddButton(document.frmTask.txtDomainUser,document.frmTask.btnAddDomainMember)
  78. //select the folder cache option
  79. nCachevalue = objForm.hdnCacheValue.value;
  80. switch(parseInt(nCachevalue))
  81. {
  82. case 16:
  83. objForm.lstCacheOptions.options[1].selected =true;
  84. break;
  85. case 32:
  86. objForm.lstCacheOptions.options[2].selected =true;
  87. break;
  88. case 48:
  89. objForm.lstCacheOptions.disabled =true;
  90. objForm.chkAllowCaching.checked = false;
  91. break;
  92. default :
  93. objForm.lstCacheOptions.options[0].selected =true;
  94. break;
  95. }
  96. // checks for the default folder cache value
  97. EnableorDisableCacheProp(objForm.chkAllowCaching);
  98. /* Disable cache checkbox,add,remove buttons,
  99. cache listbox for hidden shares*/
  100. if(objForm.hdnDisable.value == "DISABLED" )
  101. {
  102. objForm.btnRemoveMember.disabled =true
  103. objForm.btnAddMember.disabled = true
  104. objForm.chkAllowCaching.disabled = true
  105. objForm.lstCacheOptions.disabled = true
  106. }
  107. }// end of function Init()
  108. // Validate the page form values
  109. function CIFSValidatePage()
  110. {
  111. var objForm
  112. //Throw Error on zero or null user entry in allow user textbox
  113. objForm = eval("document.frmTask")
  114. if(getRadioButtonValue(objForm.radAllowUserlimit) == "n" )
  115. {
  116. if (IsAllSpaces(objForm.txtAllowUserValue.value))
  117. {
  118. DisplayErr("<% =Server.HTMLEncode(SA_EscapeQuotes(L_NOSPACES_ERRORMESSAGE)) %>");
  119. return false;
  120. }
  121. if (objForm.txtAllowUserValue.value == 0)
  122. {
  123. DisplayErr("<% =Server.HTMLEncode(SA_EscapeQuotes(L_ZEROUSERS_ERRORMESSAGE))%>");
  124. return false;
  125. }
  126. }
  127. UpdateHiddenVariables()
  128. return true;
  129. }
  130. //Function to update hidden varibales
  131. function CIFSSetData()
  132. {
  133. UpdateHiddenVariables()
  134. }
  135. //Function to set the hidden varibales to be sent to the server
  136. function UpdateHiddenVariables()
  137. {
  138. var objForm
  139. var strCurrentusers
  140. var intCurrentMembersLength
  141. var strAllowUsersData
  142. strCurrentusers =""
  143. document.frmTask.hdnComment.value=document.frmTask.txtComment.value
  144. objForm = eval("document.frmTask")
  145. intCurrentMembersLength = objForm.lstPermittedMembers.length;
  146. for(var i=0 ; i < intCurrentMembersLength; i++)
  147. {
  148. strCurrentusers = strCurrentusers + String.fromCharCode(1) +
  149. objForm.lstPermittedMembers[i].value + String.fromCharCode(2)+ objForm.lstPermittedMembers[i].text
  150. }
  151. document.frmTask.hdnCurrentUsers.value=strCurrentusers;
  152. if(getRadioButtonValue(objForm.radAllowUserlimit) == "n" )
  153. strAllowUsersData = "n" + "," + objForm.txtAllowUserValue.value;
  154. else
  155. strAllowUsersData = "y" + ",";
  156. objForm.hdnAllowUsers.value = strAllowUsersData;
  157. //if cache options unchecked
  158. if(objForm.chkAllowCaching.checked == false)
  159. {
  160. objForm.hdnCacheValue.value = "48"
  161. }
  162. }
  163. </script>
  164. <% '-------------------------------------------------------------------------
  165. ' Function name: ServePage
  166. ' Description: Serves in displaying the page Header,Middle,Bottom Parts.
  167. ' Input Variables: None.
  168. ' Output Variables: None
  169. ' Return Values: None.
  170. '-------------------------------------------------------------------------
  171. Function ServeCIFSPage
  172. Err.Clear
  173. On Error Resume Next
  174. %>
  175. <table valign="middle" align="left" border="0" cellspacing="0" cellpadding="2" >
  176. <tr>
  177. <td colspan=4 class="TasksBody">
  178. <table>
  179. <tr>
  180. <td class="TasksBody">
  181. <%=L_COMMENT_TEXT%>
  182. </td>
  183. <td class="TasksBody">
  184. &nbsp;&nbsp;&nbsp;<input type="text" name="txtComment" class="FormField" Maxlength="256" value="<%=Server.HTMLEncode(UnescapeChars(ReplaceSubString(F_strComment,"\u0022", """")))%>" size=53>
  185. </td>
  186. </tr>
  187. <tr>
  188. <td class="TasksBody">
  189. <%=L_USERLIMIT_TEXT%>
  190. </td>
  191. <td class="TasksBody">
  192. &nbsp;&nbsp;<input name="radAllowUserlimit" type="radio" class="FormRadioButton" value= "y" tabindex="1" <%=F_strUserlimitcheck_y%> OnClick ="javascript:allowUserValueEdit(this)" >&nbsp;<%=L_MAXIMUMALLOWED_TEXT%>
  193. </td>
  194. </tr>
  195. <tr>
  196. <td class="TasksBody">
  197. &nbsp;
  198. </td>
  199. <td class="TasksBody" align="left">
  200. &nbsp;&nbsp;<input name="radAllowUserlimit" type="radio" class="FormRadioButton" value= "n" <%=F_strUserlimitcheck_n%>
  201. OnClick ="javascript:allowUserValueEdit(this)">&nbsp;<%=L_ALLOW_TEXT%>
  202. <input name="txtAllowUserValue" type="text" class ="FormField" value="<% = F_nUserLimit %>" style="WIDTH=50px"<% =F_strUservaluedisable %> tabindex="2"
  203. OnKeyUP="javaScript:checkUserLimit(this)" OnKeypress="javaScript:checkkeyforNumbers(this)">
  204. </td>
  205. </tr>
  206. </table>
  207. </td>
  208. </tr>
  209. <tr>
  210. <td colspan="4" class="TasksBody">
  211. <input name="chkAllowCaching" type="checkbox" class="FormCheckBox" <%=F_strCachinglimitcheck%> OnClick="EnableorDisableCacheProp(this)" >
  212. &nbsp;<%=L_ALLOWCACHING_TEXT %>
  213. <br>
  214. <br>
  215. <%=L_SETTING_TEXT%> &nbsp;&nbsp;
  216. <select rows="1" name="lstCacheOptions" class ="FormField" onChange="storeCacheProp()" >
  217. <option value="0" selected> <%=L_MANUALCACHEDOCS_TEXT%> </option>
  218. <option value="16"> <%=L_AUTOCACHEDOCS_TEXT %> </option>
  219. <option value="32"> <%=L_AUTOCACHEPROGS_TEXT %> </option>
  220. </select>
  221. <br>
  222. <br>
  223. </td>
  224. </tr>
  225. <tr>
  226. <td colspan="4" class="TasksBody">
  227. <table valign="middle" align="left" border="0" cellspacing="0" cellpadding="2" >
  228. <tr>
  229. <td class="TasksBody">
  230. <%=L_PERMISSIONS_TEXT%>
  231. </td>
  232. <td align ="left" class="TasksBody">
  233. <%=L_ALLOWPROMPT_TEXT%>
  234. </td>
  235. <td align ="left" class="TasksBody">
  236. <%=L_DENYPROMPT_TEXT%>
  237. </td>
  238. </tr>
  239. <tr>
  240. <td class="TasksBody">
  241. <select size="11" name="lstPermittedMembers" class="FormField" onChange="setUsermask('<%=G_strLocalmachinename%>')" <%=F_flagDisable%>>
  242. <%
  243. ServetoListBox(F_strPermittedMembers)
  244. %>
  245. </select>
  246. </td>
  247. <td valign="top" align="center" class="TasksBody">
  248. <select name="lstAllowpermissions" size="1" class="FormField" onChange="JavaScript: setAllowaccess('<%=G_strLocalmachinename%>',lstPermittedMembers)" tabindex="6" <%=F_flagDisable%> >
  249. <option value="4"> <%=L_FULLCONTROL_TEXT%> </option>
  250. <option value="3"> <%=L_CHANGE_TEXT %> </option>
  251. <option value="2"> <%=L_READ_TEXT %> </option>
  252. <option value="1"> <%=L_CHANGEREAD_TEXT %> </option>
  253. <option value="0"> <%=L_NONE_TEXT %> </option>
  254. </select>
  255. <br>
  256. <br>
  257. <%
  258. Call SA_ServeOnClickButtonEx(L_CIFS_ADD_TEXT, "", "addDomainMember(document.frmTask.txtDomainUser)", 60, 0, F_flagDisable, "btnAddDomainMember")
  259. %>
  260. <br>
  261. <br>
  262. <br>
  263. <%
  264. Call SA_ServeOnClickButtonEx(L_CIFS_ADD_TEXT, "", "addMember()", 60, 0, F_flagDisable, "btnAddMember")
  265. %>
  266. <br>
  267. <br>
  268. <%
  269. Call SA_ServeOnClickButtonEx(L_CIFS_REMOVE_TEXT, "", "removeMember()", 60, 0, F_flagDisable, "btnRemoveMember")
  270. %>
  271. </td>
  272. <td valign="top" class="TasksBody">
  273. <select name="lstDenypermissions" size="1" class="FormField" onChange="JavaScript: setDenyaccess('<%=G_strLocalmachinename%>',lstPermittedMembers)" tabindex="7" <%=F_flagDisable%> >
  274. <option value="4"> <%=L_FULLCONTROL_TEXT%> </option>
  275. <option value="3"> <%=L_CHANGE_TEXT %> </option>
  276. <option value="2"> <%=L_READ_TEXT %> </option>
  277. <option value="1"> <%=L_CHANGEREAD_TEXT %> </option>
  278. <option value="0"> <%=L_NONE_TEXT %> </option>
  279. </select>
  280. <br>
  281. <br>
  282. <%=L_CIFSADDUSERORGROUP_TEXT %>
  283. <br>
  284. <input type="text" class="FormField" style="WIDTH:150px" name="txtDomainUser" onKeyUP ="disableAddButton(this,document.frmTask.btnAddDomainMember)" <%=F_flagDisable%> >
  285. <br>
  286. <select class="FormField" multiple size="5" name="lstDomainMembers" <%=F_flagDisable%> >
  287. <%
  288. ServetoListBox(F_strLocalUsers)
  289. %>
  290. </select>
  291. </td>
  292. </tr>
  293. </table>
  294. </td>
  295. </tr>
  296. <tr>
  297. <td colspan="4" class="TasksBody">
  298. <%=L_ADDUSERHELP_TEXT%>
  299. </td>
  300. </tr>
  301. </table>
  302. <%
  303. Call ServeCIFSHiddenValues
  304. End Function
  305. '-------------------------------------------------------------------------
  306. ' Function name: CIFSOnPostBackPage
  307. ' Description: Serves in getting the values from previous form
  308. ' Input Variables: None.
  309. ' Output Variables: None
  310. ' Return Values: None
  311. ' Global Variables: Out: F_strPermittedMembers - Currently selected users
  312. ' and groups
  313. ' Out: F_UserAccessMaskMaster - * seperated string
  314. ' having access control list of user
  315. ' Out: F_nCacheOption -value of the folder cache option
  316. ' Out: F_strAllowUsersData - , seperated string of
  317. ' allowuser flag and value
  318. ' Out: F_flagDisable -Form controls status value
  319. ' Out: G_strTemp -Allow user temp array
  320. ' in: G_objService - object to WMI service
  321. '-------------------------------------------------------------------------
  322. Function CIFSOnPostBackPage
  323. Err.Clear
  324. On Error Resume Next
  325. F_strPermittedMembers = Request.Form ("hdnCurrentUsers")
  326. F_UserAccessMaskMaster = Request.Form ("hdnUserAccessMaskMaster")
  327. F_nCacheOption = Request.Form ("hdnCacheValue")
  328. F_strAllowUsersData = Request.Form ("hdnAllowUsers")
  329. F_flagDisable = Request.Form ("hdnDisable")
  330. F_strComment = Request.Form ("hdnComment")
  331. F_strLocalUsers = getLocalUsersList(G_objService)
  332. F_strLocalUsers = F_strLocalUsers & Getbuiltingroups(G_objService)
  333. F_strLocalUsers = F_strLocalUsers & getGroups(G_objService,G_strLocalmachinename)
  334. G_strTemp = split(F_strAllowUsersData,",")
  335. if G_strTemp(0) = "n" then
  336. checkradio G_strTemp(1),"n"
  337. else
  338. checkradio "","y"
  339. end if
  340. End Function
  341. '-------------------------------------------------------------------------
  342. ' Function name: CIFSOnInitPage
  343. ' Description: Serves in getting the values from system
  344. ' Input Variables: None.
  345. ' Output Variables: None
  346. ' Return Values: None
  347. ' Global Variables: Out: F_strPermittedMembers - Currently selected users
  348. ' and groups
  349. ' Out: F_UserAccessMaskMaster - * seperated string
  350. ' having access control list of user
  351. ' Out: F_nCacheOption -value of the folder cache option
  352. ' Out: F_strAllowUsersData - , seperated string of
  353. ' allowuser flag and value
  354. ' Out: F_flagDisable -Form controls status value
  355. ' in: G_objService - object to WMI service
  356. '-------------------------------------------------------------------------
  357. Function CIFSOnInitPage
  358. Err.Clear
  359. On Error Resume Next
  360. F_strLocalUsers = getLocalUsersList(G_objService)
  361. F_strLocalUsers = F_strLocalUsers & Getbuiltingroups(G_objService)
  362. F_strLocalUsers = F_strLocalUsers & getGroups(G_objService,G_strLocalmachinename)
  363. If instr(F_strShareTypes,"W") > 0 Then
  364. getCIFSshareProp()
  365. GetUsersInShare()
  366. if(F_flagDisable = "") then
  367. F_nCacheOption = getShareCacheProp(F_strShareName)
  368. end If
  369. End if
  370. End Function
  371. '-------------------------------------------------------------------------
  372. ' Function name: SetCIFSshareProp
  373. ' Description: To set the sharedescritpion,maximum allowed users ,
  374. ' users and their allowed permissions of the given share
  375. ' Input Variables: None.
  376. ' Output Variables: None
  377. ' Return Values: True on sucess, False on error (and error msg
  378. ' will be set by SA_SetErrMsg)
  379. ' Global Variables: in: F_strShareName -CIFS share name
  380. ' in: F_UserAccessMaskMaster - * seperated string having access control list of user
  381. ' in: F_nCacheOption -value of the folder cache option
  382. ' in: F_strAllowUsersData - , seperated string of allowuser flag and value
  383. ' in: F_flagDisable -Form controls status value used for Hidden shares
  384. ' in: G_objService - object to WMI service
  385. ' in: L_SHARENAMENOTFOUND_ERRORMESSAGE
  386. ' in: L_FAILEDTOSETSHAREINFO_ERRORMESSAGE
  387. ' Updates system with CIFS properties as given by F_UserAccessMaskMaster. If an error
  388. ' occurs, sets error message with SA_SetErrMsg and exits with False.
  389. '-------------------------------------------------------------------------
  390. function SetCIFSshareProp()
  391. Err.Clear
  392. On Error resume next
  393. Dim objShareInstance
  394. Dim objclass
  395. Dim objSecDescriptor
  396. Dim nRetVal
  397. Dim strDomain
  398. Dim strUser
  399. Dim strAccess
  400. Dim strAce
  401. Dim i
  402. Dim objACE
  403. Dim objTrustee
  404. Dim arrSubAccessMask
  405. DIm arrShareItem
  406. Dim arrUserSID
  407. Dim objDACL
  408. Dim strWMIPath
  409. Dim sEveryone
  410. sEveryone = SA_GetAccount_Everyone()
  411. 'Setting the User EVERYONE deny FullControl Accessmask
  412. If (F_UserAccessMaskMaster = "") then
  413. F_UserAccessMaskMaster = "*" & "" & "," & sEveryone & "," & "0" & "," & "0"
  414. End If
  415. arrSubAccessMask = split(F_UserAccessMaskMaster,"*")
  416. Set objShareInstance = G_objService.Get("Win32_Share.Name=" & chr(34) & F_strShareName & chr(34))
  417. '------------- Localization String -------------
  418. Dim arrVarReplacementString(0)
  419. arrVarReplacementString(0) = F_strShareName
  420. DIM L_SHARENAMENOTFOUND_ERRORMESSAGE
  421. L_SHARENAMENOTFOUND_ERRORMESSAGE = SA_GetLocString("foldermsg.dll", "C03A005B", arrVarReplacementString)
  422. '------------
  423. Dim strNTAuthorityDomainName
  424. Dim strBuiltinDomainName
  425. ' Get localized domain names
  426. strNTAuthorityDomainName = getNTAuthorityDomainName(G_objService)
  427. strBuiltinDomainName = getBuiltinDomainName(G_objService)
  428. If Err.number <> 0 Then
  429. SA_SetErrMsg(L_SHARENAMENOTFOUND_ERRORMESSAGE )
  430. SetCIFSshareProp =FALSE
  431. Exit Function
  432. End If
  433. 'checking whether the added domain user existance
  434. for i=0 to Ubound(arrSubAccessMask)-1
  435. arrShareItem = split(arrSubAccessMask(i+1),",")
  436. strDomain = arrShareItem(0)
  437. strUser = arrShareItem(1)
  438. '------------- Localization String -------------
  439. Dim arrVarReplacementStrings(0)
  440. arrVarReplacementStrings(0) = strDomain & "\" & strUser
  441. DIM L_USERNOTFOUND_ERRORMESSAGE
  442. L_USERNOTFOUND_ERRORMESSAGE = SA_GetLocString("foldermsg.dll", "C03A0062", arrVarReplacementStrings)
  443. '------------
  444. 'Do not check if user is local or SID string
  445. If Left(strUser,1) <> "?" Then
  446. If not( UCASE(strDomain) = UCASE(G_strLocalmachinename) or UCASE(strDomain) = UCASE(strNTAuthorityDomainName) or UCASE(strDomain)= UCASE(strBuiltinDomainName) or strDomain = "" ) then
  447. strWMIPath = "Domain=" & chr(34) & strDomain & chr(34) & "," & "Name=" & chr(34) & strUser & chr(34)
  448. if (not (isValidInstance(G_objService,"Win32_Account",strWMIPath))) then
  449. SA_SetErrMsg L_USERNOTFOUND_ERRORMESSAGE & " (" & Hex(Err.Number) & ")"
  450. SetCIFSshareProp =FALSE
  451. Exit function
  452. End If
  453. End If
  454. End If
  455. Next
  456. Set objclass = G_objService.Get("Win32_SecurityDescriptor")
  457. Set objSecDescriptor = objclass.SpawnInstance_()
  458. 'Hardcoding the Control Flag value
  459. objSecDescriptor.Properties_.Item("ControlFlags") = 32772
  460. objSecDescriptor.Properties_.Item("DACL") = Array()
  461. Set objDACL = objSecDescriptor.Properties_.Item("DACL")
  462. for i=0 to Ubound(arrSubAccessMask)-1
  463. arrShareItem = split(arrSubAccessMask(i+1),",")
  464. strDomain = arrShareItem(0)
  465. strUser = arrShareItem(1)
  466. strAccess = arrShareItem(2)
  467. strAce = arrShareItem(3)
  468. 'If Username has "?" at start of the string then get SID based on SID string
  469. 'Else get SID for username ,Domain.
  470. If Left(strUser,1) <> "?" Then
  471. arrUserSID = getsidvalue(strUser,strDomain)
  472. Else
  473. strUser = Right(strUser, (Len(strUser) - 1))
  474. arrUserSID = getBinarySIDforstirngSID(strUser)
  475. End if
  476. Set objTrustee = SetTrustee(strDomain,strUser,arrUserSID)
  477. Set objACE = SetACE(strAccess, 3, strAce, objTrustee)
  478. objDACL.Value(i) = objACE
  479. Next
  480. if (G_strTemp(0) = "n") then
  481. If (objShareInstance.Type <> 0) then
  482. nRetVal = objShareInstance.SetShareInfo(F_nUserLimit,F_strComment)
  483. else
  484. nRetVal = objShareInstance.SetShareInfo(F_nUserLimit, F_strComment, objSecDescriptor)
  485. End If
  486. else
  487. If (objShareInstance.Type <> 0) then
  488. nRetVal = objShareInstance.SetShareInfo(4294967295,F_strComment)
  489. else
  490. nRetVal = objShareInstance.SetShareInfo(4294967295, F_strComment, objSecDescriptor)
  491. End If
  492. End If
  493. If nRetVal = 0 and Err.number =0 then
  494. SetCIFSshareProp =TRUE
  495. else
  496. SA_SetErrMsg L_FAILEDTOSETSHAREINFO_ERRORMESSAGE & "(" & Err.Number & ")"
  497. SetCIFSshareProp =FALSE
  498. End If
  499. 'setting cache options
  500. If (F_flagDisable = "") then
  501. If(setShareCacheProp(F_strShareName,F_nCacheOption)) then
  502. SetCIFSshareProp =TRUE
  503. else
  504. SetCIFSshareProp =FALSE
  505. end If
  506. End If
  507. SetCIFSshareProp = True
  508. End FUnction
  509. '-------------------------------------------------------------------------
  510. ' Function name: getCIFSshareProp
  511. ' Description: gets the CIFS properties from system
  512. ' Input Variables: None.
  513. ' Output Variables: None
  514. ' Return Values: True on sucess, False on error (and error msg
  515. ' will be set by SA_SetErrMsg)
  516. ' Global Variables: In: F_strShareName -CIFS share name
  517. ' Out: F_flagDisable -Form controls status value used for Hidden shares
  518. ' In: G_objService - object of WMI service
  519. ' In: L_SHARENOTFOUND_ERRORMESSAGE
  520. ' Gets the CIFS Allow maximum values and if share type is hidden the F_flagDisable
  521. ' is assigned "DISABLE".If unable to find the share name then calls
  522. ' servefailure page
  523. '-------------------------------------------------------------------------
  524. Function getCIFSshareProp()
  525. Err.Clear
  526. On Error resume next
  527. Dim objShare
  528. Dim objSharePath
  529. objSharePath = "Win32_Share.Name=" & chr(34) & F_strShareName &chr(34)
  530. set objShare = G_objService.Get(objSharePath)
  531. If Err.Number <> 0 then
  532. Call SA_ServeFailurepageEx(L_SHARENOTFOUND_ERRORMESSAGE,mstrReturnURL)
  533. Exit Function
  534. End If
  535. 'chacking for hidden share type and disabled the some controls
  536. if objShare.Type <> 0 then
  537. F_flagDisable = "DISABLED"
  538. ENd If
  539. If objShare.AllowMaximum = false then
  540. checkradio objShare.MaximumAllowed,"n"
  541. else
  542. checkradio "","y"
  543. End if
  544. getCIFSshareProp = True
  545. End FUnction
  546. '-------------------------------------------------------------------------
  547. ' Function name: GetUsersInShare
  548. ' Description: This will get all the users on the share with Access control list
  549. ' Input Variables: None.
  550. ' Output Variables: None.
  551. ' Return Values: None.
  552. ' Global Variables: in: F_strShareName -CIFS share name
  553. ' Out: F_UserAccessMaskMaster - * seperated string having access control list of user
  554. ' Out: F_strAllowUsersData - , seperated string of allowuser flag and value
  555. ' in: G_objService - object to WMI service
  556. ' in: L_FAILEDTOGET_USERSSHAREINFO_ERRORMESSAGE
  557. ' This will get all the users having access on the share with Access mask values,
  558. ' Into users list separeted by '*' , and with in record of user seperated by ','
  559. ' Format of each user record: " *(Astriscs),User,accessmask, accesstype,alone-'a' or paired-'p' "
  560. ' If the share name is not found in Win32_Logicalsharesecuritysetting
  561. ' class user everyone with allow controll is set. On error displays error using SA_SetErrMsg()
  562. '-------------------------------------------------------------------------
  563. Function GetUsersInShare()
  564. On Error Resume Next
  565. Err.Clear
  566. 'Dim services
  567. Dim objSharePath
  568. Dim objShare
  569. Dim objSecdesc
  570. Dim nRetVal
  571. Dim nAccessMask
  572. Dim nAceType
  573. Dim objPresent_DACL
  574. Dim nTrustees
  575. Dim strMemberToAdd
  576. Dim blnUserFound
  577. Dim i
  578. Dim Temp
  579. Dim strTrusteeName
  580. Dim strTrusteeDomain
  581. Dim strTrusteeSID
  582. Dim blnEmptyUserName
  583. Dim strNTAuthorityDomainName
  584. Dim strBuiltinDomainName
  585. strNTAuthorityDomainName = getNTAuthorityDomainName(G_objService)
  586. strBuiltinDomainName = getBuiltinDomainName(G_objService)
  587. F_UserAccessMaskMaster = "" ' initializing to null
  588. 'Following code adds the members present in share perm
  589. objSharePath = "Win32_LogicalShareSecuritySetting.Name=" & "'" & F_strShareName & "'"
  590. Set objShare = G_objService.Get(objSharePath)
  591. 'if the share name is not found default user Everyone is set to the share with allow read
  592. 'store all the users ,domainname,accessmask, accesstype,old-o or new-n entry,alone-a or paired-p object
  593. if Err.Number <> 0 then
  594. Dim sEveryone
  595. sEveryone = SA_GetAccount_Everyone()
  596. F_strPermittedMembers = F_strPermittedMembers & chr(1)& sEveryone & chr(2)& sEveryone
  597. F_UserAccessMaskMaster = F_UserAccessMaskMaster &"*" & "" &"," & sEveryone & "," & 2032127 &","& 0 & "," & "a"
  598. Exit Function
  599. End If
  600. nRetVal = objShare.getsecuritydescriptor(objSecdesc)
  601. Set objPresent_DACL = objSecdesc.Properties_.Item("DACL")
  602. nTrustees = UBound(objPresent_DACL.Value)
  603. For i = 0 To nTrustees
  604. Set strTrusteeName = objPresent_DACL.Value(i).Properties_.Item("Trustee").Value.Properties_.Item("Name")
  605. Set strTrusteeDomain = objPresent_DACL.Value(i).Properties_.Item _
  606. ("trustee").Value.Properties_.Item("Domain")
  607. nAccessMask = objPresent_DACL.Value(i).Properties_.Item _
  608. ("AccessMask").Value ' Save the accessmask
  609. 'code added to handle empty usernames..
  610. Set strTrusteeSID = objPresent_DACL.Value(i).Properties_.Item _
  611. ("trustee").Value.Properties_.Item("SIDString")
  612. 'If trustee name is NUll then Assign SID value of user to trustee name
  613. blnEmptyUserName = FALSE
  614. If IsNull(strTrusteeName) then
  615. strTrusteeName = strTrusteeSID
  616. blnEmptyUserName = TRUE
  617. End if
  618. nAceType = objPresent_DACL.Value(i).Properties_.Item("AceType").Value
  619. 'If Empty user flag is true then append "?" before trusteename in seraching for paired objects
  620. if (blnEmptyUserName) then
  621. Temp = strTrusteeDomain & "," & "?" & strTrusteeName
  622. Else
  623. Temp = strTrusteeDomain & "," & strTrusteeName
  624. End If
  625. blnUserFound = Instr(F_UserAccessMaskMaster,Temp)
  626. if(strTrusteeName <> "") then
  627. 'checking for the duplicate users in the DACL object
  628. if ((nAceType = 0) and ( blnUserFound = 0))or ((nAceType =1) ) then
  629. 'if user name is SID value then store value of OPTION Output with "?" appended
  630. ' at the start of string but display with same value
  631. If blnEmptyUserName then
  632. F_strPermittedMembers = F_strPermittedMembers & chr(1)& "?" & strTrusteeName & chr(2)& strTrusteeName
  633. else
  634. If (IsNull(strTrusteeDomain) or strTrusteeDomain = "") then
  635. F_strPermittedMembers = F_strPermittedMembers & chr(1) & strTrusteeName & chr(2)& strTrusteeName
  636. else
  637. If instr(strTrusteeDomain,G_strLocalmachinename) > 0 or instr(UCASE(strTrusteeDomain),UCASE(strNTAuthorityDomainName))> 0 or instr(UCASE(strTrusteeDomain),UCASE(strBuiltinDomainName)) > 0 then
  638. F_strPermittedMembers = F_strPermittedMembers & chr(1)& strTrusteeDomain & "\" & strTrusteeName & chr(2)& strTrusteeName
  639. else
  640. F_strPermittedMembers = F_strPermittedMembers & chr(1)& strTrusteeDomain & "\" & strTrusteeName & chr(2)& strTrusteeDomain & "\" & strTrusteeName
  641. End If
  642. End If
  643. End If
  644. End If
  645. 'store all the users ,domainname,accessmask, accesstype,alone-a or paired-p object
  646. 'If Username is not retrived Assign SID value to Username
  647. If blnEmptyUserName then
  648. strTrusteeName = "?" & strTrusteeName
  649. End if
  650. if ( blnUserFound = 0) then
  651. F_UserAccessMaskMaster = F_UserAccessMaskMaster &"*" & strTrusteeDomain &"," & strTrusteeName & "," & nAccessMask &","& nAceType & "," & "a"
  652. else
  653. F_UserAccessMaskMaster = F_UserAccessMaskMaster &"*" & strTrusteeDomain &"," & strTrusteeName & "," & nAccessMask &","& nAceType & "," & "p"
  654. End if
  655. End If 'Enf If for (strTrusteeName <> "")
  656. Next
  657. If Err.number <> 0 then
  658. SA_SetErrMsg L_FAILEDTOGET_USERSSHAREINFO_ERRORMESSAGE & "(" & Err.Number & ")"
  659. End If
  660. End Function
  661. '-------------------------------------------------------------------------
  662. ' Function name: ServeCIFSHiddenValues
  663. ' Description: Serves the hidden HTML fields
  664. ' Input Variables: None.
  665. ' Output Variables: None.
  666. ' Return Values: None
  667. ' Global Variables: F_(*) - form variables
  668. '-------------------------------------------------------------------------
  669. Function ServeCIFSHiddenValues
  670. %>
  671. <input type="hidden" name="hdnCacheValue" value=" <%=F_nCacheOption%> ">
  672. <input type="hidden" name="hdnUserAccessMaskMaster" value="<%= F_UserAccessMaskMaster%>" >
  673. <input type="hidden" name="hdnCurrentUsers" value="<%=F_strPermittedMembers%>">
  674. <input type="hidden" name="hdnAllowUsers" value="<%=F_strAllowUsersData%>" >
  675. <input type="hidden" name="hdnDisable" value="<%=F_flagDisable%>" >
  676. <input type="hidden" name="hdnComment" value="<%=Server.HTMLEncode(UnescapeChars(ReplaceSubString(F_strComment,"\u0022", """")))%>">
  677. <%
  678. End Function
  679. %>