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.

434 lines
12 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' nfsmaps_prop.asp: display and update NFS User and Group Map properties
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 26 Sep 2000 Creation Date
  11. '-------------------------------------------------------------------------
  12. %>
  13. <!-- #include virtual="/admin/inc_framework.asp" -->
  14. <!-- #include file="loc_NFSSvc.asp" -->
  15. <!-- #include file="inc_NFSSvc.asp" -->
  16. <!-- #include file="nfsgeneral_prop.asp" -->
  17. <!-- #include file="nfssimplemaps_prop.asp" -->
  18. <!-- #include file="nfsusersmaps_prop.asp" -->
  19. <!-- #include file="nfsgroupmaps_prop.asp" -->
  20. <%
  21. Err.Clear
  22. On Error Resume Next
  23. '------------------------------------------------------------------
  24. 'Constants
  25. '------------------------------------------------------------------
  26. Const TABINDEX_GENTAB = 0 ' to identify the General page
  27. Const TABINDEX_SIMPLEMAPTAB = 1 ' to identify the SimpleMap page
  28. Const TABINDEX_USERMAPTAB = 2 ' to idetify the UserMap page
  29. Const TABINDEX_GROUPMAPTAB = 3 ' to identify the GroupMap page
  30. '-------------------------------------------------------------------------
  31. ' Create web UI for user mapings
  32. '--------------------------------------------------------------------------
  33. Dim rc
  34. Dim page
  35. Dim idTab1
  36. Dim idTab2
  37. Dim idTab3
  38. Dim idTab4
  39. rc = SA_CreatePage(L_NFS_USERGROUPMAP_TASKTITLE_TEXT,"", PT_TABBED, page)
  40. If (rc = 0 ) Then
  41. rc = SA_AddTabPage(page, L_TAB_GENERAL_LABEL_TEXT, idTab1)
  42. rc = SA_AddTabPage(page, L_TAB_SIMPLEMAP_LABEL_TEXT, idTab2)
  43. rc = SA_AddTabPage(page, L_TAB_EXPUSERMAP_LABEL_TEXT, idTab3)
  44. rc = SA_AddTabPage(page, L_TAB_EXPGROUPMAP_LABEL_TEXT, idTab4)
  45. rc = SA_ShowPage(page)
  46. End If
  47. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  48. SetVariablesFromSystem
  49. OnInitPage = True
  50. End Function
  51. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  52. On Error Resume Next
  53. Err.Clear
  54. Dim strNISDomain
  55. Dim strNISserver
  56. Dim tmpMapping
  57. Dim i,cUserMappings,cGroupMappings
  58. Dim arrMapField
  59. Dim arrUserMaps
  60. Dim arrGroupMaps
  61. SetVariablesFromForm
  62. If(mstrMethod = "AddDomainUserMap") Then
  63. If IsValidDomainUser(F_strDomainUser) Then
  64. 'is a valid user, then we will add the mapping
  65. 'check whether the user have exists
  66. arrUserMaps = Split(F_strMapsToUser,"#")
  67. cUserMappings = ubound(arrUserMaps)
  68. For i=0 To cUserMappings
  69. arrMapField = Split(arrUserMaps(i),":")
  70. If (arrMapField(1) = F_strDomainUser) Then
  71. SetErrMsg L_WINDOWSUSERALREADYMAPPED_ERRORMESSAGE
  72. OnPostBackPage = False
  73. Exit Function
  74. End If
  75. Next
  76. 'add the user mapping
  77. If F_intGen_SelectedRadio = "0" Then
  78. strNISDomain = "PCNFS"
  79. strNISserver = "PCNFS"
  80. Else
  81. strNISDomain = F_strGen_NisDomain
  82. strNISserver = F_strGen_NisServer
  83. End If
  84. tmpMapping = "^"&":"&F_strDomainUser&":"&F_intGen_SelectedRadio&":"& _
  85. strNISDomain&":"&strNISserver&":"& _
  86. Request.Form("hdnNisUserName")&":"&Request.Form("selUNIXUsers")
  87. F_strMapsToUser = F_strMapsToUser &"#"&tmpMapping
  88. F_strDomainUser = ""
  89. Else
  90. OnPostBackPage = False
  91. Exit Function
  92. End If
  93. Elseif(mstrMethod = "AddDomainGroupMap") Then
  94. If IsValidDomainGroup(F_strDomainGroup) Then
  95. 'is a valid user, then we will add the mapping
  96. 'check whether the user have exists
  97. arrGroupMaps = Split(F_strMapsToGroup,"#")
  98. cGroupMappings = ubound(arrGroupMaps)
  99. For i=0 To cGroupMappings
  100. arrMapField = Split(arrGroupMaps(i),":")
  101. If (arrMapField(1) = F_strDomainGroup) Then
  102. SetErrMsg L_WINGROUPALREADYMAPPED_ERRORMESSAGE
  103. OnPostBackPage = False
  104. Exit Function
  105. End If
  106. Next
  107. 'add the group mapping
  108. If F_intGen_SelectedRadio = "0" Then
  109. strNISDomain = "PCNFS"
  110. strNISserver = "PCNFS"
  111. Else
  112. strNISDomain = F_strGen_NisDomain
  113. strNISserver = F_strGen_NisServer
  114. End If
  115. tmpMapping = "^"&":"&F_strDomainGroup&":"&F_intGen_SelectedRadio&":"& _
  116. strNISDomain&":"&strNISserver&":"& _
  117. Request.Form("selUNIXGroups")
  118. F_strMapsToGroup = F_strMapsToGroup& "#" &tmpMapping
  119. F_strDomainGroup = ""
  120. Else
  121. OnPostBackPage = False
  122. Exit Function
  123. End If
  124. Elseif (mstrMethod = "GetUNIXUsers") Then
  125. If CInt(F_intGen_SelectedRadio) <> CONST_RADIO_USE_NISSERVER Then
  126. F_strNisAccountToUser = NFS_ReadUsersFromFile(F_strGen_PasswdFile,F_strGen_GroupFile)
  127. else
  128. F_strNisAccountToUser = NFS_GetNISDomainUsers(F_strGen_NisDomain,F_strGen_NisServer)
  129. end if
  130. Elseif (mstrMethod = "GetUNIXGroups") Then
  131. If CInt(F_intGen_SelectedRadio) <> CONST_RADIO_USE_NISSERVER Then
  132. F_strNisAccountToGroup = NFS_ReadGroupsFromFile(F_strGen_GroupFile)
  133. else
  134. F_strNisAccountToGroup = NFS_GetNISDomainGroups(F_strGen_NisDomain,F_strGen_NisServer)
  135. end if
  136. End If
  137. OnPostBackPage = True
  138. End Function
  139. Public Function OnServeTabbedPropertyPage( _
  140. ByRef PageIn, _
  141. ByVal iTab, _
  142. ByVal bIsVisible, _
  143. ByRef EventArg)
  144. If ( iTab = idTab1 ) Then
  145. Call ServeCommonJavaScript()
  146. End If
  147. Select Case iTab
  148. Case idTab1
  149. Call ServeGenPage(PageIn, bIsVisible)
  150. Case idTab2
  151. Call ServeSMAPPage(PageIn, bIsVisible)
  152. Case idTab3
  153. Call ServeEXPUSERMAPPage(PageIn, bIsVisible)
  154. Case idTab4
  155. Call ServeEXPGROUPMAPPage(PageIn, bIsVisible)
  156. Case Else
  157. Call SA_TraceOut("TEMPLAGE_TABBED", _
  158. "OnServeTabbedPropertyPage unrecognized tab id: " _
  159. + CStr(iTab))
  160. End Select
  161. OnServeTabbedPropertyPage = True
  162. End Function
  163. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  164. OnSubmitPage = SetNFSGroupMapProperties()
  165. End Function
  166. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  167. OnClosePage = True
  168. End Function
  169. Function ServeCommonJavaScript()
  170. %>
  171. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  172. </script>
  173. <script language="JavaScript">
  174. var objForm = eval("document.frmTask");
  175. var intSelTab = objForm.TabSelected.value;
  176. function Init()
  177. {
  178. var strReturnurl=location.href;
  179. var ntempCnt=strReturnurl.indexOf("&ReturnURL=");
  180. var strAction=strReturnurl.substring(0,ntempCnt);
  181. objForm.action = strAction ;
  182. objForm.Method.value = "";
  183. // depending on the tab selected, call appropriate function
  184. switch(intSelTab)
  185. {
  186. case '0':
  187. // the general tab is selected
  188. GenInit();
  189. break;
  190. case '1':
  191. // the Simple Map tab is selected
  192. SMAPInit();
  193. break;
  194. case '2':
  195. // the Explicit User Map tab is selected
  196. EXPUSERMAPInit();
  197. break;
  198. case '3':
  199. // the Explicit Group Map tab is selected
  200. EXPGROUPMAPInit();
  201. break;
  202. }
  203. }
  204. function ValidatePage()
  205. {
  206. // depending on the tab selected, call appropriate validations
  207. switch(intSelTab)
  208. {
  209. // for general tab
  210. case '0':
  211. return GenValidatePage();
  212. break;
  213. // for Simple Map tab
  214. case '1':
  215. return SMAPValidatePage();
  216. break;
  217. // for Explicit User Map tab
  218. case '2':
  219. return EXPUSERMAPValidatePage();
  220. break;
  221. // for Explicit Group Map tab
  222. case '3':
  223. return EXPGROUPMAPValidatePage();
  224. break;
  225. }
  226. return true;
  227. }
  228. function SetData()
  229. {
  230. // call appropriate functions depending on tab selected
  231. switch(intSelTab)
  232. {
  233. // for general tab
  234. case '0':
  235. GenSetData();
  236. break;
  237. // for Simple Map tab
  238. case '1':
  239. SMAPSetData();
  240. break;
  241. // for Explicit User Map tab
  242. case '2':
  243. EXPUSERMAPSetData();
  244. break;
  245. // for Explicit Group Map tab
  246. case '3':
  247. EXPGROUPMAPSetData();
  248. break;
  249. }
  250. }
  251. </script>
  252. <%
  253. End Function
  254. '-------------------------------------------------------------------------
  255. ' Subroutine name: SetVariablesFromForm
  256. ' Description: Serves in getting the values from client,
  257. ' Uses Request.Form
  258. ' Input Variables: None
  259. ' Output Variables: None
  260. ' Returns: None
  261. ' Global Variables: None
  262. ' Calls functions from the different tabs(pages) to get the values
  263. ' from the form
  264. '-------------------------------------------------------------------------
  265. Sub SetVariablesFromForm
  266. Err.Clear
  267. On Error Resume Next
  268. 'get variables from the General tab page
  269. GetGenVariablesFromForm
  270. 'get variables from the Simple Map page
  271. GetSMAPVariablesFromForm
  272. 'get variables from the Explicit User Map page
  273. GetEXPUSERMAPVariablesFromForm
  274. 'get variables from the Explicit Group Map page
  275. GetEXPGROUPMAPVariablesFromForm
  276. End sub
  277. '-------------------------------------------------------------------------
  278. ' Function name: SetVariablesFromSystem
  279. ' Description: Serves in Getting the data from system
  280. ' Input Variables: None
  281. ' Output Variables: None
  282. ' Global Variables: None
  283. ' Returns: None
  284. ' Calls functions from different(pages) to get the initial values
  285. ' from the system. Incase of error, the functions call SA_ServeFailurePage
  286. ' and never returns
  287. '-------------------------------------------------------------------------
  288. Function SetVariablesFromSystem()
  289. Err.clear
  290. On Error Resume Next
  291. ' get values for the General tab
  292. GetGenVariablesFromSystem
  293. ' get values for the Simple Map tab
  294. GetSMAPVariablesFromSystem
  295. ' get values for the Explicit User Map tab
  296. GetEXPUSERMAPVariablesFromSystem
  297. ' get values for the Explicit Group Map tab
  298. GetEXPGROUPMAPVariablesFromSystem
  299. End Function
  300. '-------------------------------------------------------------------------
  301. ' Function name: SetNFSGroupMapProperties
  302. ' Description: Sets the NFS Maps properties
  303. ' Input Variables: None
  304. ' Output Variables: None
  305. ' Returns: True on Success, else False
  306. ' Global Variables: None
  307. ' Sets the properties of all the tabs. In case of error, sets the
  308. ' error message. The tab page in which the error occurred is displayed
  309. ' by setting the "mintTabSelected" appropriately.
  310. '-------------------------------------------------------------------------
  311. Function SetNFSGroupMapProperties
  312. Err.clear
  313. On Error Resume Next
  314. ' the return value initialized to false,
  315. ' changed to True if Successful
  316. SetNFSGroupMapProperties = False
  317. ' set the General properties
  318. If NOT GenUserGroupMappingProperties Then
  319. mintTabSelected = TABINDEX_GENTAB
  320. Exit Function
  321. End If
  322. ' set the Simple Map properties
  323. If NOT SetSMAPProp Then
  324. mintTabSelected = TABINDEX_SIMPLEMAPTAB
  325. Exit Function
  326. End If
  327. ' set the Explicit User Map properties
  328. If NOT UpdateUserMaps Then
  329. mintTabSelected =TABINDEX_USERMAPTAB
  330. Exit Function
  331. End If
  332. ' set the Explicit Group Map properties
  333. If NOT UpdateGroupMaps Then
  334. mintTabSelected =TABINDEX_GROUPMAPTAB
  335. Exit Function
  336. End If
  337. ' all the properties set, return True
  338. SetNFSGroupMapProperties = True
  339. End Function
  340. Function IsValidDomainUser(strFullName)
  341. On Error Resume Next
  342. Err.Clear
  343. Dim objLocation
  344. IsValidDomainUser = False
  345. set objLocation = GetObject("WinNT://" & Replace(strFullName,"\","/")&",user")
  346. If Err.number <> 0 Then
  347. SetErrMsg L_NFS_ERR_INVALID_DOMAIN_USER
  348. Err.Clear
  349. Exit Function
  350. End if
  351. IsValidDomainUser = True
  352. Set objLocation = Nothing
  353. End Function
  354. Function IsValidDomainGroup(strFullName)
  355. On Error Resume Next
  356. Err.Clear
  357. Dim objLocation
  358. IsValidDomainGroup = False
  359. set objLocation = GetObject("WinNT://" & Replace(strFullName,"\","/")&",group")
  360. If Err.number <> 0 Then
  361. SetErrMsg L_NFS_ERR_INVALID_DOMAIN_GROUP
  362. Err.Clear
  363. Exit Function
  364. End if
  365. IsValidDomainGroup = True
  366. Set objLocation = Nothing
  367. End Function
  368. %>