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.

410 lines
11 KiB

  1. <%@ Language=VBScript%>
  2. <%Option Explicit%>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' nfsclientgroups_edit_prop.asp:Edit the Properties of the selected NFS
  6. ' Client Group.
  7. '
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Date Description
  11. ' 27-Sept-2000 Started
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual="/admin/inc_framework.asp" -->
  15. <!-- #include file="loc_NFSSvc.asp" -->
  16. <!-- #include file="inc_NFSSvc.asp" -->
  17. <%
  18. '-------------------------------------------------------------------------
  19. ' Form Variables
  20. '-------------------------------------------------------------------------
  21. Dim F_ClientGroupName ' The nfs Clientgroup name
  22. Dim F_ClientGroupMembers ' The Current GroupMembers
  23. '-------------------------------------------------------------------------
  24. ' Create the page and Event handler
  25. '-------------------------------------------------------------------------
  26. Dim page
  27. Dim rc
  28. rc = SA_CreatePage(L_CLIENTGROUPSEDIT_TITLE_TEXT, "", PT_PROPERTY, page)
  29. If rc = 0 Then
  30. SA_ShowPage( page )
  31. End If
  32. Public Function OnInitPage( ByRef PageIn, ByRef EventArg)
  33. SetVariablesFromsystem
  34. OnInitPage = True
  35. End Function
  36. Public Function OnPostBackPage( ByRef PageIn, ByRef EventArg)
  37. SetVariablesFromForm
  38. OnPostBackPage = True
  39. End Function
  40. Public Function OnServePropertyPage( ByRef PageIn, ByRef EventArg)
  41. Call ServeCommonJavaScript()
  42. %>
  43. <TABLE VALIGN="middle" ALIGN="left" BORDER="0" CELLSPACING="0"
  44. CELLPADDING="2" WIDTH="518">
  45. <TR>
  46. <TD class="TasksBody" colspan=4>
  47. <%=L_EDIT_DESCRIPTION_TEXT%>
  48. </TD>
  49. </TR>
  50. <TR><TD class="TasksBody" colspan=4>&nbsp;</TD></TR>
  51. <TR>
  52. <TD class="TasksBody" NOWRAP >
  53. <%=L_GROUPNAME_TEXT%>
  54. </TD>
  55. <TD class="TasksBody" NOWRAP width="132">
  56. <input type="text" name="txtgroupname"
  57. value="<%=F_ClientGroupName%>" style="width:132"
  58. maxlength="25" class=FormField readonly>
  59. </TD>
  60. <TD class="TasksBody">
  61. </TD>
  62. <TD class="TasksBody" nowrap>
  63. <%=L_CLIENTNAME_TEXT%>
  64. </TD>
  65. </TR>
  66. <TR height="22">
  67. <TD class="TasksBody" NOWRAP rowspan="2">
  68. <%=L_MEMBERS_TEXT%>
  69. </TD>
  70. <TD class="TasksBody" NOWRAP rowspan="2">
  71. <select name="lstMembers" size="5" style="width:132"
  72. class=FormField >
  73. <%DisplayMembers()%>
  74. </select>
  75. </TD>
  76. <TD class="TasksBody" NOWRAP align="center" valign="top" width="110">
  77. <% Call SA_ServeOnClickButtonEx(L_MEMBERSADDBTN_TEXT, "", "AddtoListbox()", 50, 0, "DISABLED","btnmembersadd") %>
  78. </TD>
  79. <TD class="TasksBody" NOWRAP valign="top" rowspan="2" >
  80. <input type="text" name="txtmembersadd" style="width:160"
  81. maxlength="25" class=FormField
  82. onKeyPress="javascript:ClearErr()"
  83. onkeyup="EnableAddBtn()">
  84. </TD>
  85. </TR>
  86. <TR>
  87. <TD class="TasksBody" NOWRAP align="center" valign="top" width="110">
  88. <% Call SA_ServeOnClickButtonEx(L_MEMBERSREMOVEBTN_TEXT, "", "DeletefromListbox()", 50, 0, "DISABLED","btnmembersremove") %>
  89. </TD>
  90. </TR>
  91. </TABLE>
  92. <input type="hidden" name="hidnewGroupName" Value="<%=F_ClientGroupName%>">
  93. <input type="hidden" name="hidGroupmembers" Value="<%=F_ClientGroupMembers%>">
  94. <%
  95. OnServePropertyPage = True
  96. End Function
  97. Public Function OnSubmitPage( ByRef PageIn, ByRef EventArg)
  98. OnSubmitPage = EditClientGroup()
  99. End Function
  100. Public Function OnClosePage( ByRef PageIn, ByRef EventArg)
  101. OnClosePage = True
  102. End Function
  103. Function ServeCommonJavaScript()
  104. %>
  105. <script language = "JavaScript" src = "<%=m_VirtualRoot%>inc_global.js">
  106. </script>
  107. <script language = "JavaScript">
  108. var objForm = eval("document.frmTask");
  109. var intSelTab = objForm.TabSelected.value;
  110. function Init()
  111. {
  112. var strReturnurl=location.href;
  113. var tempCnt=strReturnurl.indexOf("&ReturnURL=");
  114. var straction=strReturnurl.substring(0,tempCnt);
  115. objForm.action = straction;
  116. objForm.Method.value = "";
  117. //Disabling the remove button
  118. if(objForm.lstMembers.length==0)
  119. {
  120. objForm.btnmembersremove.disabled=true;
  121. }
  122. else
  123. {
  124. objForm.btnmembersremove.disabled=false;
  125. }
  126. }
  127. function ValidatePage()
  128. {
  129. return true;
  130. }
  131. function SetData()
  132. {
  133. // Assigning all the members to a string with a wildcharacters
  134. var strleng=objForm.lstMembers.length;
  135. var strMembers="";
  136. for (i=0;i < strleng;i++)
  137. {
  138. if (i==0)
  139. strMembers=objForm.lstMembers.options[i].value;
  140. else
  141. strMembers= strMembers + "," +objForm.lstMembers.
  142. options[i].value;
  143. }
  144. objForm.hidGroupmembers.value=strMembers;
  145. }
  146. function EnableAddBtn()
  147. {
  148. if(Trim(objForm.txtmembersadd.value)!="")
  149. {
  150. objForm.btnmembersadd.disabled=false;
  151. }
  152. else
  153. objForm.btnmembersadd.disabled=true;
  154. }
  155. function AddtoListbox()
  156. {
  157. var i;
  158. var MemberName = Trim(objForm.txtmembersadd.value);
  159. //If the member has exist in members list, display error
  160. for(i=0;i < objForm.lstMembers.length;i++)
  161. {
  162. if(objForm.lstMembers.options[i].value.toUpperCase()==
  163. MemberName.toUpperCase())
  164. {
  165. DisplayErr(MemberName+"<%=Server.HTMLEncode(L_MEMBEREXIST_ERRORMESSAGE)%>");
  166. objForm.txtmembersadd.select();
  167. objForm.txtmembersadd.focus();
  168. return;
  169. }
  170. }
  171. if(MemberName.indexOf(".")!=-1)
  172. {
  173. if(isValidIP(objForm.txtmembersadd)==0)
  174. {
  175. addToListBox(objForm.lstMembers,objForm.
  176. btnmembersremove,MemberName,
  177. MemberName);
  178. objForm.txtmembersadd.value="";
  179. }
  180. else
  181. DisplayErr("<% =Server.HTMLEncode(L_INVALID_MEMBER)%>");
  182. }
  183. else
  184. {
  185. if(isNaN(MemberName))
  186. {
  187. addToListBox(objForm.lstMembers,objForm.
  188. btnmembersremove,MemberName,
  189. MemberName);
  190. objForm.txtmembersadd.value="";
  191. }
  192. else
  193. {
  194. DisplayErr("<% =Server.HTMLEncode(L_INVALID_MEMBER) %>");
  195. }
  196. }
  197. //set the button to disable
  198. objForm.btnmembersadd.disabled=true;
  199. }
  200. function DeletefromListbox()
  201. {
  202. removeListBoxItems(objForm.lstMembers,objForm.
  203. btnmembersremove);
  204. }
  205. //Function for focus when raises the errmsg
  206. function setFocus(objErr)
  207. {
  208. objErr.focus();
  209. objErr.select();
  210. }
  211. </script>
  212. <%
  213. End Function
  214. '-------------------------------------------------------------------------
  215. 'Function name: SetVariablesFromSystem
  216. 'Description: Serves in Getting the data from System
  217. 'Input Variables: None
  218. 'Output Variables: None
  219. 'Returns: None
  220. 'Global Variables: In:
  221. ' Out:
  222. '-------------------------------------------------------------------------
  223. Function SetVariablesFromSystem
  224. Err.Clear
  225. On Error Resume Next
  226. Dim StrClientGroupName
  227. ' Nfs ClientGroupName is obtained from QueryString
  228. StrClientGroupName= Request.QueryString("Pkey")
  229. F_ClientGroupName=StrClientGroupName
  230. If F_ClientGroupName = "" OR Err.Number <> 0 Then
  231. SA_ServeFailurePage L_PROPERTYNOTRETRIEVED_ERRORMESSAGE
  232. End if
  233. F_ClientGroupMembers = NFS_ListMembersInGroup(F_ClientGroupName)
  234. F_ClientGroupMembers= Mid( F_ClientGroupMembers, 1, len( F_ClientGroupMembers )-1 )
  235. End Function
  236. '-------------------------------------------------------------------------
  237. 'Function name: SetVariablesFromForm
  238. 'Description: Serves in Getting the data from Client
  239. 'Input Variables: None
  240. 'Output Variables: None
  241. 'Returns: None
  242. 'Global Variables: In:
  243. ' Out:
  244. '-------------------------------------------------------------------------
  245. Function SetVariablesFromForm
  246. 'Err.Clear
  247. 'On Error Resume Next
  248. F_ClientGroupName=Request.Form("hidnewGroupName")
  249. F_ClientGroupMembers=Request.Form("hidGroupmembers")
  250. Call SA_TraceOut( "F_ClientGroupName: ", F_ClientGroupName )
  251. Call SA_TraceOut( " F_ClientGroupMembers: ", F_ClientGroupMembers )
  252. End Function
  253. '-------------------------------------------------------------------------
  254. 'Function name: DisplayMembers
  255. 'Description: Serves in Displaying the Members of given Client
  256. ' Group in a list box.
  257. 'Input Variables: None
  258. 'Output Variables: None
  259. 'Returns: None
  260. 'Global Variables: In:F_ClientGroupName -NFs Client Group Name
  261. '-------------------------------------------------------------------------
  262. Function DisplayMembers
  263. Err.Clear
  264. On Error Resume Next
  265. Dim strMembers
  266. Dim intMembers
  267. Dim intMembersCount
  268. strMembers=Split(F_ClientGroupMembers,",")
  269. intMembersCount=ubound(strMembers)
  270. If g_strMemberAtFault = "" Then
  271. Response.Write "<option value="&strMembers(0)& _
  272. " selected>" & strMembers(0)&"</option>"
  273. For intMembers=1 to intMembersCount
  274. Response.Write "<option value="&strMembers(intMembers)& _
  275. ">" & strMembers(intMembers)&"</option>"
  276. next
  277. Else
  278. For intMembers=0 to intMembersCount
  279. If strMembers(intMembers) = g_strMemberAtFault then
  280. Response.Write "<option value="&strMembers(intMembers)& _
  281. " selected>" & strMembers(intMembers)&"</option>"
  282. else
  283. Response.Write "<option value="&strMembers(intMembers)& _
  284. ">" & strMembers(intMembers)&"</option>"
  285. end if
  286. next
  287. End If
  288. End Function
  289. '-------------------------------------------------------------------------
  290. 'Function name: EditClientGroup()
  291. 'Description: Serves in Editing the Members of a Client Group
  292. 'Input Variables: None
  293. 'Output Variables: None
  294. 'Returns: None
  295. 'Global Variables: In:L_(*) -Localization Varibles.
  296. ' In:F_ClientGroupName -NFs Client Group Name
  297. ' In:F_ClientGroupMembers -The Current GroupMembers in
  298. ' the present Group.
  299. ' In:F_ClientGroupMembers --GroupMembers to be
  300. ' added to Present Group
  301. '-------------------------------------------------------------------------
  302. Function EditClientGroup( )
  303. Err.Clear
  304. on error resume next
  305. Dim ObjClientGroups
  306. Dim intMembers
  307. Dim intMembersCount
  308. Dim arrMembers
  309. Dim nRetValue
  310. EditClientGroup = False
  311. ' Check to see if the groups exists
  312. nRetValue = NFS_IsValidGroup( F_ClientGroupName )
  313. If Not HandleError( nRetValue ) Then
  314. Exit Function
  315. End If
  316. Dim strMembers
  317. strMembers = NFS_ListMembersInGroup(F_ClientGroupName)
  318. If (Len(strMembers) > 0) Then
  319. If (Right(strMembers, 1) = ",") Then
  320. strMembers = Left(strMembers, Len(strMembers) - 1)
  321. End If
  322. End If
  323. nRetValue = NFS_DeleteMembersFromGroup ( F_ClientGroupName, strMembers )
  324. If nRetValue = ERROR_SUCCESS Then
  325. nRetValue = NFS_AddMembersToGroup ( F_ClientGroupName, F_ClientGroupMembers )
  326. End If
  327. If Not HandleError( nRetValue ) Then
  328. Exit Function
  329. End If
  330. If nRetValue = ERROR_SUCCESS Then
  331. EditClientGroup = True
  332. Else
  333. EditClientGroup = False
  334. End If
  335. End Function
  336. %>