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.

1024 lines
34 KiB

  1. <% '------------------------------------------------------------------
  2. ' Share_nfsprop.asp: Manage NFS Share Permissions
  3. '
  4. ' Copyright (c) Microsoft Corporation. All rights reserved.
  5. '
  6. ' Date Description
  7. ' 9 Oct 2000 Creation Date
  8. ' 12 March 2001 Modifiy Date
  9. '------------------------------------------------------------------
  10. '--------------------------------------------------------------------------
  11. 'global Constants
  12. '--------------------------------------------------------------------------
  13. Const G_nMEMBERS = 40' Upper limit of array that holds
  14. ' clients and client groups list
  15. Const G_GROUP = 1 ' Constants used to call SFU API's
  16. Const G_MEMBER = 2 ' Constants used to call SFU API's
  17. Const G_PERMISSION_TAB = 0 ' Permission Tab
  18. '--------------------------------------------------------------------------
  19. 'Global Variables
  20. '--------------------------------------------------------------------------
  21. Dim G_objRegistryHandle ' Registry object
  22. Dim F_REGISTRY_PATH ' Path to registry key
  23. Dim G_CLGRPS ' Used to get all the
  24. ' Client Groups and Members
  25. Dim G_bValidateEditText ' If we need to validate edit text
  26. G_bValidateEditText = True
  27. Dim G_oldSharePermissionlist
  28. '--------------------------------------------------------------------------
  29. 'Form Variables
  30. '--------------------------------------------------------------------------
  31. Dim F_strNFSShareName ' NFS Share name
  32. Dim F_strShareNFSPath ' NFS Share Path
  33. Dim F_strPermissionList ' User name list
  34. Dim F_strAccessType ' ACL
  35. Dim F_bAddBtnClick ' User Clicked on Add
  36. Dim F_strCommName ' Name of Client or Client Group
  37. Dim F_strClientInfo ' Stores Permission list
  38. Dim F_strGlobalPerm ' Global permission setting
  39. Dim F_strCliGrp ' List of Clients and Client Groups
  40. Dim F_strEUCJPStatus ' status of the EUCJP checkbox ( check/uncheck )
  41. ' SFU 2.3 - 2-28
  42. ' Anonymous
  43. Dim G_bAllowAnonAccess
  44. '--------------------------------------------------------------------------
  45. 'Initializing of Reg path
  46. '--------------------------------------------------------------------------
  47. F_REGISTRY_PATH ="SOFTWARE\Microsoft\Server For NFS\CurrentVersion\exports"
  48. '--------------------------------------------------------------------------
  49. F_strCommName =""
  50. 'Function Call to get the registry handle connection
  51. set G_objRegistryHandle = RegConnection()
  52. '-------------------------------------------------------------------------
  53. ' Function name: ServerSideValidation()
  54. ' Description: Server side validation
  55. ' Input Variables: None.
  56. ' Output Variables: None
  57. ' Return Values: None.
  58. '-------------------------------------------------------------------------
  59. Function ServerSideValidation()
  60. Err.Clear
  61. On Error Resume Next
  62. Dim arrPermissions ' Permissions
  63. Dim i
  64. Dim ComputerID 'Return value
  65. Dim strCompName 'Client IP or Computer Name
  66. Dim cPermissions
  67. Dim strTemp 'Temparary variable
  68. ServerSideValidation = True
  69. Const CONST_UNKNOWN_HOST="UNKNOWN HOST"
  70. Const CONST_NOACESS="0,ALL MACHINES,0,1;"
  71. Const CONST_READONLY="0,ALL MACHINES,0,2;"
  72. Const CONST_READWRITE="0,ALL MACHINES,0,4;"
  73. arrPermissions = split(F_strPermissionList, ";")
  74. cPermissions = ubound(arrPermissions)
  75. For i = 1 to (ubound(arrPermissions)-1)
  76. strTemp=split(arrPermissions(i), ",")
  77. strCompName =strTemp(1)
  78. If Instr(arrPermissions(i),"G")=0 Then
  79. ComputerID = ValidateMember(strCompName)
  80. If ComputerID <> CONST_UNKNOWN_HOST Then
  81. If cPermissions = 1 Then
  82. 'Set the ALL MACHINES to NO ACESS
  83. F_strPermissionList = Replace(F_strPermissionList,CONST_READONLY,_
  84. CONST_NOACESS)
  85. F_strPermissionList = Replace(F_strPermissionList,CONST_READWRITE,_
  86. CONST_NOACESS)
  87. End if
  88. Else
  89. Dim arrRepString(1)
  90. Dim strResolveErrMsg
  91. arrRepString(0) = strCompName
  92. strResolveErrMsg = SA_GetLocString("foldermsg.dll", "C03A0095", arrRepString)
  93. Call SA_SetErrMsg(strResolveErrMsg)
  94. ServerSideValidation=False
  95. Exit Function
  96. End if
  97. End if
  98. Next
  99. End Function
  100. %>
  101. <!--#include file="share_nfsprop.js" -->
  102. <% '-------------------------------------------------------------------------
  103. ' Function name: ServeNFSPage
  104. ' Description: Serves in displaying the page Header,Middle,Bottom Parts.
  105. ' Input Variables: None.
  106. ' Output Variables: None
  107. ' Return Values: None.
  108. ' Global variables L_(*) & F_(*)
  109. '-------------------------------------------------------------------------
  110. Function ServeNFSPage
  111. Err.clear
  112. On error resume next
  113. %>
  114. <table>
  115. <tr>
  116. <td class="TasksBody" nowrap align=left>
  117. <%=L_SHAREPATH_TEXT%>
  118. </td>
  119. <td class="TasksBody" nowrap align=left>
  120. <%=F_strShareNFSPath%>
  121. </td>
  122. </tr>
  123. <tr height="6">
  124. <td class="TasksBody">
  125. </td>
  126. </tr>
  127. <!-- SFU 2.3 - 2-28 -->
  128. <tr>
  129. <td class="TasksBody" colspan=2>
  130. <input type="checkbox" name="chkAllowAnnon" class="FormCheckBox" <%=GetAnnonAccessCheckState()%> value="ON" ><%=L_ALLOWANNON_TEXT%>
  131. </td>
  132. </tr>
  133. <!-- END SFU 2.3 - 2-28 -->
  134. <tr>
  135. <td class="TasksBody" colspan=2>
  136. <input type="checkbox" name="chkEUCJP" class="FormCheckBox" <%=F_strEUCJPStatus %> value="ON" ><%=L_EUCJP_TEXT%>
  137. </td>
  138. </tr>
  139. </table>
  140. <table>
  141. <tr>
  142. <td class="TasksBody">
  143. <%=L_PERMISSIONS_TEXT%>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td height="80" class="TasksBody">
  148. <select id="lstPermissions" name="lstPermissions" class="FormField" size="8" onClick="DisableBtn();" onChange="if (document.frmTask.scrollCliGrp.selectedIndex!= -1){ document.frmTask.scrollCliGrp.selectedIndex= -1;selectAccess( document.frmTask.lstPermissions,document.frmTask.cboRights );}if(document.frmTask.lstPermissions.selectedIndex ==0){document.frmTask.btnRemove.disabled=true;} else{ document.frmTask.btnRemove.disabled=false;}selectAccess(this,cboRights);" style="font-family: Courier" >
  149. <%
  150. 'Function call to get the permissions
  151. Call getPermissions()
  152. %>
  153. </select>
  154. </td>
  155. </tr>
  156. </table>
  157. <table>
  158. <tr valign=top>
  159. <td class="TasksBody">
  160. <% =L_CLIENTANDGROUPS_TEXT %>
  161. </td>
  162. <td class="TasksBody">
  163. <% =L_NFS_CLIENT_TEXT %>
  164. </td>
  165. </tr>
  166. <tr valign=top>
  167. <td class="TasksBody">
  168. <select name="scrollCliGrp" class="FormField" size="4" language=javascript onChange="if (document.frmTask.lstPermissions.selectedIndex!= -1){ document.frmTask.lstPermissions.selectedIndex= -1;selectAccess( document.frmTask.lstPermissions,document.frmTask.cboRights );}clgrps_onChange(this);" onClick="OnSelectClientGroup()" >
  169. <%FillClientGroupsList()%>
  170. </select>
  171. </td>
  172. <td class="TasksBody">
  173. <input type="text" name="txtCommName" class="FormField" style="HEIGHT: 22; WIDTH: 175" size="20" onClick="OnSelectNameInput();" OnKeyUP="disableAdd(this,document.frmTask.btnAdd)" onFocus=HandleKey("DISABLE") onBlur=HandleKey("ENABLE") >
  174. </td>
  175. </tr>
  176. </table>
  177. <table>
  178. <tr>
  179. <td class="TasksBody" nowrap>
  180. <%=L_SHARETYPE_TEXT%>
  181. </td>
  182. <td class="TasksBody">
  183. <select name="cboRights" class="FormField" onChange ="changeRights()">
  184. <option value="1,17"><%=L_NOACESS_TEXT%></option>
  185. <option value="2,18"><%=L_READONLY_TEXT%></option>
  186. <option value="4,19" selected><%=L_READWRITE_TEXT%></option>
  187. <option value="10,20"><%=L_READONLY_TEXT & " + " & L_ROOT_TEXT%></option>
  188. <option value="12,21"><%=L_READWRITE_TEXT & " + " & L_ROOT_TEXT%></option>
  189. </select>
  190. </td>
  191. </table>
  192. <table>
  193. <tr>
  194. <td class="TasksBody" align=center width=150>
  195. <%
  196. Call SA_ServeOnClickButtonEx(L_NFS_ADD_TEXT, "", "getUsernames(txtCommName,lstPermissions)", 60, 0, "ENABLED", "btnAdd")
  197. %>
  198. </td>
  199. <td class="TasksBody" align=center width=150>
  200. <%
  201. Call SA_ServeOnClickButtonEx(L_NFS_REMOVE_TEXT, "", "fnbRemove(lstPermissions,'Comm'); if (lstPermissions.length==0){ btnRemove.disabled=true;}", 60, 0, "DISABLED", "btnRemove")
  202. %>
  203. </td>
  204. </tr>
  205. </table>
  206. <%
  207. Call ServeNFSHiddenValues
  208. End Function
  209. '----------------------------------------------------------------------------
  210. 'Function name: ValidateMember()
  211. 'Description: validate the computer name is valid
  212. 'Input Variables: MemberName
  213. 'Oupput Variables: IP value is obtained
  214. 'Return Values: None.
  215. 'GlobalVariables: None
  216. '----------------------------------------------------------------------------
  217. Function ValidateMember(MemberName)
  218. Err.Clear
  219. On Error Resume Next
  220. If isIP(MemberName) Then
  221. ValidateMember=ClientIP(MemberName)
  222. Else
  223. ValidateMember = ClientStr(MemberName)
  224. End if
  225. End Function
  226. '----------------------------------------------------------------------------
  227. 'Function name: ClientStr
  228. 'Description: function for validClient if entered in String format
  229. 'Input Variables: Client
  230. 'Oupput Variables: Hex value of Client for client Id
  231. 'GlobalVariables: None
  232. '----------------------------------------------------------------------------
  233. Function ClientStr(MemberName)
  234. ' It looks like nobody is using this method to convert the machine name
  235. ' to an IP address. If so, this function should be deleted.
  236. ClientStr = ClientIP(MemberName)
  237. Exit Function
  238. End Function
  239. '----------------------------------------------------------------------------
  240. 'Function name: ClientIP
  241. 'Description: function for validClient if entered in IP format
  242. 'Input Variables: Client
  243. 'Oupput Variables: value of Client for client Id
  244. 'GlobalVariables None
  245. '----------------------------------------------------------------------------
  246. Function ClientIP(MemberName)
  247. Err.Clear
  248. On Error Resume Next
  249. Const CONST_UNKNOWN_HOST="UNKNOWN HOST"
  250. If ( TRUE = Ping(MemberName) ) Then
  251. ClientIP = IPaddress
  252. Else
  253. ClientIP = CONST_UNKNOWN_HOST
  254. End If
  255. End Function
  256. '----------------------------------------------------------------------------
  257. 'Function name: FillMembers
  258. 'Description: Serves in printing the permissions of
  259. ' the selected NFSShare in the ListBox
  260. 'Input Variables: Grpname: list the the members of this Group.
  261. 'Output Variables: (None)
  262. 'Global Variables: In:F_strPermissionList -List of Permissions
  263. '----------------------------------------------------------------------------
  264. Function FillMembers(Grpname)
  265. Err.Clear
  266. On Error Resume Next
  267. Dim strCmems ' Member list
  268. Dim nCount ' Count of members
  269. Dim nCounter ' For loop index
  270. Dim clientGroupObj ' CliGrpEnum Object
  271. set clientGroupObj = Server.CreateObject("CliGrpEnum.1")
  272. strCmems = ""
  273. clientGroupObj.machine = GetComputerName
  274. clientGroupObj.ReadClientGroupsReg()
  275. clientGroupObj.presentgroup=Grpname
  276. clientGroupObj.mode = G_MEMBER
  277. clientGroupObj.moveFirst()
  278. nCount = cint(clientGroupObj.memCount(""))
  279. If nCount = 0 Then
  280. strCmems=""
  281. End If
  282. For nCounter=0 to nCount-1
  283. strCmems = strCmems & cstr(clientGroupObj.memName)
  284. ' CligrpEnum throws an exception if you iterate past the end
  285. ' This short circuits the exception
  286. If nCount <> nCounter+1 Then
  287. clientGroupObj.moveNext()
  288. End If
  289. Next
  290. FillMembers = cstr(strCmems) & cstr("->[")
  291. set clientGroupObj = nothing
  292. End Function
  293. '----------------------------------------------------------------------------
  294. 'Function name: getPermissions
  295. 'Description: Serves in printing the permissions of
  296. ' the selected NFSShare in the ListBox
  297. 'Input Variables: (None)
  298. 'Output Variables: (None)
  299. 'Global Variables: In:F_strPermissionList -List of Permissions
  300. '----------------------------------------------------------------------------
  301. Function getPermissions()
  302. Err.Clear
  303. On Error Resume Next
  304. Dim arrPermissionList,arrTemp
  305. Dim strTemp,i,strClient,j,strGlobalP
  306. F_strPermissionList=F_strPermissionList & "N" & "," & strCompName & _
  307. "," & ComputerID & "," & F_strAccessType & "0;"
  308. arrPermissionList=split(F_strPermissionList,";",-1,0)
  309. For i=Lbound(arrPermissionList) To (Ubound(arrPermissionList)-1)
  310. arrTemp=Split(arrPermissionList(i),",")
  311. strGlobalP = arrTemp(3)
  312. strClient=ConvertPerm(strGlobalP)
  313. strTemp=server.htmlencode(arrTemp(1)) & buildSpaces(23-len(arrTemp(1))) & strClient
  314. Response.Write("<option value=" & Chr(34) & server.htmlencode(arrTemp(0)) & "," & _
  315. server.htmlencode(arrTemp(1))&"," & server.htmlencode(arrTemp(2)) &","& server.htmlencode(arrTemp(3)) &","& server.htmlencode(arrTemp(4)) & _
  316. Chr(34)& " >" & replace(strTemp," " ,"&nbsp;") & "</option>")
  317. Next
  318. End Function
  319. '----------------------------------------------------------------------------
  320. 'Function name: getNFSPermissions
  321. 'Description: Gets the NFS Share Permissions from the system
  322. 'Input Variables: (None)
  323. 'Output Variables: (None)
  324. 'Global Variables:
  325. ' IN:G_objRegistryHandle -Server connection for registry to default space
  326. ' OUT:F_REGISTRY_PATH -Path of the registry updated to the current share
  327. ' IN:CONST_STRING -Constant used
  328. ' IN:L_(*) -Localized strings
  329. '----------------------------------------------------------------------------
  330. Function getNFSPermissions()
  331. Err.Clear
  332. On Error Resume Next
  333. Dim arrEnumKeys,arrEnumKeyItems,arrPermissionInfo
  334. Dim strShareName,strPermissionInfo
  335. Dim strClient,strTotal
  336. Dim i,j,k,intWhileCount,intCount,intBound,l,m,n
  337. Dim strEUCJPStatus
  338. Const CONST_REGISTRY_PATH="SOFTWARE\Microsoft\Server For NFS\CurrentVersion\exports"
  339. 'Checking for the null share name If true Exit
  340. If F_strNFSShareName ="" Then
  341. getNFSPermissions=L_PERMISSION_ERRORMESSAGE
  342. Exit Function
  343. End If
  344. F_REGISTRY_PATH =CONST_REGISTRY_PATH
  345. arrEnumKeys = RegEnumKey(G_objRegistryHandle,F_REGISTRY_PATH)
  346. For i = 0 to (ubound(arrEnumKeys))
  347. arrEnumKeyItems = RegEnumKeyValues(G_objRegistryHandle, F_REGISTRY_PATH & "\" & arrEnumKeys(i))
  348. strShareName = getRegkeyvalue(G_objRegistryHandle,F_REGISTRY_PATH & "\" & _
  349. arrEnumKeys(i),"Alias",CONST_STRING)
  350. If (F_strNFSShareName =strShareName) Then
  351. 'getting the value fron the registry
  352. strPermissionInfo = getRegkeyvalue(G_objRegistryHandle,F_REGISTRY_PATH & _
  353. "\" & arrEnumKeys(i),"Clients",CONST_STRING)
  354. 'getting the value of Global permission
  355. F_strGlobalPerm = getRegkeyvalue(G_objRegistryHandle,F_REGISTRY_PATH & _
  356. "\" & arrEnumKeys(i),"globalperm",CONST_DWORD)
  357. strEUCJPStatus = getRegkeyvalue(G_objRegistryHandle,F_REGISTRY_PATH & _
  358. "\" & arrEnumKeys(i),"Encoding",CONST_DWORD)
  359. '
  360. ' SFU 2.3 - 2-28
  361. ' Assign correct state for G_bAllowAnonAccess
  362. G_bAllowAnonAccess = getRegkeyvalue( G_objRegistryHandle, F_REGISTRY_PATH & _
  363. "\" & arrEnumKeys(i),"AllowAnonymousAccess", CONST_DWORD)
  364. Call SA_TraceOut(SA_GetScriptFileName(), "Share: " & F_strNFSShareName & " Property.AllowAnonymousAccess: " & G_bAllowAnonAccess)
  365. If ( G_bAllowAnonAccess >= 1 ) Then
  366. G_bAllowAnonAccess = TRUE
  367. Else
  368. G_bAllowAnonAccess = FALSE
  369. End If
  370. If (CInt(strEUCJPStatus) = 0) Then
  371. F_strEUCJPStatus = "CHECKED"
  372. Else
  373. F_strEUCJPStatus = ""
  374. End If
  375. 'This is to get the total client info from the system
  376. F_strClientInfo=strPermissionInfo
  377. 'This is to use the path in future the same key
  378. F_REGISTRY_PATH=F_REGISTRY_PATH & "\" & arrEnumKeys(i)
  379. arrPermissionInfo = split(strPermissionInfo,",")
  380. intBound = ubound(arrPermissionInfo)
  381. intWhileCount=0
  382. intCount=0
  383. strTotal=""
  384. 'Looping through the array of permissions list
  385. While (intCount < intBound)
  386. j=5*intWhileCount + 0
  387. k=5*intWhileCount + 1
  388. l=5*intWhileCount + 2
  389. m=5*intWhileCount + 3
  390. n=5*intWhileCount + 4
  391. strTotal=strTotal & arrPermissionInfo(j) &","& arrPermissionInfo(k) &","& arrPermissionInfo(l) &","& arrPermissionInfo(m) &","& arrPermissionInfo(n) &";"
  392. intCount=intCount + 5 '5 is the boundary for one user permission
  393. intWhileCount=intWhileCount+1 'increment for ordinary numbers
  394. Wend
  395. 'Returning the string of permissions
  396. getNFSPermissions="0,ALL MACHINES,0," & F_strGlobalPerm & "," & strEUCJPStatus & ";" & strTotal
  397. Exit Function 'After printing of permissions jump
  398. End If 'If (F_strNFSShareName =strShareName)
  399. Next 'For i = 0 to (ubound(arrEnumKeys))
  400. If Err.number <> 0 Then
  401. SA_SetErrMsg L_GETSHAREPERMISSOINS_ERRORMESSAGE & "(" & Hex(Err.Number) & ")"
  402. End If
  403. End Function 'End of function
  404. '----------------------------------------------------------------------------
  405. 'Function name: NFSOnInitPage()
  406. 'Description: Serves in Getting the data from system
  407. 'Input Variables: (None)
  408. 'Output Variables: (None)
  409. 'Global Variables: Out:F_strNFSShareName) -updated Share name(from previous form)
  410. ' In:F_strShareNFSPath -share path(from previous form)
  411. ' Out:F_strPermissionList -List of Permissions
  412. 'Functions used getNFSPermissions()
  413. '----------------------------------------------------------------------------
  414. Function NFSOnInitPage()
  415. Err.Clear
  416. On Error Resume Next
  417. Const CONST_READONLY="0,ALL MACHINES,0,2,7;"
  418. F_strNFSShareName = F_strShareName
  419. F_strShareNFSPath = F_strNewSharePath
  420. '
  421. ' Default state is Anonymous Access disabled
  422. G_bAllowAnonAccess = FALSE
  423. Call SA_TraceOut(SA_GetScriptFileName(), "Setting initial state for G_bAllowAnonAccess = " & G_bAllowAnonAccess)
  424. if instr(F_strShareTypes,"U")> 0 then
  425. 'Function call to get the default share permissions
  426. F_strPermissionList = getNFSPermissions()
  427. Call SA_TraceOut(SA_GetScriptFileName(), "OnInit(U) permissions: " & F_strPermissionList)
  428. G_oldSharePermissionlist= F_strPermissionList
  429. else
  430. F_strPermissionList =CONST_READONLY
  431. Call SA_TraceOut(SA_GetScriptFileName(), "OnInit(NOT U) permissions: " & F_strPermissionList)
  432. G_oldSharePermissionlist = F_strPermissionList
  433. end if
  434. End Function
  435. '----------------------------------------------------------------------------
  436. 'Function name: NFSOnPostBackPage
  437. 'Description: Serves in Getting the data from Client
  438. 'Input Variables: (None)
  439. 'Output Variables: (None)
  440. 'Global Variables: Out:F_strPermissionList -List of Permissions(from form)
  441. ' Out:F_strNFSShareName -Share name(from from)
  442. ' Out:F_strShareNFSPath -Share path(from from)
  443. '----------------------------------------------------------------------------
  444. Function NFSOnPostBackPage()
  445. Err.Clear
  446. On Error Resume Next
  447. Call SA_TraceOut(SA_GetScriptFileName(), "Entering NFSOnPostBackPage")
  448. F_strNFSShareName = F_strShareName
  449. F_strShareNFSPath = F_strNewSharePath
  450. F_strAccessType = Request.Form("cboRights")
  451. F_strCommName = Request.Form("txtCommName")
  452. F_strEUCJPstatus = Request.Form("hidEUCJP")
  453. Call SA_TraceOut(SA_GetScriptFileName(), "Request.Form(chkAllowAnnon): " & Request.Form("chkAllowAnnon"))
  454. If ( Len(Request.Form("hidchkAllowAnnon")) > 0 ) Then
  455. G_bAllowAnonAccess = TRUE
  456. Else
  457. G_bAllowAnonAccess = FALSE
  458. End If
  459. Call SA_TraceOut(SA_GetScriptFileName(), "Post-Back state for G_bAllowAnonAccess = " & G_bAllowAnonAccess)
  460. ' If there is no data in the edit field use from the list box
  461. if ( F_strCommName = "" ) Then
  462. G_bValidateEditText = False
  463. F_strCommName = Request.Form("scrollCliGrp")
  464. F_strCliGrp = Request.Form("scrollCliGrp")
  465. End IF
  466. F_strPermissionList = Request.Form("hidUserNames")
  467. F_strClientInfo = Request.Form("hidClientInfo")
  468. F_REGISTRY_PATH = Request.Form("hidRegistryPath")
  469. F_strGlobalPerm = Request.Form("hidGlobalperm")
  470. G_oldSharePermissionlist = Request.Form("hidOldShareperm")
  471. End Function
  472. '----------------------------------------------------------------------------
  473. 'Function name: UpdateNFSPermissions
  474. 'Description: Serves in Setting user permissions
  475. 'Input Variables: (None)
  476. 'Oupput Variables: Boolean -Returns ( True/Flase )True: If
  477. ' Implemented properly False: If error in Implemented
  478. 'GlobalVariables: In:G_objRegistryHandle -Server connection for registry to default space
  479. ' In:F_REGISTRY_PATH -Path of the registry
  480. ' In:L_(*) -Localized strings
  481. '----------------------------------------------------------------------------
  482. Function UpdateNFSPermissions()
  483. Err.Clear
  484. On Error Resume Next
  485. Dim arrPermissionList
  486. Dim i,j
  487. Dim strQueryForCmd,strTemp
  488. Dim intReturnValue
  489. Dim strQueryForCmdOld
  490. Dim intReturnValueOld
  491. Dim arrPermissionListOld
  492. UpdateNFSPermissions = False
  493. strQueryForCmd = ""
  494. If not ServerSideValidation Then
  495. Call SA_TraceOut(SA_GetScriptFileName(), "ServerSideValidation failed")
  496. UpdateNFSPermissions = False
  497. Exit function
  498. End if
  499. If trim(F_strPermissionList) <> "" Then
  500. arrPermissionList= split(F_strPermissionList,";")
  501. strQueryForCmd = strQueryForCmd & getClientsAndPermissions(arrPermissionList(0),False)
  502. 'Checking for the share with allmachines no access
  503. IF ( Ucase(Trim(strQueryForCmd)) = Ucase("No Access") ) Then
  504. IF ( Ubound(arrPermissionList)=1 and arrPermissionList(1)<> "") Then
  505. SA_SetErrMsg L_CANNOTCREATE_EMPTY_SHARE__ERRORMESSAGE & "(" & Hex(Err.Number) & ")"
  506. Exit Function
  507. Else
  508. strQueryForCmd=""
  509. End IF
  510. End IF
  511. 'Applying the ANON property on every share
  512. If ( TRUE = G_bAllowAnonAccess ) Then
  513. strQueryForCmd=strQueryForCmd & "ANON=YES "
  514. Else
  515. strQueryForCmd=strQueryForCmd & "ANON=NO "
  516. End If
  517. 'Applying the EUCJP property on the share
  518. IF (Ucase(F_strEUCJPStatus)="CHECKED") Then
  519. strQueryForCmd=strQueryForCmd & "ENCODING=EUC-JP "
  520. End If
  521. FOR i = 1 to ubound(arrPermissionList) - 1
  522. strQueryForCmd = strQueryForCmd & getClientsAndPermissions(arrPermissionList(i),True)
  523. Next
  524. End if
  525. 'Call to Delete a share
  526. Call SA_TraceOut(SA_GetScriptFileName(), "Deleting share " & F_strNFSShareName & " before setting new attributes")
  527. If NOT deleteShareNFS(F_strNFSShareName) Then
  528. Call SA_TraceOut(SA_GetScriptFileName(), "Delete failed with error: " & Hex(Err.Number) & " " & Err.Description)
  529. SA_SetErrMsg L_UPDATION_FAIL_ERRORMESSAGE
  530. Exit Function
  531. End If
  532. Call SA_TraceOut(SA_GetScriptFileName(), "Calling CreateNFSShare(" & F_strNFSShareName & ", " & F_strShareNFSPath & ", " & strQueryForCmd & ")" )
  533. intReturnValue = CreateNFSShare(F_strNFSShareName, F_strShareNFSPath, strQueryForCmd)
  534. '
  535. ' Check for success
  536. If ( Err.Number = 0 AND intReturnValue = TRUE ) Then
  537. '
  538. ' Success, we're out of here
  539. Call SA_TraceOut(SA_GetScriptFileName(), "UpdateNFSPermissions success!")
  540. UpdateNFSPermissions = TRUE
  541. Exit Function
  542. End If
  543. '
  544. ' Failure
  545. Call SA_TraceOut(SA_GetScriptFileName(), "Create share failed with error: " & Hex(Err.Number) & " " & Err.Description)
  546. ' Rollback
  547. if trim(G_oldSharePermissionlist) <> "" then
  548. arrPermissionListOld= split(G_oldSharePermissionlist,";")
  549. strQueryForCmdOld = strQueryForCmdOld & getClientsAndPermissions(arrPermissionListOld(0),False)
  550. FOR j = 1 to ubound(arrPermissionList) - 1
  551. strQueryForCmdOld = strQueryForCmdOld & getClientsAndPermissions(arrPermissionListOld(j),True)
  552. Next
  553. intReturnValueOld = CreateNFSShare(F_strNFSShareName, F_strShareNFSPath, strQueryForCmdOld)
  554. If not intReturnValueOld = true Then
  555. Call SA_ServeFailurepage(L_UPDATIONFAIL_DELETE_ERRORMESSAGE)
  556. End if
  557. end if
  558. '
  559. ' Set failure error message
  560. SA_SetErrMsg L_UPDATION_FAIL_ERRORMESSAGE
  561. End Function
  562. '----------------------------------------------------------------------------
  563. 'Function name: getClientsAndPermissions
  564. 'Description: Serves in building the string of permissions of the
  565. ' clientGroups to send as input to the nfsshare.exe
  566. 'Input Variables: In: strClientPermValue - the comma seperated values for a given client
  567. ' In: blnAppendClient - Is the client Name needs to be appended in the inParam to exe?
  568. 'Oupput Variables: None
  569. 'Returns: The String of ClientGroups and their permissions
  570. ' Example: RW RO="abc" RW="xyz"
  571. 'GlobalVariables: None
  572. '----------------------------------------------------------------------------
  573. Function getClientsAndPermissions(strClientPermValue, blnAppendClient)
  574. Err.Clear
  575. On Error Resume Next
  576. Dim strReturnValue
  577. Dim strRoot
  578. Dim arrClientPermissions
  579. Dim strClient
  580. Dim strPermissions
  581. Const CONST_NA= "No Access"
  582. Const CONST_RO= "RO"
  583. Const CONST_RW= "RW"
  584. Const CONST_ROOT= "ROOT"
  585. strReturnValue = ""
  586. strRoot = ""
  587. If strClientPermValue = "" Then
  588. getClientsAndPermissions = strReturnValue
  589. Exit Function
  590. End If
  591. arrClientPermissions = Split(strClientPermValue,",")
  592. strClient = Chr(34) & replace(arrClientPermissions(1),chr(34), "\" & chr(34)) & Chr(34)
  593. strPermissions = arrClientPermissions(3)
  594. Select Case CInt(strPermissions)
  595. Case 1
  596. strReturnValue = CONST_NA
  597. Case 2
  598. strReturnValue = CONST_RO
  599. Case 4
  600. strReturnValue = CONST_RW
  601. Case 9
  602. strReturnValue = CONST_NA
  603. strRoot = CONST_ROOT
  604. Case 10
  605. strReturnValue = CONST_RO
  606. strRoot = CONST_ROOT
  607. Case 12
  608. strReturnValue = CONST_RW
  609. strRoot = CONST_ROOT
  610. Case Else
  611. ' this will not occur
  612. strReturnValue = CONST_RO
  613. End SELECT
  614. If blnAppendClient = FALSE Then
  615. strReturnValue = strReturnValue
  616. Else
  617. strReturnValue = strReturnValue & "=" & strClient
  618. End If
  619. if strRoot <> "" Then
  620. If blnAppendClient = FALSE Then
  621. strReturnValue = strReturnValue & " " & strRoot
  622. Else
  623. strReturnValue = strReturnValue & " " & strRoot & "=" & strClient
  624. End If
  625. End If
  626. getClientsAndPermissions = strReturnValue & " "
  627. End Function
  628. '----------------------------------------------------------------------------
  629. 'Function name: ConvertIP
  630. 'Description: function converts the IP address to the HEX value
  631. ' for clinetid to be updated in registry.
  632. 'Input Variables: IP Address.
  633. 'OutPut Variables: HEX value
  634. '----------------------------------------------------------------------------
  635. Function ConvertIP(IPaddress)
  636. Err.Clear
  637. On Error Resume Next
  638. Dim IPValue,IP,IP1,IP2,IP3,IP4
  639. IP = split(IPaddress,".")
  640. IP1 =hex(IP(0))
  641. if IP(0) <=9 then
  642. IP1 = 0 & IP1
  643. end if
  644. IP2=hex(IP(1))
  645. if IP(1) <=9 then
  646. IP2 = 0 & IP2
  647. end if
  648. IP3=hex(IP(2))
  649. if IP(2) <=9 then
  650. IP3 = 0 & IP3
  651. end if
  652. IP4= hex(IP(3))
  653. if IP(3) <=9 then
  654. IP4 = 0 & IP4
  655. end if
  656. IPValue= LCase(IP4&IP3&IP2&IP1)
  657. ConvertIP= IPValue
  658. End Function
  659. '----------------------------------------------------------------------------
  660. 'Function name: isIP
  661. 'Description: function checks for valid IP format
  662. 'Input Variables: IP Address.
  663. 'OutPut Variables: returns true if in IP format or returns false
  664. '----------------------------------------------------------------------------
  665. Function isIP(strIP)
  666. Err.Clear
  667. On Error Resume Next
  668. isIP = TRUE
  669. Dim i
  670. For i = 1 to Len(strIP)
  671. If mid(strIP,i,1) <> "." and Not isNumeric(mid(strIP,i,1)) Then
  672. isIP = FALSE
  673. Exit Function
  674. End if
  675. Next
  676. End Function
  677. '----------------------------------------------------------------------------
  678. 'Function name: ConvertPerm
  679. 'Description: Converts the permissions which is int value to a string
  680. 'Input Variables: (None)
  681. 'Oupput Variables: permission description is obtained
  682. 'GlobalVariables: None
  683. '----------------------------------------------------------------------------
  684. Function ConvertPerm(arg_str)
  685. Err.Clear
  686. On Error Resume Next
  687. Const INVALIDENTRY="invalid entry"
  688. Dim strClient
  689. select case arg_str
  690. case 1,17:
  691. strClient=L_NOACESS_TEXT
  692. case 2,18:
  693. strClient=L_READONLY_TEXT
  694. case 4,19:
  695. strClient=L_READWRITE_TEXT
  696. case 9,20:
  697. strClient=L_NOACESS_TEXT & " + " & L_ROOT_TEXT
  698. case 10,21:
  699. strClient=L_READONLY_TEXT & " + " & L_ROOT_TEXT
  700. case 12,22:
  701. strClient=L_READWRITE_TEXT & " + " & L_ROOT_TEXT
  702. case else
  703. strClient =INVALIDENTRY
  704. End Select
  705. ConvertPerm = strClient
  706. End Function
  707. '---------------------------------------------------------------------
  708. 'Function name: buildSpaces
  709. 'Description: Helper function to return String with nbsps
  710. ' which act as spaces in the list box
  711. 'Input Variables: intCount -spacesCount
  712. 'OutPut Variables: spacesstring -Returns the nbsp string
  713. '---------------------------------------------------------------------
  714. Function buildSpaces(intCount)
  715. Err.Clear
  716. On Error Resume Next
  717. Dim i , strSpace
  718. strSpace="&nbsp;"
  719. 'Forming a string with the count send as parameter
  720. For i=1 To intCount
  721. strSpace=strSpace & "&nbsp;"
  722. Next
  723. buildSpaces=strSpace
  724. End Function
  725. '----------------------------------------------------------------------------
  726. ' Function name: FillClientGroupsList
  727. ' Description: Builds the client group list.
  728. ' Input Variables: None
  729. ' Output Variables: None
  730. ' Returns: None
  731. ' Global Variables: G_CLGRPS
  732. '----------------------------------------------------------------------------
  733. Function FillClientGroupsList()
  734. Err.Clear
  735. On Error Resume Next
  736. Dim strCgrps ' Client groups
  737. Dim arrMembers ' Array of Members
  738. Dim nGroupCount ' Group count
  739. Dim nCounter ' index into group loop
  740. Dim nMemCounter ' index into members in a group list
  741. Dim nArrMemCount ' Total member count
  742. Dim clientGroupObj ' CliGrpEnum.1 object
  743. clientGroupObj = null
  744. Dim arrAllMembers() 'Array of all members within all groups
  745. ReDim arrAllMembers( G_nMEMBERS)
  746. set clientGroupObj = Server.CreateObject("CliGrpEnum.1")
  747. clientGroupObj.machine = GetComputerName
  748. clientGroupObj.ReadClientGroupsReg()
  749. clientGroupObj.mode = G_GROUP
  750. clientGroupObj.moveFirst()
  751. nGroupCount = cint(clientGroupObj.grpCount)
  752. nArrMemCount = -1
  753. If nGroupCount=0 Then
  754. strCgrps=""
  755. End If
  756. For nCounter= 0 to nGroupCount-1
  757. strCgrps = strCgrps & cstr(clientGroupObj.grpName) & "->["
  758. For nMemCounter = 0 to (ubound(arrMembers))-1
  759. If Not bIsMember( arrAllMembers, arrMembers(nMemCounter), nArrMemCount ) Then
  760. 'Response.Write "<OPTION VALUE=" & chr(34) & server.htmlencode(cstr(arrMembers(nMemCounter)))&","&"G" & chr(34) & ">" & _
  761. Response.Write "<OPTION VALUE=" & chr(34) & server.htmlencode(cstr(arrMembers(nMemCounter))) & chr(34) & ">" & _
  762. replace(Server.HTMLEncode( arrMembers(nMemCounter))," ", "&nbsp;") & "</OPTION>"
  763. nArrMemCount = nArrMemCount + 1
  764. arrAllMembers( nArrMemCount ) = arrMembers(nMemCounter)
  765. End If
  766. Next
  767. 'Response.Write "<OPTION VALUE=" & chr(34) & server.HTMLEncode(cstr(clientGroupObj.grpName))&","& "G" & chr(34) & ">" & _
  768. Response.Write "<OPTION VALUE=" & chr(34) & server.HTMLEncode(cstr(clientGroupObj.grpName)) & chr(34) & ">" & _
  769. replace(Server.HTMLEncode(cstr(clientGroupObj.grpName))," " ,"&nbsp;") & "</OPTION>"
  770. ' CligrpEnum throws an exception if you iterate past the end
  771. ' This short circuits the exception
  772. If nGroupCount <> nCounter+1 Then
  773. clientGroupObj.moveNext()
  774. End If
  775. Next
  776. G_CLGRPS = strCgrps
  777. set clientGroupObj = nothing
  778. End Function
  779. '----------------------------------------------------------------------------
  780. ' Function name: bIsMember
  781. ' Description : Tests is a member needed to be added to the client group list.
  782. ' Input Variables: In:aaCliAndCligrps)- Existing list of Members ( array )
  783. ' In:strNewMem - New Member to be added to the list.
  784. ' In:intCount - Count of members in above array.
  785. ' Output Variables: None
  786. ' Returns: True, if strNewMem is already a member, otherwise False
  787. '----------------------------------------------------------------------------
  788. Function bIsMember( arrCliAndCliGrps, strNewMem, nCount )
  789. Err.Clear
  790. On Error Resume Next
  791. Dim nMemCounter ' For loop index
  792. bIsMember = False
  793. If strNewMem = "" Then
  794. bIsMember = True
  795. Else
  796. If nCount > -1 Then
  797. For nMemCounter = 0 to nCount
  798. If UCASE(strNewMem) = UCASE( arrCliAndCliGrps(nMemCounter) ) Then
  799. bIsMember = True
  800. End If
  801. Next
  802. End If
  803. End If
  804. End Function
  805. Function GetAnnonAccessCurrentState()
  806. If ( G_bAllowAnonAccess ) Then
  807. GetAnnonAccessCurrentState = "ON"
  808. Else
  809. GetAnnonAccessCurrentState = ""
  810. End If
  811. Call SA_TraceOut(SA_GetScriptFileName(), "GetAnnonAccessCurrentState returning: " & GetAnnonAccessCurrentState)
  812. End Function
  813. Function GetAnnonAccessCheckState()
  814. If ( G_bAllowAnonAccess ) Then
  815. GetAnnonAccessCheckState = " CHECKED "
  816. Else
  817. GetAnnonAccessCheckState = ""
  818. End If
  819. Call SA_TraceOut(SA_GetScriptFileName(), "GetAnnonAccessCheckState returning: " & GetAnnonAccessCheckState)
  820. End Function
  821. '------------------------------------------------------------------
  822. 'Function name: ServeNFSHiddenValues()
  823. 'Description: Serve Hidden Values
  824. 'Input Variables: None
  825. 'Output Variables: None
  826. 'Global Variables: F_(*)
  827. '------------------------------------------------------------------
  828. function ServeNFSHiddenValues()
  829. On error resume next
  830. Err.clear
  831. %>
  832. <input type="hidden" name="hidClientInfo" value="<%=server.htmlencode(F_strClientInfo)%>">
  833. <input type="hidden" name="hidGlobalperm" value="<%=F_strGlobalPerm%>">
  834. <input type="hidden" name="hidRegistryPath" value="<%=F_REGISTRY_PATH%>">
  835. <input type="hidden" name="hidUserNames" value="<%=Server.htmlencode(F_strPermissionList)%>">
  836. <input type="hidden" name="hidAddBtn" value="<%=F_bAddBtnClick%>">
  837. <input type="hidden" name="hidstrShareName" value="<%=F_strNFSShareName%>">
  838. <input type="hidden" name="hidstrSharePath" value="<%=F_strShareNFSPath%>">
  839. <input type="hidden" name="hidCliGrp" value="<%=Server.htmlencode(F_strCliGrp)%>">
  840. <input type="hidden" name="hidOldShareperm" value="<%=Server.htmlencode(G_oldSharePermissionlist)%>">
  841. <input type="hidden" name="hidEUCJP" value="<%=F_strEUCJPstatus%>">
  842. <input type="hidden" name="hidchkAllowAnnon" value="<%=GetAnnonAccessCurrentState()%>" >
  843. <input type="hidden" name="hidGroups" value="<%=Server.htmlencode(G_CLGRPS)%>">
  844. <input type="hidden" name="blnnewCligrp">
  845. <input type="hidden" name="blnremCligrp">
  846. <input type="hidden" name="blnnewMem">
  847. <input type="hidden" name="blnremMem">
  848. <input type="hidden" name="newCligrp">
  849. <input type="hidden" name="remCligrp">
  850. <input type="hidden" name="newMem">
  851. <input type="hidden" name="remMem">
  852. <input type="hidden" name="grpmem">
  853. <%
  854. End Function
  855. %>