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.

959 lines
30 KiB

  1. <% '-------------------------------------------------------------------------
  2. ' share_genprop.asp: Shares general prop page.
  3. '
  4. ' Copyright (c) Microsoft Corporation. All rights reserved.
  5. '
  6. ' Date Description
  7. ' 12 Oct 2000 Creation Date
  8. ' 9 March 2001 Modified Date.
  9. '-------------------------------------------------------------------------
  10. %>
  11. <!--#include file="share_genprop.js" -->
  12. <%
  13. '------------------------------------------------------------------------
  14. ' Form Variables
  15. '------------------------------------------------------------------------
  16. Dim F_strNewSharename 'Modified share name
  17. Dim F_strNewSharePath 'Modified share path
  18. Dim F_strSharesChecked 'Type of shares selected
  19. Dim F_strConfirmed 'delete confirmation
  20. '-------------------------------------------------------------------------
  21. ' Global Variables
  22. '-------------------------------------------------------------------------
  23. Dim G_objConnection 'gets the WMI connection
  24. Dim G_strErrorinShareType 'gets the type of share which is not created
  25. Dim G_ErrFlag
  26. Const CONST_WINDOWSSHARES="W"
  27. Const CONST_NFSSHARES="U"
  28. Const CONST_FTPSHARES="F"
  29. Const CONST_HTTPSHARES="H"
  30. Const CONST_APPLETALKSHARES="A"
  31. G_ErrFlag = 0
  32. G_strErrorinShareType =""
  33. 'Get the WMI connection
  34. set G_objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  35. '-------------------------------------------------------------------------
  36. 'Function name: ServeGenPage
  37. 'Description: Serves in getting the general properties(tab) sheet
  38. ' for shares
  39. 'Input Variables: None
  40. 'Output Variables: None
  41. 'Returns: None
  42. 'Global Variables: G_strErrorinShareType,G_strChecktheShareMsG
  43. '--------------------------------------------------------------------------
  44. Function ServeGenPage()
  45. Err.Clear
  46. On Error Resume Next
  47. %>
  48. <table width="518" align="left" border="0" cellspacing="0" cellpadding="2" >
  49. <tr>
  50. <td class="TasksBody" align=left width=18% >
  51. <%=L_SHARENAME_TEXT%>
  52. </td>
  53. <td class="TasksBody" align=left >
  54. <input type="text" class="FormField" name="txtShareName" maxlength="80" size="20" disabled onFocus="this.select()" onKeyUp="makeDisable(this)" onMouseOut="makeDisable(this)" value="<%=server.HTMLEncode(F_strNewSharename)%>" >
  55. </td>
  56. </tr>
  57. <tr>
  58. <td class="TasksBody" align=left >
  59. <%=L_SHAREDPATH_TEXT%>
  60. </td>
  61. <td class="TasksBody" align=left>
  62. <input type="text" class="FormField" name="txtSharePath" disabled size="20" onFocus="this.select()" value="<%=server.HTMLEncode(F_strNewSharePath)%>">
  63. </td>
  64. </tr>
  65. <tr>
  66. <td class="TasksBody" colspan="2">
  67. &nbsp;
  68. </td>
  69. </tr>
  70. <tr>
  71. <td class="TasksBody" colspan="2">
  72. <%=L_ACCESSEDBYCLIENTS_TEXT%>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td colspan="2" class="TasksBody" align=left>
  77. <table border=0>
  78. <tr>
  79. <td class="TasksBody">
  80. &nbsp;
  81. <%
  82. 'checkbox selected/unselected
  83. If instr(F_strSharesChecked,CONST_WINDOWSSHARES) > 0 Then
  84. SelectCheckBox CONST_WINDOWSSHARES,true,false
  85. Else
  86. SelectCheckBox CONST_WINDOWSSHARES,false ,false
  87. End If
  88. 'to dispaly as error
  89. If instr(G_strErrorinShareType,CONST_WINDOWSSHARES) > 0 Then
  90. ShowErrorinRed L_CHK_WINDOWS_TEXT
  91. Else
  92. response.write L_CHK_WINDOWS_TEXT
  93. End If
  94. %>
  95. </td>
  96. </tr>
  97. <%Set G_objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  98. 'to make the checkbox disable if the service is not installed
  99. If isServiceInstalled(G_objConnection,"nfssvc") Then
  100. %>
  101. <tr>
  102. <td class="TasksBody">
  103. &nbsp;
  104. <%
  105. 'checkbox selected/unselected
  106. If instr(F_strSharesChecked,CONST_NFSSHARES) > 0 Then
  107. SelectCheckBox CONST_NFSSHARES,true,false
  108. Else
  109. SelectCheckBox CONST_NFSSHARES,false,false
  110. End If
  111. 'to dispaly as error
  112. If instr(G_strErrorinShareType,CONST_NFSSHARES) > 0 Then
  113. ShowErrorinRed L_CHK_UNIX_TEXT
  114. Else
  115. response.write L_CHK_UNIX_TEXT
  116. End If
  117. %>
  118. </td>
  119. </tr>
  120. <%
  121. End If
  122. %>
  123. <%
  124. 'to make the checkbox disable if the service is not installed
  125. If isServiceInstalled(G_objConnection,"msftpsvc") Then
  126. %>
  127. <tr>
  128. <td class="TasksBody">
  129. &nbsp;
  130. <%'checkbox selected/unselected
  131. If instr(F_strSharesChecked,CONST_FTPSHARES) > 0 Then
  132. SelectCheckBox CONST_FTPSHARES,true,false
  133. Else
  134. SelectCheckBox CONST_FTPSHARES,false ,false
  135. End If
  136. 'to dispaly as error
  137. If instr(G_strErrorinShareType,CONST_FTPSHARES) > 0 Then
  138. ShowErrorinRed L_CHK_FTP_TEXT
  139. Else
  140. response.write L_CHK_FTP_TEXT
  141. End If
  142. %>
  143. </td>
  144. </tr>
  145. <%
  146. End If
  147. %>
  148. <tr>
  149. <td colspan="0" class="TasksBody">
  150. &nbsp;
  151. <%
  152. 'checkbox selected/unselected
  153. If instr(F_strSharesChecked,CONST_HTTPSHARES) > 0 Then
  154. SelectCheckBox CONST_HTTPSHARES,true,false
  155. Else
  156. SelectCheckBox CONST_HTTPSHARES,false ,false
  157. End If
  158. 'to dispaly as error
  159. If instr(G_strErrorinShareType,CONST_HTTPSHARES) > 0 Then
  160. ShowErrorinRed L_CHK_HTTP_TEXT
  161. Else
  162. response.write L_CHK_HTTP_TEXT
  163. End If
  164. %>
  165. </td>
  166. </tr>
  167. <%
  168. If isServiceInstalled(G_objConnection,"MacFile") Then
  169. %>
  170. <tr>
  171. <td class="TasksBody">
  172. &nbsp;
  173. <%
  174. 'checkbox selected/unselected
  175. If instr(F_strSharesChecked,CONST_APPLETALKSHARES) > 0 Then
  176. SelectCheckBox CONST_APPLETALKSHARES,true,false
  177. Else
  178. SelectCheckBox CONST_APPLETALKSHARES,false ,false
  179. End If
  180. 'to dispaly as error
  181. If instr(G_strErrorinShareType,CONST_APPLETALKSHARES) > 0 Then
  182. ShowErrorinRed L_CHK_APPLETALK_TEXT
  183. Else
  184. response.write L_CHK_APPLETALK_TEXT
  185. End If
  186. %>
  187. </td>
  188. </tr>
  189. <%End if %>
  190. </table>
  191. </tr>
  192. </table>
  193. <%
  194. Call ServeGenHiddenValues
  195. 'check for the error message of shares
  196. if G_strChecktheShareMsg <> "" then
  197. SA_SetErrMsg G_strChecktheShareMsg
  198. end if
  199. End Function
  200. '-------------------------------------------------------------------------
  201. 'Function name: getShareDetails
  202. 'Description: Serves in Getting the share details from the system
  203. 'Input Variables: strShareName,strShareTypes
  204. 'Output Variables: arrShareDetails
  205. 'Returns: Share Details
  206. 'Global Variables: None
  207. '--------------------------------------------------------------------------
  208. Function getShareDetails(strShareName,strShareTypes,arrShareDetails)
  209. Err.Clear
  210. On Error Resume Next
  211. 'Getting CIFS share details from the system
  212. if (instr(strShareTypes,CONST_WINDOWSSHARES) > 0) then
  213. getShareDetails = getCIFSShareDetails(strShareName,arrShareDetails)
  214. Exit function
  215. end if
  216. 'Getting UNIX share details from the system
  217. if (instr(strShareTypes,CONST_NFSSHARES) > 0) then
  218. getShareDetails = getNFSShareDetails(strShareName,arrShareDetails)
  219. Exit function
  220. end if
  221. 'Getting FTP share details from the system
  222. if (instr(strShareTypes,CONST_FTPSHARES) > 0) then
  223. getShareDetails = getFTPShareDetails(strShareName,arrShareDetails)
  224. Exit function
  225. end if
  226. 'Getting HTTP share details from the system
  227. if (instr(strShareTypes,CONST_HTTPSHARES) > 0) then
  228. getShareDetails = getHTTPShareDetails(strShareName,arrShareDetails)
  229. Exit function
  230. end if
  231. 'Getting HTTP share details from the system
  232. if (instr(strShareTypes,CONST_APPLETALKSHARES) > 0) then
  233. getShareDetails = getAppleTalkShareDetails(strShareName,arrShareDetails)
  234. Exit function
  235. end if
  236. End Function
  237. '-------------------------------------------------------------------------
  238. 'Function name: getCIFSShareDetails
  239. 'Description: Serves in Getting the CIFS share details from the system
  240. 'Input Variables: strShareName
  241. 'Output Variables: arrShareDetails
  242. 'Returns: CIFS Share Detals
  243. 'Global Variables: G_objConnection
  244. ' L_(*) 'localization variables
  245. ' True ->If Implemented properly
  246. ' False->If Not Implemented
  247. '--------------------------------------------------------------------------
  248. Function getCIFSShareDetails(strShareName,arrShareDetails)
  249. Err.Clear
  250. On Error Resume Next
  251. Dim strCIFSName
  252. Dim objCIFSShare
  253. strCIFSName = "Name=" & chr(34) & strShareName & chr(34)
  254. 'Get the WMI connection
  255. set G_objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  256. strCIFSName = "Win32_Share." & strCIFSName
  257. 'get the share instance
  258. set objCIFSShare = G_objConnection.get(strCIFSName)
  259. arrShareDetails(0)= objCIFSShare.name
  260. arrShareDetails(1) = objCIFSShare.path
  261. arrShareDetails(2) = objCIFSShare.description
  262. if Err.number <> 0 then
  263. getCIFSShareDetails = false
  264. Call SA_ServeFailurepageEx(L_SHARE_NOT_FOUND_ERRORMESSAGE ,mstrReturnURL)
  265. Exit Function
  266. end if
  267. getCIFSShareDetails = true
  268. 'clean the object
  269. set G_objConnection = nothing
  270. End Function
  271. '-------------------------------------------------------------------------
  272. 'Function name: getNFSShareDetails
  273. 'Description: Serves in Getting the share details from the system
  274. 'Input Variables: strShareName
  275. 'Output Variables: arrShareDetails
  276. 'Returns: (True / Flase )
  277. 'Global Variables: None
  278. ' True ->If Implemented properly
  279. ' False->If Not Implemented
  280. '--------------------------------------------------------------------------
  281. Function getNFSShareDetails(strShareName,arrShareDetails)
  282. Err.Clear
  283. On Error Resume Next
  284. CONST CONST_NFS_REGISTRY_PATH ="SOFTWARE\Microsoft\Server For NFS\CurrentVersion\exports"
  285. Dim objRegistryHandle
  286. Dim arrNFSShares
  287. Dim nIndex
  288. Dim arrTemp
  289. Dim strNFSShareName
  290. Dim strNFSSharePath
  291. ' get the registry connection Object.
  292. set objRegistryHandle = RegConnection()
  293. strNFSSharePath = ""
  294. arrNFSShares = RegEnumKey(objRegistryHandle,CONST_NFS_REGISTRY_PATH)
  295. 'check for the existence of the share
  296. For nIndex = 0 to (ubound(arrNFSShares))
  297. arrTemp = RegEnumKeyValues(objRegistryHandle,CONST_NFS_REGISTRY_PATH & "\" & arrNFSShares(nIndex))
  298. strNFSShareName = getRegkeyvalue(objRegistryHandle,CONST_NFS_REGISTRY_PATH & "\" & arrNFSShares(nIndex),arrTemp(1),CONST_STRING)
  299. if Lcase(strNFSShareName) = Lcase(strShareName) then
  300. strNFSSharePath = getRegkeyvalue(objRegistryHandle,CONST_NFS_REGISTRY_PATH & "\" & arrNFSShares(nIndex),arrTemp(0),CONST_STRING)
  301. exit for
  302. end if
  303. next
  304. if strNFSSharePath = "" or Err.number<> 0 then
  305. getNFSShareDetails = false
  306. Call SA_ServeFailurepageEx(L_SHARE_NOT_FOUND_ERRORMESSAGE ,mstrReturnURL)
  307. else
  308. 'get the share details
  309. arrShareDetails(0) = strNFSShareName
  310. arrShareDetails(1) = strNFSSharePath
  311. arrShareDetails(2) = ""
  312. end if
  313. 'clean the object
  314. set G_objConnection = nothing
  315. End Function
  316. '-------------------------------------------------------------------------
  317. 'Function name: getAppleTalkShareDetails
  318. 'Description: Serves in Getting the Appletalk share details
  319. 'Input Variables: strShareName
  320. 'Output Variables: arrShareDetails
  321. 'Returns: (True / Flase )
  322. 'Global Variables: G_objConnection
  323. ' in: L_*
  324. '--------------------------------------------------------------------------
  325. Function GetAppleTalkShareDetails(strShareName,arrShareDetails)
  326. Dim objRegistryHandle
  327. Dim arrAppleTalkSharesValues
  328. Dim arrFormValues
  329. Dim strSharePath
  330. Dim strenumstringpath
  331. Const CONST_REGISTRY_APPLETALK_PATH = "SYSTEM\CurrentControlSet\Services\MacFile\Parameters\Volumes"
  332. ' Get the registry connection Object.
  333. set objRegistryHandle = RegConnection()
  334. If Err.number <> 0 Then
  335. Call SA_ServeFailurePageEx(L_REGISTRYCONNECTIONFAILED_ERRORMESSAGE,mstrReturnURL)
  336. Exit Function
  337. End If
  338. arrAppleTalkSharesValues = getRegkeyvalue(objRegistryHandle,CONST_REGISTRY_APPLETALK_PATH,strShareName,CONST_MULTISTRING)
  339. arrShareDetails(0)= strShareName
  340. strSharePath = split(arrAppleTalkSharesValues(3),"=",2)
  341. arrShareDetails(1) = strSharePath(1)
  342. 'clean the object
  343. set objRegistryHandle = nothing
  344. GetAppleTalkShareDetails = True
  345. End Function
  346. '-------------------------------------------------------------------------
  347. 'Function name: getHTTPShareDetails
  348. 'Description: Serves in Getting the http share details
  349. 'Input Variables: strShareName
  350. 'Output Variables: arrShareDetails
  351. 'Returns: (True / Flase )
  352. 'Global Variables: G_objConnection
  353. ' in: L_*
  354. '--------------------------------------------------------------------------
  355. Function getHTTPShareDetails(strShareName,arrShareDetails)
  356. Err.Clear
  357. On Error Resume Next
  358. Dim strHTTPName
  359. Dim objHTTPShare
  360. Dim strName
  361. Dim strfileName
  362. Dim strSiteName
  363. strSiteName=GetSharesWebSiteName()
  364. 'Get the WMI connection
  365. Set G_objConnection = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  366. strHTTPName = "name=" & chr(34) & strSiteName & "/ROOT/" & cstr(strShareName) & chr(34)
  367. 'check for the existence of the share
  368. if not isValidInstance(G_objConnection,GetIISWMIProviderClassName("IIs_WebVirtualDir"),strHTTPName) then
  369. getHTTPShareDetails = false
  370. Call SA_ServeFailurepageEx(L_SHARE_NOT_FOUND_ERRORMESSAGE,mstrReturnURL)
  371. Err.Clear
  372. Exit Function
  373. end if
  374. strHTTPName = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & "." & strHTTPName
  375. 'get the share instance
  376. set objHTTPShare = G_objConnection.get(strHTTPName)
  377. If Err.number <> 0 Then
  378. getHTTPShareDetails = false
  379. Exit Function
  380. Err.Clear
  381. End If
  382. strName = objHTTPShare.name
  383. strfileName=split(strName,"/")
  384. arrShareDetails(0)= strfileName(ubound(strfileName))
  385. arrShareDetails(1) = objHTTPShare.path
  386. arrShareDetails(2) = objHTTPShare.description
  387. getHTTPShareDetails = true
  388. 'clean the object
  389. set G_objConnection = nothing
  390. End Function
  391. '-------------------------------------------------------------------------
  392. 'Function name: getFTPShareDetails
  393. 'Description: Serves in Getting the http share details
  394. 'Input Variables: strShareName
  395. 'Output Variables: arrShareDetails
  396. 'Returns: (True / Flase )
  397. 'Global Variables: G_objConnection
  398. ' in: L_*
  399. '--------------------------------------------------------------------------
  400. Function getFTPShareDetails(strShareName,arrShareDetails)
  401. Err.Clear
  402. On Error Resume Next
  403. Dim strFTPName
  404. Dim objFTPShare
  405. Dim strName
  406. Dim strfileName
  407. 'Get the WMI connection
  408. Set G_objConnection = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  409. strFTPName = "name=" & chr(34) & "MSFTPSVC/1/ROOT/" & cstr(strShareName) & chr(34)
  410. 'check for the existence of the share
  411. if NOT isValidInstance(G_objConnection,GetIISWMIProviderClassName("IIs_FtpVirtualDir"),strFTPName) then
  412. getFTPShareDetails = false
  413. Call SA_ServeFailurepageEx(L_SHARE_NOT_FOUND_ERRORMESSAGE,mstrReturnURL)
  414. Err.Clear
  415. Exit Function
  416. end if
  417. strFTPName = GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting") & "." & strFTPName
  418. 'get the share instance
  419. set objFTPShare = G_objConnection.get(strFTPName)
  420. If Err.number <> 0 Then
  421. getFTPShareDetails = false
  422. Exit Function
  423. Err.Clear
  424. End If
  425. strName = objFTPShare.name
  426. strfileName=split(strName,"/")
  427. arrShareDetails(0)= strfileName(ubound(strfileName))
  428. arrShareDetails(1) = objFTPShare.path
  429. arrShareDetails(2) = ""
  430. getFTPShareDetails = true
  431. 'clean the object
  432. set G_objConnection = nothing
  433. End Function
  434. '-------------------------------------------------------------------------
  435. 'Function name: isPropChanged
  436. 'Description: to check for the properties in the controls change
  437. 'Input Variables: None
  438. 'Output Variables: None
  439. 'Returns: (True / Flase )
  440. 'Global Variables: None
  441. '--------------------------------------------------------------------------
  442. Function isPropChanged
  443. Err.Clear
  444. On Error Resume Next
  445. 'checks if there are any changes made by the user
  446. if F_strNewSharename <> F_strSharename or F_strNewSharePath <> F_strSharePath then
  447. isPropChanged = true
  448. else
  449. isPropChanged = false
  450. end if
  451. end function
  452. '-------------------------------------------------------------------------
  453. 'Function name: GenShareProperties
  454. 'Description: does the share create,delete,update functions
  455. 'Input Variables: None
  456. 'Output Variables: None
  457. 'Returns: (True / Flase )
  458. 'Global Variables: G_objConnection
  459. ' True ->If Implemented properly
  460. ' False->If Not Implemented
  461. ' in: L_*
  462. ' in: F_*
  463. '--------------------------------------------------------------------------
  464. Function GenShareProperties()
  465. Err.Clear
  466. On Error Resume Next
  467. Dim blnPropChanged 'to check for the changes made by user
  468. Dim nReturnVar 'return var for the function
  469. Dim arrStrErrorNum(2) 'array to store the errors types
  470. Dim blnCreateshare 'var to determine if error occured
  471. blnCreateshare = true
  472. GenShareProperties=true
  473. Dim oValidator
  474. Set oValidator = new CSAValidator
  475. If ( FALSE = oValidator.IsValidFileName(F_strNewSharename)) Then
  476. Call SA_SetErrMsg(L_INVALIDNAME_ERRORMESSAGE)
  477. Call SA_TraceOut(SA_GetScriptFileName(), "Invalid share name specified: " & F_strNewSharename)
  478. Exit Function
  479. End If
  480. Set oValidator = Nothing
  481. 'check for the existence of the given path
  482. If not isPathExisting(F_strNewSharePath) Then
  483. SA_SetErrMsg L_DIR_ERRORMESSAGE & " " & " (" & Hex(Err.Number) & ") "
  484. GenShareProperties=false
  485. Exit Function
  486. End if
  487. 'user is unckecked the cifs share check box, so delete the cifs share
  488. if instr(F_strShareTypes,CONST_WINDOWSSHARES) >0 and instr(F_strSharesChecked,CONST_WINDOWSSHARES) =0 then
  489. 'Get the WMI connection
  490. Set G_objConnection = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  491. if not deleteShareCIFS(G_objConnection, F_strSharename) then
  492. G_strErrorinShareType = G_strErrorinShareType & CONST_WINDOWSSHARES
  493. else
  494. F_strShareTypes = replace(F_strShareTypes,CONST_WINDOWSSHARES,"")
  495. end if
  496. 'clean the object
  497. Set G_objConnection = nothing
  498. end if
  499. 'Create the CIFS share
  500. if instr(F_strShareTypes,CONST_WINDOWSSHARES) =0 and instr(F_strSharesChecked,CONST_WINDOWSSHARES) >0 then
  501. 'Get the WMI connection
  502. Set G_objConnection = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  503. nReturnVar = cifsnewshare(G_objConnection, F_strNewSharename,F_strNewSharePath,"")
  504. 'to frame the error messages with return variable
  505. if nReturnVar =0 then
  506. F_strShareTypes = F_strShareTypes& "W "
  507. else
  508. blnCreateshare = false
  509. GenShareProperties=false
  510. FrameErrorMessage arrStrErrorNum,nReturnVar," " & L_CIFS_TEXT
  511. G_strErrorinShareType = G_strErrorinShareType & CONST_WINDOWSSHARES
  512. end if
  513. 'clean the object
  514. Set G_objConnection = nothing
  515. end if
  516. 'Delete the NFS share
  517. if instr(F_strShareTypes,CONST_NFSSHARES) >0 and instr(F_strSharesChecked,CONST_NFSSHARES) =0 then
  518. 'Get the reg connection
  519. Set G_objConnection = RegConnection()
  520. if not deleteShareNFS(F_strShareName) then
  521. G_strErrorinShareType = G_strErrorinShareType & CONST_NFSSHARES
  522. else
  523. F_strShareTypes = replace(F_strShareTypes,CONST_NFSSHARES,"")
  524. end if
  525. 'clean the object
  526. Set G_objConnection = nothing
  527. end if
  528. 'Create the NFS share
  529. if instr(F_strShareTypes,CONST_NFSSHARES) =0 and instr(F_strSharesChecked,CONST_NFSSHARES) >0 then
  530. 'Get the WMI connection
  531. 'Set G_objConnection = RegConnection() 'to be removed
  532. nReturnVar =CreateNFSShare(F_strNewSharename,F_strNewSharePath,"")
  533. ' G_ErrFlag = nReturnVar
  534. 'to frame the error messages with return variable
  535. if nReturnVar = true then
  536. F_strShareTypes = F_strShareTypes & "U "
  537. else
  538. blnCreateshare = false
  539. GenShareProperties=false
  540. ' if G_ErrFlag = -100 or G_ErrFlag = -1 then
  541. ' FrameErrorMessage arrStrErrorNum,nReturnVar, " "&L_NFS_TEXT
  542. ' end if
  543. G_strErrorinShareType = G_strErrorinShareType & CONST_NFSSHARES
  544. end if
  545. 'clean the object
  546. 'Set G_objConnection = nothing
  547. end if
  548. 'Delete the FTP share
  549. if instr(F_strShareTypes,CONST_FTPSHARES) >0 and instr(F_strSharesChecked,CONST_FTPSHARES) =0 then
  550. 'Get the WMI connection
  551. Set G_objConnection = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  552. if not deleteShareFTP(G_objConnection, F_strSharename) then
  553. G_strErrorinShareType = G_strErrorinShareType & CONST_FTPSHARES
  554. else
  555. F_strShareTypes = replace(F_strShareTypes,CONST_FTPSHARES,"")
  556. end if
  557. 'clean the object
  558. Set G_objConnection = nothing
  559. end if
  560. 'Create the FTP share
  561. if instr(F_strShareTypes,CONST_FTPSHARES) =0 and instr(F_strSharesChecked,CONST_FTPSHARES) >0 then
  562. 'Get the WMI connection
  563. Set G_objConnection = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  564. nReturnVar =ftpnewshare(G_objConnection, F_strNewSharename,F_strNewSharePath)
  565. 'to frame the error messages with return variable
  566. if nReturnVar =0 then
  567. F_strShareTypes = F_strShareTypes& "F "
  568. else
  569. blnCreateshare = false
  570. GenShareProperties=false
  571. FrameErrorMessage arrStrErrorNum,nReturnVar," " & L_FTP_TEXT
  572. G_strErrorinShareType = G_strErrorinShareType & CONST_FTPSHARES
  573. end if
  574. 'clean the object
  575. Set G_objConnection = nothing
  576. end if
  577. 'Delete the HTTP share
  578. if instr(F_strShareTypes,CONST_HTTPSHARES) >0 and instr(F_strSharesChecked,CONST_HTTPSHARES) =0 then
  579. 'Get the WMI connection
  580. Set G_objConnection = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  581. if not deleteShareHTTP(G_objConnection, F_strSharename) then
  582. G_strErrorinShareType = G_strErrorinShareType & CONST_HTTPSHARES
  583. else
  584. F_strShareTypes = replace(F_strShareTypes,CONST_HTTPSHARES,"")
  585. end if
  586. 'clean the object
  587. Set G_objConnection = nothing
  588. end if
  589. 'Create the HTTP share
  590. if instr(F_strShareTypes,CONST_HTTPSHARES) =0 and instr(F_strSharesChecked,CONST_HTTPSHARES) >0 then
  591. 'Get the WMI connection
  592. Set G_objConnection = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  593. nReturnVar = httpnewshare(G_objConnection, F_strNewSharename,F_strNewSharePath)
  594. 'to frame the error messages with return variable
  595. if nReturnVar= 0 then
  596. F_strShareTypes = F_strShareTypes& "H "
  597. else
  598. blnCreateshare = false
  599. GenShareProperties=false
  600. FrameErrorMessage arrStrErrorNum,nReturnVar," " & L_HTTP_TEXT
  601. G_strErrorinShareType = G_strErrorinShareType & CONST_HTTPSHARES
  602. end if
  603. 'clean the object
  604. Set G_objConnection = nothing
  605. end if
  606. 'Delete the APPLETALK share
  607. if instr(F_strShareTypes,CONST_APPLETALKSHARES) >0 and instr(F_strSharesChecked,CONST_APPLETALKSHARES) =0 then
  608. if not deleteShareAppleTalk(F_strSharename) then
  609. G_strErrorinShareType = G_strErrorinShareType & CONST_APPLETALKSHARES
  610. else
  611. F_strShareTypes = replace(F_strShareTypes,CONST_APPLETALKSHARES,"")
  612. end if
  613. end if
  614. 'Create the APPLETALK share
  615. if instr(F_strShareTypes,CONST_APPLETALKSHARES) =0 and instr(F_strSharesChecked,CONST_APPLETALKSHARES) >0 then
  616. Dim strQueryForCmd
  617. 'Query to create Apple Talk share
  618. strQueryForCmd = "VOLUME /ADD /NAME:" & chr(34) & F_strNewSharename & chr(34) & " /PATH:" & chr(34) & F_strNewSharePath & chr(34)
  619. nReturnVar = CreateAppleTalkShare(F_strNewSharename,F_strNewSharePath,strQueryForCmd)
  620. 'to frame the error messages with return variable
  621. if nReturnVar= True then
  622. F_strShareTypes = F_strShareTypes& "A "
  623. else
  624. blnCreateshare = false
  625. GenShareProperties=false
  626. FrameErrorMessage arrStrErrorNum,nReturnVar," " & L_APPLETALK_TEXT
  627. G_strErrorinShareType = G_strErrorinShareType & CONST_APPLETALKSHARES
  628. end if
  629. end if
  630. 'check for error in creating shares
  631. if G_strErrorinShareType <> "" then
  632. 'to frame the error messages when an error occured in creating share
  633. If blnCreateshare = false then
  634. G_strChecktheShareMsg = ShowErrorMessage(arrStrErrorNum) & " " & ShowUNIXError(G_ErrFlag)& " (" & Hex(Err.Number) & ") "
  635. else
  636. G_strChecktheShareMsg = L_SHARESTATUS_ERRORMESSAGE & " " & " (" & Hex(Err.Number) & ") "
  637. end if
  638. F_strConfirmed = 0
  639. GenShareProperties=false
  640. exit function
  641. end if
  642. End function
  643. '-------------------------------------------------------------------------
  644. 'Function name: isEnabled
  645. 'Description: check for the check box to be disabled/enabled
  646. 'Input Variables: strShareType
  647. 'Output Variables: None
  648. 'Returns: (True / Flase )
  649. 'Global Variables: None
  650. '--------------------------------------------------------------------------
  651. Function isEnabled(strShareType)
  652. Err.Clear
  653. On Error Resume Next
  654. dim nIndex
  655. for nIndex = 0 to G_nIndex
  656. if ucase(G_arrShareTypes(nIndex))= ucase(strShareType) then
  657. isEnabled = true
  658. exit function
  659. end if
  660. next
  661. isEnabled = false
  662. End function
  663. '-------------------------------------------------------------------------
  664. 'Function name: GeneralOnInitPage
  665. 'Description: Serves in Getting the varibales from the system
  666. 'Input Variables: None
  667. 'Output Variables: None
  668. 'Returns: (True / Flase )
  669. 'Global Variables: None
  670. ' in: F_*
  671. '--------------------------------------------------------------------------
  672. Function GeneralOnInitPage
  673. Err.Clear
  674. On Error Resume Next
  675. Dim arrShareDetails(3)
  676. 'Get the WMI connection
  677. set G_objConnection = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  678. 'Get the share details
  679. getShareDetails F_strShareName,F_strShareTypes,arrShareDetails
  680. F_strNewShareName = arrShareDetails(0)
  681. F_strNewSharePath = arrShareDetails(1)
  682. F_strSharesChecked = F_strShareTypes
  683. End Function
  684. '-------------------------------------------------------------------------
  685. 'Function name: GeneralOnPostBackPage
  686. 'Description: Serves in Getting the varibales from the Form
  687. 'Input Variables: None
  688. 'Output Variables: None
  689. 'Returns: (True / Flase )
  690. 'Global Variables: None
  691. ' in: F_*
  692. '--------------------------------------------------------------------------
  693. Function GeneralOnPostBackPage
  694. Err.Clear
  695. On Error Resume Next
  696. F_strNewShareName = Request.Form("hidSharename")
  697. F_strNewSharePath = Request.Form("hidSharePath")
  698. F_strSharesChecked = Request.Form("hidSharesChecked")
  699. F_strShareTypes = Request.Form("hidShareTypes")
  700. F_strDelete = Request.Form("hidDelete")
  701. End Function
  702. '-------------------------------------------------------------------------
  703. 'Function name: ShowUNIXError
  704. 'Description: to frame error messages to display error messages
  705. ' accordingly(either duplicate share name/share name not valid)
  706. 'Input Variables: strMsg
  707. 'Output Variables: None
  708. 'Returns: (True / Flase )
  709. 'Global Variables: None
  710. '--------------------------------------------------------------------------
  711. Function ShowUNIXError(nErrFlag)
  712. Err.Clear
  713. on error resume next
  714. Dim strError
  715. Select case nErrFlag
  716. case -4
  717. strError = L_SUB_PATH_ALREADY_SHARED_ERRORMESSAGE& " <I>" &L_NFS_TEXT&"</I>"
  718. case -8
  719. strError = L_PARENT_PATH_ALREADY_SHARED_ERRORMESSAGE& " <I>" &L_NFS_TEXT&"</I>"
  720. End Select
  721. ShowUNIXError = strError
  722. End Function
  723. '-------------------------------------------------------------------------
  724. 'Function name: isPathExisting
  725. 'Description: checks for the directory existing
  726. 'Input Variables: strDirectoryPath
  727. 'Output Variables: None
  728. 'Returns: (True / Flase )
  729. 'Global Variables: None
  730. ' True ->If Implemented properly
  731. ' False->If Not Implemented
  732. '--------------------------------------------------------------------------
  733. Function isPathExisting(strDirectoryPath)
  734. Err.Clear
  735. On Error Resume Next
  736. Dim objFSO 'to create filesystemobject instance
  737. isPathExisting = true
  738. 'get the filesystemobject instance
  739. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  740. 'Checks for existence of the given path
  741. If NOT objFSO.FolderExists(strDirectoryPath) Then
  742. 'Checks if the given path is drive only
  743. If NOT objFSO.DriveExists(strDirectoryPath) Then
  744. isPathExisting = false
  745. Exit Function
  746. end if
  747. End If
  748. 'clean the object
  749. Set objFSO = nothing
  750. End Function
  751. '-------------------------------------------------------------------------
  752. 'Function name: ServeGenHiddenValues
  753. 'Description: footer function
  754. 'Input Variables: None
  755. 'Output Variables: None
  756. 'Returns: (True / Flase )
  757. 'Global Variables: None
  758. '--------------------------------------------------------------------------
  759. Function ServeGenHiddenValues
  760. Err.Clear
  761. On Error Resume Next
  762. %>
  763. <input type="hidden" name="hidSharename" value="<%=server.HTMLEncode(F_strNewSharename)%>">
  764. <input type="hidden" name="hidSharePath" value="<%=server.HTMLEncode(F_strNewSharePath)%>">
  765. <input type="hidden" name="hidSharesChecked" value ="<%=F_strSharesChecked%>" >
  766. <input type="hidden" name="hidShareTypes" value="<%=F_strShareTypes%>">
  767. <input type="hidden" name="hidOldSharename" value="<%=F_strShareName%>">
  768. <input type="hidden" name="hidOldstrSharePath" value="<%=F_strSharePath%>">
  769. <input type="hidden" name="hidDelete" value="<%=F_strDelete%>">
  770. <%
  771. End Function
  772. %>