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.

1190 lines
43 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' shares.asp: shares area page - lists all the shares,and provides
  6. ' links for creating new share,editing and deleting shares
  7. '
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Date Description
  11. ' 22-Jan-2001 Creation date
  12. ' 19-Mar-2001 Modified date
  13. '-------------------------------------------------------------------------
  14. %>
  15. <!-- #include virtual="/admin/inc_framework.asp" -->
  16. <!-- #include virtual="/admin/ots_main.asp" -->
  17. <!-- #include file="loc_shares.asp" -->
  18. <!-- #include file="inc_shares.asp" -->
  19. <%
  20. '-------------------------------------------------------------------------
  21. ' Global Variables
  22. '-------------------------------------------------------------------------
  23. Dim rc 'Return value for CreatePage
  24. Dim page 'Variable that receives the output page object
  25. Dim g_bSearchChanged
  26. Dim g_iSearchCol
  27. Dim g_sSearchColValue
  28. Dim g_bPagingInitialized
  29. Dim g_bPageChangeRequested
  30. Dim g_sPageAction
  31. Dim g_iPageMin
  32. Dim g_iPageMax
  33. Dim g_iPageCurrent
  34. Dim g_bSortRequested
  35. Dim g_iSortCol
  36. Dim g_sSortSequence
  37. Dim G_strHost 'Host name
  38. Dim G_objHTTPService 'WMI server HTTP object
  39. Dim G_strAdminSiteID 'HTTP administration web site WMI name
  40. Dim SOURCE_FILE 'To hold source file name
  41. Dim G_objConnection
  42. Dim G_strReturnURL ' to hold the return URL in case of error
  43. '-------------------------------------------------------------------------
  44. ' Global Constants
  45. '-------------------------------------------------------------------------
  46. Const CONST_WINDOWSSHARES="W"
  47. Const CONST_NFSSHARES="U"
  48. Const CONST_FTPSHARES="F"
  49. Const CONST_HTTPSHARES="H"
  50. Const CONST_APPLETALKSHARES="A"
  51. 'holds the number of rows to be displayed in OTS
  52. Const CONST_SHARES_PER_PAGE = 100
  53. 'Registry path for APPLETALK Volumes
  54. CONST CONST_REGISTRY_APPLETALK_PATH ="SYSTEM\CurrentControlSet\Services\MacFile\Parameters\Volumes"
  55. 'Registry path for NFS Exports
  56. CONST CONST_NFS_REGISTRY_PATH ="SOFTWARE\Microsoft\Server For NFS\CurrentVersion\exports"
  57. 'holds the web site name
  58. CONST CONST_ADMINISTRATOR ="Administration"
  59. 'Holds shares web site name
  60. CONST CONST_SHARES ="Shares"
  61. ' Flag to toggle optional tracing output
  62. Const CONST_ENABLE_TRACING = TRUE
  63. SOURCE_FILE = SA_GetScriptFileName()
  64. ' Create Page
  65. rc = SA_CreatePage(L_APPLIANCE_SHARES_TEXT,"", PT_AREA, page )
  66. ' Show page
  67. rc = SA_ShowPage( page )
  68. '---------------------------------------------------------------------
  69. ' Function name: OnInitPage
  70. ' Description: Called to signal first time processing for this page.
  71. ' Input Variables: PageIn and EventArg
  72. ' Output Variables: PageIn and EventArg
  73. ' Return Values: TRUE to indicate initialization was successful. FALSE to indicate
  74. ' errors. Returning FALSE will cause the page to be abandoned.
  75. ' Global Variables: None
  76. ' Called to signal first time processing for this page. Use this method
  77. ' to do first time initialization tasks.
  78. '---------------------------------------------------------------------
  79. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  80. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  81. ' Set default values
  82. ' Sort first column in ascending sequence
  83. g_iSortCol = 1
  84. g_sSortSequence = "A"
  85. ' Paging needs to be initialized
  86. g_bPagingInitialized = FALSE
  87. ' Start on page #1
  88. g_iPageCurrent = 1
  89. 'holds teh URL in case of error
  90. G_strReturnURL = m_VirtualRoot & mstrReturnURL
  91. '---------------------------------------------------------------------
  92. ' This function is called only when the navigation is from Folders area page
  93. If Request.QueryString("ParentPlugin") = "Folders" then
  94. Call SearchFolderPathForShares()
  95. End If
  96. '---------------------------------------------------------------------
  97. G_strHost = GetSystemName() 'Get the system name
  98. Set G_objHTTPService = GetWMIConnection(CONST_WMI_IIS_NAMESPACE) 'get the WMI connection
  99. G_strAdminSiteID = GetWebSiteID(CONST_ADMINISTRATOR ) 'get the Web site ID
  100. 'Function call to update the text file for shares default page
  101. Call GenSharesPage(G_strHost , GetWebSiteID(CONST_SHARES))
  102. OnInitPage = TRUE
  103. End Function
  104. '---------------------------------------------------------------------
  105. ' Function name: OnServeAreaPage
  106. ' Description: Called when the page needs to be served.
  107. ' Input Variables: PageIn, EventArg
  108. ' Output Variables: PageIn, EventArg
  109. ' Return Values: TRUE to indicate no problems occured. FALSE to indicate errors.
  110. ' Returning FALSE will cause the page to be abandoned.
  111. ' Global Variables: G_objHTTPService
  112. '---------------------------------------------------------------------
  113. Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  114. OnServeAreaPage = ServeSharesObjectPicker() 'serves the list with the shares
  115. 'Release the objects
  116. Set G_objHTTPService = Nothing
  117. End Function
  118. '---------------------------------------------------------------------
  119. ' Function: OnSearchNotify()
  120. ' Description: Search notification event handler. When one or more columns are
  121. ' marked with the OTS_COL_SEARCH flag, the Web Framework fires
  122. ' this event in the following scenarios:
  123. '
  124. ' 1) The user presses the search Go button.
  125. ' 2) The user requests a table column sort
  126. ' 3) The user presses either the page next or page previous buttons
  127. '
  128. ' The EventArg indicates the source of this notification event which can
  129. ' be either a search change event (scenario 1) or a post back event
  130. ' (scenarios 2 or 3)
  131. ' Input Variables: PageIn,EventArg,sItem,sValue
  132. ' Output Variables: PageIn,EventArg,sItem,sValue
  133. ' Return Values: Always returns TRUE
  134. ' Global Variables: In:g_iSearchCol,g_sSearchColValue,g_bSearchRequested,g_bSearchChanged
  135. '---------------------------------------------------------------------
  136. Public Function OnSearchNotify(ByRef PageIn, _
  137. ByRef EventArg, _
  138. ByRef sItem, _
  139. ByRef sValue )
  140. OnSearchNotify = TRUE
  141. '
  142. ' User pressed the search GO button
  143. '
  144. If SA_IsChangeEvent(EventArg) Then
  145. If ( CONST_ENABLE_TRACING ) Then
  146. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Change Event Fired")
  147. End If
  148. g_bSearchChanged = TRUE
  149. g_iSearchCol = Int(sItem)
  150. g_sSearchColValue = CStr(sValue)
  151. '
  152. ' User clicked a column sort, OR clicked either the page next or page prev button
  153. ElseIf SA_IsPostBackEvent(EventArg) Then
  154. If ( CONST_ENABLE_TRACING ) Then
  155. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Postback Event Fired")
  156. End If
  157. g_bSearchChanged = FALSE
  158. g_iSearchCol = Int(sItem)
  159. g_sSearchColValue = CStr(sValue)
  160. '
  161. ' Unknown event source
  162. Else
  163. If ( CONST_ENABLE_TRACING ) Then
  164. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  165. End If
  166. End IF
  167. End Function
  168. '---------------------------------------------------------------------
  169. ' Function: OnPagingNotify()
  170. ' Function name: OnPagingNotify()
  171. ' Description: Paging notification event handler.
  172. ' Input Variables: PageIn,EventArg,sPageAction,iPageMin,iPageMax,iPageCurrent
  173. ' Output Variables: PageIn,EventArg
  174. ' Return Values: Always returns TRUE
  175. ' Global Variables: G_*
  176. '---------------------------------------------------------------------
  177. Public Function OnPagingNotify(ByRef PageIn, _
  178. ByRef EventArg, _
  179. ByVal sPageAction, _
  180. ByVal iPageMin, _
  181. ByVal iPageMax, _
  182. ByVal iPageCurrent )
  183. OnPagingNotify = TRUE
  184. g_bPagingInitialized = TRUE
  185. '
  186. ' User pressed either page next or page previous
  187. '
  188. If SA_IsChangeEvent(EventArg) Then
  189. If ( CONST_ENABLE_TRACING ) Then
  190. Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Change Event Fired")
  191. End If
  192. g_bPageChangeRequested = TRUE
  193. g_sPageAction = CStr(sPageAction)
  194. g_iPageMin = iPageMin
  195. g_iPageMax = iPageMax
  196. g_iPageCurrent = iPageCurrent
  197. '
  198. ' User clicked a column sort OR the search GO button
  199. ElseIf SA_IsPostBackEvent(EventArg) Then
  200. If ( CONST_ENABLE_TRACING ) Then
  201. Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Postback Event Fired")
  202. End If
  203. g_bPageChangeRequested = FALSE
  204. g_sPageAction = CStr(sPageAction)
  205. g_iPageMin = iPageMin
  206. g_iPageMax = iPageMax
  207. g_iPageCurrent = iPageCurrent
  208. '
  209. ' Unknown event source
  210. Else
  211. If ( CONST_ENABLE_TRACING ) Then
  212. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnPagingNotify()")
  213. End If
  214. End IF
  215. End Function
  216. '---------------------------------------------------------------------
  217. ' Function: OnSortNotify()
  218. ' Function name: GetServices
  219. ' Description: Sorting notification event handler.
  220. ' Input Variables: PageIn,EventArg,sortCol,sortSeq
  221. ' Output Variables: PageIn,EventArg
  222. ' Return Values: Always returns TRUE
  223. ' Global Variables: G_*
  224. '---------------------------------------------------------------------
  225. Public Function OnSortNotify(ByRef PageIn, _
  226. ByRef EventArg, _
  227. ByVal sortCol, _
  228. ByVal sortSeq )
  229. OnSortNotify = TRUE
  230. '
  231. ' User pressed column sort
  232. '
  233. If SA_IsChangeEvent(EventArg) Then
  234. If ( CONST_ENABLE_TRACING ) Then
  235. Call SA_TraceOut(SOURCE_FILE, "OnSortNotify() Change Event Fired")
  236. End If
  237. g_iSortCol = sortCol
  238. g_sSortSequence = sortSeq
  239. g_bSortRequested = TRUE
  240. '
  241. ' User presed the search GO button OR clicked either the page next or page prev button
  242. ElseIf SA_IsPostBackEvent(EventArg) Then
  243. If ( CONST_ENABLE_TRACING ) Then
  244. Call SA_TraceOut(SOURCE_FILE, "OnSortNotify() Postback Event Fired")
  245. End If
  246. g_iSortCol = sortCol
  247. g_sSortSequence = sortSeq
  248. g_bSortRequested = TRUE
  249. '
  250. ' Unknown event source
  251. Else
  252. If ( CONST_ENABLE_TRACING ) Then
  253. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  254. End If
  255. End IF
  256. If ( CONST_ENABLE_TRACING ) Then
  257. Call SA_TraceOut(SOURCE_FILE, "Sort col: " + CStr(sortCol) + " sequence: " + sortSeq)
  258. End If
  259. End Function
  260. '-------------------------------------------------------------------------
  261. ' Function name: ServeSharesObjectPicker
  262. ' Description: Gets Shares from SA and outputs to the
  263. ' Share Objectpicker control.On error of creating or
  264. ' displaying of rows, columns and table an appropriate
  265. ' error message is displayed by calling SA_ServeFailurepage.
  266. ' Input Variables: None
  267. ' Output Variables: None
  268. ' Returns: None
  269. ' Global Variables: in: L_* - Localization strings
  270. '-------------------------------------------------------------------------
  271. Function ServeSharesObjectPicker()
  272. Err.Clear
  273. On Error Resume Next
  274. Dim objTableShare 'hold the Table object
  275. Dim nReturnValue 'hold the return value
  276. Dim strShr 'hold the Share as string
  277. Dim strKey 'hold the dictionary object key
  278. Dim objDict 'hold the dictionary object
  279. Dim strShrName 'hold the Sshare name
  280. DIm strShrPath 'hold the Share Path
  281. Dim strShrTypes 'hold Share type
  282. Dim strShrDesc 'hold the Share description
  283. Dim arrDicItems 'hold Dictionary object items
  284. Dim strURL 'hold URL
  285. Dim i
  286. Dim nShareCount 'hold the row count
  287. Dim nColumnSharedFolder 'hold the index of Shared folder column
  288. Dim nColumnSharedPath 'hold the index of Shared Path column
  289. Dim nColumnType 'hold the index of Type column
  290. Dim nColumnDescription 'hold the index of Description column
  291. Dim colFlags 'hold the flag
  292. ' Create Appliance Shares table
  293. objTableShare = OTS_CreateTable(L_APPLIANCE_SHARES_TEXT , L_DESCRIPTION_HEADING_TEXT )
  294. ' If the search criteria changed Then we need to recompute the paging range
  295. If ( TRUE = g_bSearchChanged ) Then
  296. '
  297. ' Need to recalculate the paging range
  298. g_bPagingInitialized = FALSE
  299. '
  300. ' Restarting on page #1
  301. g_iPageCurrent = 1
  302. End If
  303. ' Create hidden column and add them to the table
  304. nColumnSharedFolder=0
  305. colFlags = (OTS_COL_FLAG_HIDDEN OR OTS_COL_KEY OR OTS_COL_SORT)
  306. nReturnValue=OTS_AddTableColumn(objTableShare, OTS_CreateColumn(L_COLUMN_SHAREDFOLDER_TEXT,"left",colFlags))
  307. If nReturnValue <> gc_ERR_SUCCESS Then
  308. Call SA_ServeFailurepageEx(L_FAILEDTOADDCOLOUMN_ERRORMESSAGE,G_strReturnURL)
  309. End IF
  310. nColumnSharedFolder=1
  311. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  312. nReturnValue = OTS_AddTableColumn(objTableShare, OTS_CreateColumnEx(L_COLUMN_SHAREDFOLDER_TEXT ,"left",colFlags, 16))
  313. If nReturnValue <> gc_ERR_SUCCESS Then
  314. Call SA_ServeFailurepageEx(L_FAILEDTOADDCOLOUMN_ERRORMESSAGE,G_strReturnURL)
  315. End IF
  316. nColumnSharedPath=2
  317. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  318. nReturnValue = OTS_AddTableColumn(objTableShare, OTS_CreateColumnEx(L_COLUMN_SHAREDPATH_TEXT,"left", colFlags, 20))
  319. If nReturnValue <> gc_ERR_SUCCESS Then
  320. Call SA_ServeFailurepageEx(L_FAILEDTOADDCOLOUMN_ERRORMESSAGE,G_strReturnURL)
  321. End IF
  322. nColumnType=3
  323. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY)
  324. nReturnValue = OTS_AddTableColumn(objTableShare, OTS_CreateColumnEx(L_COLUMN_TYPE_TEXT,"left", colFlags, 12))
  325. If nReturnValue <> gc_ERR_SUCCESS Then
  326. Call SA_ServeFailurepageEx(L_FAILEDTOADDCOLOUMN_ERRORMESSAGE,G_strReturnURL)
  327. End IF
  328. nColumnDescription=4
  329. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  330. nReturnValue = OTS_AddTableColumn(objTableShare, OTS_CreateColumnEx(L_COLUMN_DESCRIPTION_TEXT,"left", colFlags, 25))
  331. If nReturnValue <> gc_ERR_SUCCESS Then
  332. Call SA_ServeFailurepageEx(L_FAILEDTOADDCOLOUMN_ERRORMESSAGE,G_strReturnURL)
  333. End IF
  334. ' Taking the instance of Dictionary Object to place all shares
  335. ' in Dictionay object.
  336. Set objDict=server.CreateObject("scripting.dictionary")
  337. If Err.number <>0 Then
  338. Call SA_ServeFailurepageEx(L_DICTIONARYOBJECTINSTANCEFAILED_ERRORMESSAGE,G_strReturnURL)
  339. End If
  340. ' Setting the property of Dictionary object to compare the shares in
  341. ' incase sensitive
  342. objDict.CompareMode= vbTextCompare
  343. ' Add all shares to shares table
  344. ' Gets all windows shares with name,path and description and type
  345. Call GetCifsShares(objDict)
  346. 'to make the checkbox disable if the service is not installed
  347. Set G_objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  348. If isServiceInstalled(G_objConnection,"nfssvc") Then
  349. ' Gets all unix shares with name,path and type
  350. Call GetNfsshares(objDict)
  351. End if
  352. ' Gets all Ftp shares with name,path and type
  353. Call GetFtpShares(objDict)
  354. ' Gets all Http shares with name,path and type
  355. Call GetHttpShares(objDict)
  356. If isServiceInstalled(G_objConnection,"MacFile") Then
  357. ' Gets all AppleTalk shares with name,path and type
  358. Call GetAppleTalkShares(objDict)
  359. End if
  360. ' Store all share type such that we can display appropriate help message
  361. Dim strAllShrTypes
  362. strAllShrTypes = ""
  363. ' Displaying all shares In Object Picker Control
  364. nShareCount =0
  365. for each strkey in objDict.Keys
  366. strShr=split(strKey,chr(1))
  367. arrDicItems = split(objDict.Item(strKey),chr(1))
  368. strShrDesc = arrDicItems(0)
  369. strShrTypes = arrDicItems(1)
  370. strShrName = strShr(0)
  371. strShrPath = strShr(1)
  372. If (g_bSearchRequested) Then
  373. If ( Len( g_sSearchColValue ) <= 0 ) Then
  374. nShareCount=nShareCount+1
  375. ' Verify that the current user part of the current page
  376. If ( IsItemOnPage(nShareCount, g_iPageCurrent, CONST_SHARES_PER_PAGE) ) Then
  377. Call OTS_AddTableRow(objTableShare, Array(replace(strShrName+chr(1)+strShrPath+chr(1)+strShrTypes+chr(1)+strShrDesc,"\","/"),strShrName,strShrPath,strShrTypes ,strShrDesc))
  378. ' Save all types displayed
  379. strAllShrTypes = strAllShrTypes + strShrTypes
  380. End If
  381. Else
  382. Select Case (g_iSearchCol)
  383. Case nColumnSharedFolder
  384. If ( InStr(1,strShrName, trim(g_sSearchColValue), 1) ) Then
  385. nShareCount=nShareCount+1
  386. If ( IsItemOnPage(nShareCount, g_iPageCurrent, CONST_SHARES_PER_PAGE) ) Then
  387. Call OTS_AddTableRow(objTableShare, Array(replace(strShrName+chr(1)+strShrPath+chr(1)+strShrTypes+chr(1)+strShrDesc,"\","/"),strShrName,strShrPath,strShrTypes ,strShrDesc))
  388. ' Save all types displayed
  389. strAllShrTypes = strAllShrTypes + strShrTypes
  390. End If
  391. End If
  392. Case nColumnSharedPath
  393. If ( InStr(1,strShrPath, trim(g_sSearchColValue), 1) ) Then
  394. nShareCount=nShareCount+1
  395. If ( IsItemOnPage(nShareCount, g_iPageCurrent, CONST_SHARES_PER_PAGE) ) Then
  396. Call OTS_AddTableRow( objTableShare, Array(replace(strShrName+chr(1)+strShrPath+chr(1)+strShrTypes+chr(1)+strShrDesc,"\","/"),strShrName,strShrPath,strShrTypes ,strShrDesc))
  397. ' Save all types displayed
  398. strAllShrTypes = strAllShrTypes + strShrTypes
  399. End If
  400. End If
  401. Case nColumnType
  402. If ( InStr(1,strShrTypes, trim(g_sSearchColValue), 1) ) Then
  403. nShareCount=nShareCount+1
  404. If ( IsItemOnPage(nShareCount, g_iPageCurrent, CONST_SHARES_PER_PAGE) ) Then
  405. Call OTS_AddTableRow( objTableShare, Array(replace(strShrName+chr(1)+strShrPath+chr(1)+strShrTypes+chr(1)+strShrDesc,"\","/"),strShrName,strShrPath,strShrTypes ,strShrDesc))
  406. ' Save all types displayed
  407. strAllShrTypes = strAllShrTypes + strShrTypes
  408. End If
  409. End If
  410. Case nColumnDescription
  411. If ( InStr(1,strShrDesc, trim(g_sSearchColValue), 1) ) Then
  412. nShareCount=nShareCount+1
  413. If ( IsItemOnPage(nShareCount, g_iPageCurrent, CONST_SHARES_PER_PAGE) ) Then
  414. Call OTS_AddTableRow( objTableShare, Array(replace(strShrName+chr(1)+strShrPath+chr(1)+strShrTypes+chr(1)+strShrDesc,"\","/"),strShrName,strShrPath,strShrTypes ,strShrDesc))
  415. ' Save all types displayed
  416. strAllShrTypes = strAllShrTypes + strShrTypes
  417. End If
  418. End If
  419. Case Else
  420. nShareCount=nShareCount+1
  421. If ( IsItemOnPage(nShareCount, g_iPageCurrent, CONST_SHARES_PER_PAGE) ) Then
  422. Call OTS_AddTableRow(objTableShare, Array(replace(strShrName+chr(1)+strShrPath+chr(1)+strShrTypes+chr(1)+strShrDesc,"\","/"),strShrName,strShrPath,strShrTypes ,strShrDesc))
  423. ' Save all types displayed
  424. strAllShrTypes = strAllShrTypes + strShrTypes
  425. End If
  426. End Select
  427. End If
  428. Else
  429. ' Search not enabled, select all rows
  430. Call OTS_AddTableRow( objTableShare, Array(replace(strShrName+chr(1)+strShrPath+chr(1)+strShrTypes+chr(1)+strShrDesc,"\","/"),strShrName,strShrPath,strShrTypes,strShrDesc))
  431. ' Save all types displayed
  432. strAllShrTypes = strAllShrTypes + strShrTypes
  433. End If
  434. Next
  435. ' Add Tasks
  436. nReturnValue = OTS_SetTableTasksTitle(objTableShare,L_SHARETASKTITLE_TEXT)
  437. ' New user Task is always available (OTS_TaskAlways)
  438. 'Munge the URL with tabs
  439. strURL = "shares/share_new.asp"
  440. Call SA_MungeURL(strURL,"Tab1",GetTab1())
  441. Call SA_MungeURL(strURL,"Tab2",GetTab2())
  442. nReturnValue =OTS_AddTableTask( objTableShare, OTS_CreateTaskEx(L_SHARESSERVEAREABUTTON_NEW_TEXT, _
  443. L_NEWSHARE_ROLLOVERTEXT_TEXT, _
  444. strURL,_
  445. OTS_PT_TABBED_PROPERTY,_
  446. "OTS_TaskAlways") )
  447. ' Error handling when any error occurs at the time of adding a Task
  448. ' to The object picker control.
  449. If nReturnValue <> gc_ERR_SUCCESS Then
  450. Call SA_ServeFailurepageEx(L_FAILEDTOADDTASK_ERRORMESSAGE,G_strReturnURL)
  451. End If
  452. 'Munge the URL with tabs
  453. strURL = "shares/share_delete.asp"
  454. Call SA_MungeURL(strURL,"Tab1",GetTab1())
  455. Call SA_MungeURL(strURL,"Tab2",GetTab2())
  456. ' Delete user Task is available If any task is selected (OTS_TaskAny)
  457. nReturnValue = OTS_AddTableTask( objTableShare, OTS_CreateTaskEx(L_SHARESSERVEAREABUTTON_DELETE_TEXT, _
  458. L_SHAREDELETE_ROLLOVERTEXT_TEXT, _
  459. strURL,_
  460. OTS_PT_PROPERTY,_
  461. "OTS_TaskAny") )
  462. If nReturnValue <> gc_ERR_SUCCESS Then
  463. Call SA_ServeFailurepageEx(L_FAILEDTOADDTASK_ERRORMESSAGE,G_strReturnURL)
  464. End If
  465. 'Set properties for individual shares
  466. 'Munge the URL with tabs
  467. strURL = "shares/share_prop.asp"
  468. Call SA_MungeURL(strURL,"Tab1",GetTab1())
  469. Call SA_MungeURL(strURL,"Tab2",GetTab2())
  470. nReturnValue =OTS_AddTableTask(objTableShare, OTS_CreateTaskEx(L_SHARESSERVEAREABUTTON_PROPERTIES_TEXT, _
  471. L_SHAREPROPERTIES_ROLLOVERTEXT_TEXT, _
  472. strURL,_
  473. OTS_PT_TABBED_PROPERTY,_
  474. "OTS_TaskOne") )
  475. If nReturnValue <> gc_ERR_SUCCESS Then
  476. Call SA_ServeFailurepageEx(L_FAILEDTOADDTASK_ERRORMESSAGE,G_strReturnURL)
  477. End If
  478. 'Enable paging
  479. Call OTS_EnablePaging(objTableShare, TRUE)
  480. '
  481. ' If paging range needs to be initialised Then
  482. ' we need to figure out how many pages we are going to display
  483. If ( FALSE = g_bPagingInitialized ) Then
  484. g_iPageMin = 1
  485. g_iPageMax = Int(nShareCount / CONST_SHARES_PER_PAGE )
  486. If ( (nShareCount MOD CONST_SHARES_PER_PAGE) > 0 ) Then
  487. g_iPageMax = g_iPageMax + 1
  488. End If
  489. g_iPageCurrent = 1
  490. Call OTS_SetPagingRange(objTableShare, g_iPageMin, g_iPageMax, g_iPageCurrent)
  491. End If
  492. ' Enable table multiselection
  493. Call OTS_SetTableMultiSelection(objTableShare, true)
  494. ' Sort the table
  495. Call OTS_SortTable (objTableShare, g_iSortCol, g_sSortSequence, SA_RESERVED)
  496. nReturnValue = OTS_ServeTable(objTableShare)
  497. '
  498. ' Add appropriate abbreviations
  499. '
  500. Dim strShareAbbreviations
  501. strShareAbbreviations = ""
  502. if instr(strAllShrTypes, CONST_WINDOWSSHARES) then
  503. strShareAbbreviations = strShareAbbreviations + L_WINDOWSSHARES_ABBREVITION_TEXT + "&nbsp;&nbsp;&nbsp;&nbsp;"
  504. end if
  505. if instr(strAllShrTypes, CONST_NFSSHARES) then
  506. strShareAbbreviations = strShareAbbreviations + L__NFSSHARES_ABBREVITION_TEXT + "&nbsp;&nbsp;&nbsp;&nbsp;"
  507. end if
  508. if instr(strAllShrTypes, CONST_FTPSHARES) then
  509. strShareAbbreviations = strShareAbbreviations + L_FTPSHARES_ABBREVITION_TEXT + "&nbsp;&nbsp;&nbsp;&nbsp;"
  510. end if
  511. if instr(strAllShrTypes, CONST_HTTPSHARES) then
  512. strShareAbbreviations = strShareAbbreviations + L_HTTPSHARES_ABBREVITION_TEXT + "&nbsp;&nbsp;&nbsp;&nbsp;"
  513. end if
  514. if instr(strAllShrTypes, CONST_APPLETALKSHARES) then
  515. strShareAbbreviations = strShareAbbreviations + L_APPLETALKSHARES_ABBREVITION_TEXT + "&nbsp;&nbsp;&nbsp;&nbsp;"
  516. end if
  517. Response.write "<br>"& strShareAbbreviations
  518. If nReturnValue <> gc_ERR_SUCCESS OR Err.number <> 0 Then
  519. Call SA_ServeFailurepageEx(L_FAILEDTOSHOW_ERRORMESSAGE,G_strReturnURL)
  520. End If
  521. ' Destroying dynamically created objects.
  522. Set objDict=Nothing
  523. End Function
  524. '---------------------------------------------------------------------
  525. ' Function: IsItemOnPage()
  526. ' Description: VerIfy that the current user part of the current page.
  527. ' Input Variables: iCurrentItem
  528. ' Output Variables: None
  529. ' Return Values: TRUE or FALSE
  530. ' Global Variables: None
  531. '---------------------------------------------------------------------
  532. Private Function IsItemOnPage(ByVal iCurrentItem, iCurrentPage, iItemsPerPage)
  533. Dim iLowerLimit
  534. Dim iUpperLimit
  535. iLowerLimit = ((iCurrentPage - 1) * iItemsPerPage )
  536. iUpperLimit = iLowerLimit + iItemsPerPage + 1
  537. If ( iCurrentItem > iLowerLimit AND iCurrentItem < iUpperLimit ) Then
  538. IsItemOnPage = TRUE
  539. Else
  540. IsItemOnPage = FALSE
  541. End If
  542. End Function
  543. '-------------------------------------------------------------------------
  544. ' Sub Routine name: GetCIfsShares()
  545. ' Description: Gets Windows Shares from SA machine and Adds
  546. ' to Dictionary Object.
  547. ' Input Variables: objDict(dictionary object)
  548. ' Output Variables: None
  549. ' Returns: None
  550. ' Global Variables: in: L_WMICLASSINSTANCEFAILED_ERRORMESSAGE
  551. ' G_strHost
  552. '-------------------------------------------------------------------------
  553. Sub GetCifsShares(Byref objDict)
  554. Err.Clear
  555. On Error Resume Next
  556. Dim objShareObject 'hold Share object
  557. Dim strShare 'hold instance of share object
  558. Dim strQuery 'hold query string
  559. Dim strLanMan 'hold lanmanserver string
  560. Dim strDictValue 'hold string to pass it to Dictionary object
  561. Dim objService
  562. strLanMan = "/lanmanserver"
  563. set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  564. strQuery="SELECT name,path,description FROM Win32_SHARE"
  565. Set objShareObject=GetObject("WinNT://" & G_strHost & "/LanmanServer")
  566. ' If instance of the wmi class is failed
  567. If Err.number <>0 Then
  568. Call SA_ServeFailurepageEx(L_WMICLASSINSTANCEFAILED_ERRORMESSAGE,G_strReturnURL)
  569. End If
  570. for each strShare in objShareObject
  571. 'Check if the associated folder is exist. If it's not exist, delete the share
  572. 'Notice that's a W2k problem. In XP, share will be deleted automatically when
  573. 'the associated folder is deleted.
  574. If Not isPathExisting(strShare.Path) Then
  575. If not deleteShareCIFS(objService, strShare.Name) then
  576. Call SA_TraceOut(SOURCE_FILE, "GetCifsShares: Delete orphan share Failed with Error:"+Hex(Err.Number))
  577. End If
  578. Else
  579. strDictValue = Mid( strShare.adspath, instr( UCASE( strShare.adspath ), UCASE( strLanMan ) ) + _
  580. len(strLanMan) + 1, len(strShare.adspath) - _
  581. instr( UCASE( strShare.adspath ), UCASE( strLanMan ) ) + len(strLanMan ) )
  582. ' Adding all windows shares to the Dictionary object one by one as "sharename &chr(1)& sharepath" as Key and "share description &chr(1)&share type" as a "Value"
  583. objDict.Add strDictValue & chr(1) & strShare.path , strShare.description & chr(1) &"W"
  584. End If
  585. next
  586. ' Destroying dynamically created objects
  587. Set objShareObject = Nothing
  588. End Sub
  589. '----------------------------------------------------------------------------------------
  590. ' Sub Routine name: GetNfsShares()
  591. ' Description: gets all Nfs Shares from SA machine and adds to Dictionary Object
  592. ' Input Variables: objDict(dictionary object)
  593. ' Output Variables: None
  594. ' Returns: None
  595. ' Global Variables: in: CONST_NFS_REGISTRY_PATH - Registry path to access Nfs Shares
  596. '-----------------------------------------------------------------------------------------
  597. Sub GetNfsShares(ByRef objDict)
  598. Err.Clear
  599. On Error Resume Next
  600. Dim objRegistryHandle 'hold Registry connection
  601. Dim intenumkey 'hold enum key value as INTEGER
  602. Dim strenumvalue 'hold enum key value as STRING
  603. Dim strenumstringval 'hold enum key value as STRING
  604. Dim strenumstringpath 'hold value of the registry key
  605. Dim nidx 'hold count
  606. Dim ObjConnection 'hold WMI connection object
  607. Dim strDictValue 'hold item of dictionary object
  608. Dim strShareString 'hold the share as STRING
  609. Const CONST_NFS="nfssvc"
  610. 'get the WMI connection
  611. Set ObjConnection = getWMIConnection("Default")
  612. ' Check whether the service is installed on the machine or not
  613. If not IsServiceInstalled(ObjConnection,CONST_NFS) Then
  614. Exit Sub
  615. End If
  616. ' Get the registry connection Object.
  617. Set objRegistryHandle = RegConnection()
  618. ' RegEnumKey function gets the Subkeys in the given Key and Returns
  619. ' an array containing sub keys from registry
  620. intenumkey = RegEnumKey(objRegistryHandle,CONST_NFS_REGISTRY_PATH)
  621. For nidx= 0 to (ubound(intenumkey))
  622. ' RegEnumKeyValues function Gets the values in the given SubKey
  623. ' and Returns an array containing sub keys
  624. strenumvalue = RegEnumKeyValues(objRegistryHandle,CONST_NFS_REGISTRY_PATH & "\" & intenumkey(nidx))
  625. ' getRegkeyvalue function gets the value in the registry for a given
  626. ' value and returns the value of the requested key
  627. strenumstringpath = getRegkeyvalue(objRegistryHandle,CONST_NFS_REGISTRY_PATH & "\" & intenumkey(nidx),strenumvalue(0),CONST_STRING)
  628. strenumstringval = getRegkeyvalue(objRegistryHandle,CONST_NFS_REGISTRY_PATH & "\" & intenumkey(nidx),strenumvalue(1),CONST_STRING)
  629. strShareString=strenumstringval &chr(1) & strenumstringpath
  630. ' Checking for same share with share path is existing in dictionary object.
  631. If objDict.Exists(strShareString) Then
  632. strDictValue= objDict.Item(strShareString) & " U" 'append 'U' to identify as NFS share
  633. objDict.Item(strShareString)= strDictValue
  634. else
  635. If strenumstringval <> "" Then
  636. objDict.Add strShareString,chr(1) & "U"
  637. End If
  638. End If
  639. Next
  640. ' Destroying dynamically created objects
  641. Set ObjConnection = Nothing
  642. Set objRegistryHandle = Nothing
  643. End Sub
  644. '-------------------------------------------------------------------------------------
  645. ' Sub Routine name: GetFtpShares
  646. ' Description: Gets Ftp Shares from SA machine and adds to Dictionary Object.
  647. ' Input Variables: objDict(dictionary object)
  648. ' Output Variables: None
  649. ' Returns: None
  650. ' Global Variables: in: L_WMICLASSINSTANCEFAILED_ERRORMESSAGE
  651. '-------------------------------------------------------------------------------------
  652. Sub GetFtpShares(ByRef objDict)
  653. Err.Clear
  654. on error resume next
  655. Dim objConnection 'hold Connection name
  656. Dim objFtpnames 'hold Ftp VirtualDir object
  657. Dim instFtpname 'hold instances of Ftp VirtualDir object
  658. Dim strShareString 'hold the share as STRING
  659. Dim strTemp 'hold temporary array of FTP name
  660. Dim strDictvalue 'hold item of dictionary object
  661. 'get the WMI connection
  662. Set ObjConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  663. 'get the ioncatnces of IIs_FtpVirtualDirSetting class
  664. Set objFtpnames = objConnection.InstancesOf(GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting"))
  665. If Err.number <>0 Then
  666. Call SA_ServeFailurepageEx(L_WMICLASSINSTANCEFAILED_ERRORMESSAGE,G_strReturnURL)
  667. End If
  668. ' Adding all Ftp shares to Dictionary Object.
  669. For Each instFtpname in objFtpnames
  670. strTemp=split(instFtpname.name,"/")
  671. ' Displaying only Root level ftp Shares
  672. If ubound(strTemp)=3 Then
  673. strShareString=strTemp(ubound(strTemp))&chr(1)&instFtpname.path
  674. ' Checking whether the sharename with same path is existing in the dictionary object
  675. If objDict.Exists(strShareString) Then
  676. If instr(objDict.item(strShareString),"F")=0 Then
  677. strDictValue=objDict.Item(strShareString) & " F" 'append 'F' to identIfy FTP share
  678. objDict.Item(strShareString)= strDictValue
  679. End If
  680. else
  681. objDict.Add strShareString,chr(1)&"F"
  682. End If
  683. End If
  684. Next
  685. ' Destroying dynamically created objects
  686. Set objConnection = Nothing
  687. Set objFtpnames = Nothing
  688. End Sub
  689. '-------------------------------------------------------------------------
  690. ' Sub Routine name: GetHttpShares
  691. ' Description: Gets Http Shares from localmachine and adds to
  692. ' Dictionary Object.
  693. ' Input Variables: objDict(dictionary object)
  694. ' Output Variables: None
  695. ' Returns: None
  696. ' Global Variables: in: L_WMICLASSINSTANCEFAILED_ERRORMESSAGE
  697. '-------------------------------------------------------------------------
  698. Sub GetHttpShares(ByRef objDict)
  699. Err.Clear
  700. On Error resume next
  701. Dim strShareString 'hold the share as STRING
  702. Dim strDictvalue 'hold item of dictionary object
  703. Dim strSiteName 'hold site name
  704. Dim objWebRoot 'hold ADSI connection to site
  705. Dim instWeb 'hold site instance
  706. 'Get Metabase name of "Shares" site
  707. strSiteName=GetSharesWebSiteName()
  708. 'Connect to IIS provider
  709. Set objWebRoot = GetObject( "IIS://" & request.servervariables("SERVER_NAME") & "/" & strSiteName & "/root")
  710. For Each instWeb in objWebRoot
  711. '
  712. 'Get method will gen an error if the object does not have the EnableBrowsing property.
  713. 'Only the objects has EnableBrowsing property set to true are listed as HTTP shares.
  714. '
  715. 'Notice not every object has a path property unless its EnableDirBrowsing is set to true
  716. '
  717. If instWeb.EnableDirBrowsing = true Then
  718. strShareString=instWeb.name & chr(1) & instWeb.path
  719. If objDict.Exists(strShareString) Then
  720. If instr(objDict.item(strShareString),"H")=0 Then
  721. strDictValue=objDict.Item(strShareString) & " H" 'appEnd 'H' to identify HTTP/WebDAV share
  722. objDict.Item(strShareString)= strDictValue
  723. End If
  724. Else
  725. objDict.Add strShareString,chr(1)&"H"
  726. End If 'objDict.Exists
  727. End If 'instWeb.EnableDirBrowsing = true
  728. Next
  729. 'Destroying dynamically created objects
  730. Set objWebRoot = Nothing
  731. End Sub
  732. '-------------------------------------------------------------------------
  733. ' Function name: GetSystemName()
  734. ' Description: gets the system name
  735. ' Input Variables: None
  736. ' Output Variables: None
  737. ' Returns: Computer name
  738. ' Global Variables: None
  739. '-------------------------------------------------------------------------
  740. Function GetSystemName()
  741. On Error Resume Next
  742. Err.Clear
  743. Dim WinNTSysInfo ' hold WinNT system object
  744. Set WinNTSysInfo = CreateObject("WinNTSystemInfo")
  745. GetSystemName = WinNTSysInfo.ComputerName 'get the computer name
  746. ' Destroying dynamically created objects
  747. Set WinNTSysInfo =Nothing
  748. End Function
  749. '-------------------------------------------------------------------------
  750. ' Function name: GetWebSiteID
  751. ' Description: Get web site name
  752. ' Input Variables: strWebSiteNamee
  753. ' Output Variables: None
  754. ' Returns: website name
  755. ' Global Variables: IN:G_objHTTPService
  756. '-------------------------------------------------------------------------
  757. Function GetWebSiteID( strWebSiteName )
  758. On Error Resume Next
  759. Err.Clear
  760. Dim strWMIpath 'hold query string for WMI
  761. Dim objSiteCollection 'hold Sites collection
  762. Dim objSite 'hold Site instance
  763. 'XPE only has one website, admin and shares are two virtual directory under
  764. 'that default website.
  765. If CONST_OSNAME_XPE = GetServerOSName() Then
  766. 'WMI query
  767. strWMIpath = "Select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where Name =" & chr(34) & GetCurrentWebsiteName() & chr(34)
  768. Else
  769. 'Build the query for WMI
  770. strWMIpath = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where servercomment =" & chr(34) & strWebSiteName & chr(34)
  771. End If
  772. Set objSiteCollection = G_objHTTPService.ExecQuery(strWMIpath)
  773. for each objSite in objSiteCollection
  774. GetWebSiteID = objSite.Name
  775. Exit For
  776. Next
  777. 'Destroying dynamically created object
  778. Set objSiteCollection = Nothing
  779. End Function
  780. '-------------------------------------------------------------------------
  781. ' Function name: FolderExists()
  782. ' Description: Validating the folder exists or not.
  783. ' Input Variables: strShareName
  784. ' Output Variables: None
  785. ' Returns: True/False
  786. ' Global Variables: None
  787. '-------------------------------------------------------------------------
  788. Function FolderExists( strShareName )
  789. Dim objFso 'hold filesystem object
  790. FolderExists = False
  791. Set objFso = Server.CreateObject( "Scripting.FileSystemObject")
  792. If objFso.FolderExists( strShareName ) Then
  793. FolderExists = True
  794. End If
  795. ' Destroying dynamically created objects
  796. Set objFso = Nothing
  797. End Function
  798. '-------------------------------------------------------------------------
  799. ' Sub Routine name: GetAppleTalkShares
  800. ' Description: Gets all AppleTalk Shares from SA machine and
  801. ' adds to Dictionary Object
  802. ' Input Variables: objDict(dictionary object)
  803. ' Output Variables: objDict
  804. ' Returns: None
  805. ' Global Variables: in: CONST_REGISTRY_APPLETALK_PATH - Registry path to access Appletalk Shares
  806. '-------------------------------------------------------------------------
  807. Sub GetAppleTalkShares(ByRef objDict)
  808. Err.Clear
  809. On Error Resume Next
  810. Dim objRegistryHandle 'hold Registry connection
  811. Dim intenumkey 'hold enum key value as INTEGER
  812. Dim strenumvalue 'hold enum key value as STRING
  813. Dim strenumstringval 'hold enum key value as STRING
  814. Dim strenumstringpath 'hold value of the registry key
  815. Dim nidx 'hold count
  816. Dim ObjConnection 'hold WMI connection object
  817. Dim strDictValue 'hold string value of dictionary object
  818. Dim strShareString 'hold the share as STRING
  819. Const CONST_MACFILE="MacFile"
  820. Set ObjConnection = getWMIConnection("Default") 'gets the WMI connection
  821. ' Check whether the service is installed on the machine or not
  822. If not IsServiceInstalled(ObjConnection,CONST_MACFILE) Then
  823. Exit Sub
  824. End If
  825. ' Get the registry connection Object.
  826. Set objRegistryHandle = RegConnection()
  827. ' RegEnumKey function gets the Subkeys in the given Key and Returns
  828. ' an array containing sub keys from registry
  829. intenumkey = RegEnumKeyValues(objRegistryHandle,CONST_REGISTRY_APPLETALK_PATH)
  830. For nidx= 0 to (ubound(intenumkey))
  831. strenumstringpath = getRegkeyvalue(objRegistryHandle,CONST_REGISTRY_APPLETALK_PATH,intenumkey(nidx),CONST_MULTISTRING)
  832. strShareString= trim(intenumkey(nidx)) & chr(1) & Mid(trim(strenumstringpath(3)),6)
  833. If objDict.Exists(strShareString) Then
  834. strDictValue= objDict.Item(strShareString) & " A" 'append 'A' to identify APPLETALK share
  835. objDict.Item(strShareString)= strDictValue
  836. else
  837. If strShareString <> "" Then
  838. objDict.Add strShareString,chr(1) & "A"
  839. End If
  840. End If
  841. Next
  842. ' Destroying dynamically created objects
  843. Set ObjConnection=Nothing
  844. Set objRegistryHandle=Nothing
  845. End Sub
  846. '-------------------------------------------------------------------------
  847. ' Function name: GenSharesPage
  848. ' Description: lists all shares
  849. ' Input Variables: strHostName -hostname
  850. ' strSharesSiteID -website ID
  851. ' Output Variables: None
  852. ' Returns:
  853. ' Global Variables:
  854. '
  855. '-------------------------------------------------------------------------
  856. Sub GenSharesPage(strHostName,strSharesSiteID)
  857. Err.Clear
  858. On Error Resume Next
  859. Dim strSharesFolder
  860. Dim oFileSystemObject
  861. Dim oSharesListFile
  862. Set oFileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
  863. 'strSharesFolder = oFileSystemObject.GetSpecialFolder(0).Drive & "\inetpub\shares"
  864. strSharesFolder = GetSharesFolder()
  865. Set oSharesListFile = oFileSystemObject.CreateTextFile( strSharesFolder + "\SharesList.txt", True, True)
  866. Dim oWebVirtDir
  867. Dim oWebRoot
  868. Dim index
  869. Dim urlAdmin, i, urlHTTPSAdmin
  870. Dim nNumSites
  871. nNumSites = 1000
  872. Dim arrVroots()
  873. ReDim arrVroots(nNumSites, 1 )
  874. Set oWebRoot = GetObject( "IIS://" & strHostName & "/" & strSharesSiteID & "/root")
  875. if (Err.Number) then
  876. Call SA_TraceOut(SOURCE_FILE, "GenSharesPage:GetObject Failed with Error:"+Hex(Err.Number))
  877. exit sub
  878. end if
  879. index = -1
  880. For Each oWebVirtDir in oWebRoot
  881. If oWebVirtDir.EnableDirBrowsing = true Then
  882. index = index + 1
  883. if (index > nNumSites) then
  884. Call SA_TraceOut(SOURCE_FILE, "GenSharesPage:Num Shares:"+nNumSites)
  885. nNumSites = nNumSites + 1000
  886. ReDim Preserve arrVroots(nNumSites, 1 )
  887. end if
  888. arrVroots( index, 0 ) = oWebVirtDir.Name
  889. End If
  890. Next
  891. Call SAQuickSort( arrVroots, 0, index, 1, 0 )
  892. For i = 0 To index
  893. oSharesListFile.Writeline(arrVroots( i, 0 ))
  894. Next
  895. oSharesListFile.Close
  896. End Sub
  897. '-------------------------------------------------------------------------
  898. ' Function name: SearchFolderPathForShares
  899. ' Description: Initializes global search variables to search for all shares of a particular
  900. ' folder if only one folder is selected in Folders OTS. Else no search condition is set.
  901. ' Input Variables: None
  902. ' Output Variables: None
  903. ' Returns: None
  904. ' Global Variables: g_bSearchChanged
  905. ' g_iSearchCol
  906. ' g_sSearchColValue
  907. '-------------------------------------------------------------------------
  908. sub SearchFolderPathForShares()
  909. Dim itemCount ' table selection count
  910. Dim itemKey ' the selected value
  911. Dim arrShares ' array to hold all hidden column entries
  912. Dim strFolderPath ' Folder path of the selected folder
  913. Dim strShareFormat ' Share format of the selected folder ('S' or 'M')
  914. Const CONST_SHARE_MULTIPLE = "M"
  915. Const CONST_SHARE_SINGLE = "S"
  916. ' Request.Form("shareformat") is populated in Folders area page because:
  917. ' 1. It is required to distinguish between "One folder selected" and "no folders selected"
  918. ' 2. It is required to override the OTS_GetTableSelection made in Shares area page (for share new/prop)
  919. strShareFormat = Request.Form("shareformat")
  920. strFolderPath = ""
  921. itemCount = OTS_GetTableSelectionCount("")
  922. ' First If condition
  923. ' Check whether only one folder entry is selected
  924. If itemCount = 1 then
  925. ' Second If condition
  926. ' If OTS_GetTableSelectionCount is currently retaining the last selected value, override it
  927. ' This is useful when no entry is selected in the Folders OTS
  928. If strShareFormat = CONST_SHARE_SINGLE or strShareFormat = CONST_SHARE_MULTIPLE then
  929. ' Third If condition
  930. ' If retrieving the selected value is successful
  931. If ( OTS_GetTableSelection("", 1, itemKey) ) Then
  932. arrShares = split(itemKey, chr(1))
  933. ' Get the folder path
  934. If IsArray(arrShares) and UBound(arrShares) > 0 then
  935. strFolderPath = UnEscapeChars(replace(arrShares(0),"/","\"))
  936. End If
  937. ' Set the search conditions
  938. g_bSearchChanged = TRUE ' Indicates search is requested
  939. g_iSearchCol = 2 ' Search is on second column - Folder Path
  940. g_sSearchColValue = strFolderPath ' Folder path
  941. End If
  942. End If
  943. End if
  944. end sub
  945. %>