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.

686 lines
24 KiB

  1. <%
  2. '-------------------------------------------------------------------------
  3. ' nfsgeneral_prop.asp: display and update general properties of the
  4. ' NFS User and Group Mappings
  5. '
  6. ' Copyright (c) Microsoft Corporation. All rights reserved.
  7. '
  8. ' Date Description
  9. ' 25 Sep 2000 Creation Date
  10. '-------------------------------------------------------------------------
  11. Err.Clear
  12. On Error resume next
  13. '-------------------------------------------------------------------------
  14. 'Form Variables
  15. '-------------------------------------------------------------------------
  16. Dim F_strGen_NisDomain ' to store the NIS domain name
  17. Dim F_strGen_NisServer ' to store the NIS server name
  18. Dim F_intGen_RefreshHours ' to store the Refresh Interval Hours
  19. Dim F_intGen_RefreshMinutes ' to store the Refresh Interval Minutes
  20. Dim F_strGen_PasswdFile ' to store the password file
  21. Dim F_strGen_GroupFile ' to store the group file
  22. Dim F_intGen_SelectedRadio ' to store the value of the radio selected
  23. Dim F_intGen_RefreshInterval ' to store the Refresh Interval
  24. ' Hours + Minutes In Minutes to set in wmi
  25. Dim F_strUseNISServer_RadioStatus ' status of "Use Nis" radio
  26. Dim F_strUsePasswdGroupFiles_RadioStatus ' status of "Use files" radio
  27. '-------------------------------------------------------------------------
  28. 'Constants
  29. '-------------------------------------------------------------------------
  30. Const CONST_RADIO_CHECKED_STATUS = "CHECKED"
  31. Const CONST_RADIO_NOT_CHECKED_STATUS = ""
  32. Const CONST_RADIO_USE_NISSERVER = 1
  33. Const CONST_RADIO_USE_PASSWD_GROUPFILES = 0
  34. ' objects and wmi related constants
  35. Const WMI_SFUADMIN_NAMESPACE = "root\SFUAdmin"
  36. Const WMI_MAPPER_SETTINGS_CLASS = "Mapper_Settings"
  37. Const FILE_SYSTEM_OBJECT = "Scripting.Filesystemobject"
  38. %>
  39. <SCRIPT LANGUAGE="JavaScript">
  40. //<!--
  41. var JS_CONST_USE_NISSERVER = 1
  42. var JS_CONST_USE_FILES = 0
  43. // Set the initial form values
  44. function GenInit()
  45. {
  46. // get the selected radio value
  47. var intRadioSelected = document.frmTask.hdnintGen_UserGroupMap_radio.value;
  48. // enable or disable values depending on the radio selected
  49. setFormFieldsStatus(parseInt(intRadioSelected,10));
  50. }// end of GenInit()
  51. // validates the form values when the user clicks
  52. // on another tab(to go to diferent page) OR clicks OK(to set the values)
  53. // if any value is not valid, this displays error message and
  54. // remains in the same page
  55. function GenValidatePage()
  56. {
  57. // get the form handle into a variable
  58. var objGenForm = eval("document.frmTask");
  59. // accept the form values in variables to validate them
  60. var intHours = parseInt(objGenForm.txtGen_RefreshHours.value,10);
  61. var intMinutes = parseInt(objGenForm.txtGen_RefreshMinutes.value,10);
  62. var intRadioValue = parseInt(objGenForm.hdnintGen_UserGroupMap_radio.value,10);
  63. // minutes cannot be greater than 59
  64. if(intMinutes > 59)
  65. {
  66. DisplayErr("<%=Server.HTMLEncode(L_MINUTES_NOTVALID_ERRORMESSAGE)%>");
  67. selectFocus(objGenForm.txtGen_RefreshMinutes);
  68. return false;
  69. }
  70. // if both hours and minutes are null, display error
  71. // minumum value of refresh interval is 5 min
  72. if(isNaN(intHours) && isNaN(intMinutes))
  73. {
  74. DisplayErr("<%=Server.HTMLEncode(L_MINIMUM_INTERVAL_REQUIRED_ERRORMESSAGE)%>");
  75. selectFocus(objGenForm.txtGen_RefreshMinutes);
  76. return false;
  77. }
  78. // minumum value of refresh interval is 5 min
  79. if ((isNaN(intHours) || (intHours == 0)) && (intMinutes < 5))
  80. {
  81. DisplayErr("<%=Server.HTMLEncode(L_MINIMUM_INTERVAL_REQUIRED_ERRORMESSAGE)%>");
  82. selectFocus(objGenForm.txtGen_RefreshMinutes);
  83. return false;
  84. }
  85. // if PCNFS is selected, validate the file names
  86. if(intRadioValue == JS_CONST_USE_FILES)
  87. {
  88. var passwordFile = objGenForm.txtGen_PasswdFile.value;
  89. var groupFile = objGenForm.txtGen_GroupFile.value;
  90. // check if the file name is empty
  91. if(IsAllSpaces(passwordFile))
  92. {
  93. DisplayErr("<%=Server.HTMLEncode(L_PASSWORDFILENAME_EMPTY_ERRORMESSAGE)%>");
  94. selectFocus(objGenForm.txtGen_PasswdFile);
  95. return false;
  96. }
  97. else
  98. {
  99. // the password file name is not empty
  100. // Verify if the file name is valid
  101. if(!isValidFileName(passwordFile))
  102. {
  103. DisplayErr("<%=Server.HTMLEncode(L_PASSWORDFILENAME_INVALID_ERRORMESSAGE)%>");
  104. selectFocus(objGenForm.txtGen_PasswdFile);
  105. return false;
  106. }
  107. }
  108. // check if the group file name is empty
  109. if(IsAllSpaces(groupFile))
  110. {
  111. DisplayErr("<%=Server.HTMLEncode(L_GROUPFILENAME_EMPTY_ERRORMESSAGE)%>");
  112. selectFocus(objGenForm.txtGen_GroupFile);
  113. return false;
  114. }
  115. else
  116. {
  117. // the group file name is not empty
  118. // verify if the file name is valid
  119. if(!isValidFileName(groupFile))
  120. {
  121. DisplayErr("<%=Server.HTMLEncode(L_GROUPFILENAME_INVALID_ERRORMESSAGE)%>");
  122. selectFocus(objGenForm.txtGen_GroupFile);
  123. return false;
  124. }
  125. }
  126. }
  127. // if NIS domain is given, validate if the fields are empty
  128. if(intRadioValue == JS_CONST_USE_NISSERVER)
  129. {
  130. var strNISDomain = objGenForm.txtGen_NISDomain.value;
  131. // the domain name must not be empty
  132. if(IsAllSpaces(strNISDomain))
  133. {
  134. DisplayErr("<%=Server.HTMLEncode(L_NISDOMAIN_EMPTY_ERRORMESSAGE)%>");
  135. selectFocus(objGenForm.txtGen_NISDomain);
  136. return false;
  137. }
  138. // the nis server value is optional. No validations required for it.
  139. }
  140. // update all the hidden variables as user might have clicked on a
  141. // different tab or clicked OK
  142. UpdateGenHiddenVaribles();
  143. // all values are valid. Hidden values are also updated. Return True
  144. return true;
  145. }// end of GenValidatePage()
  146. // dummy function for framework
  147. function GenSetData()
  148. {
  149. // all the hidden variables are set in the
  150. // GenValidatePage() function. No data to set here.
  151. } // end of GenSetData()
  152. // to update the hidden variables
  153. function UpdateGenHiddenVaribles()
  154. {
  155. // get the form handle into a variable
  156. var objGenForm = eval("document.frmTask");
  157. // take the values to variables for easy access
  158. var objRadio = objGenForm.radGen_UserGroupMap;
  159. var intHours = parseInt(objGenForm.txtGen_RefreshHours.value,10);
  160. var intMinutes = parseInt(objGenForm.txtGen_RefreshMinutes.value,10);
  161. // if hours is blank, assign 0
  162. if (isNaN(intHours))
  163. {
  164. intHours = 0;
  165. }
  166. // if minutes is blank, assign 0
  167. if (isNaN(intMinutes))
  168. {
  169. intMinutes = 0;
  170. }
  171. // populate the hidden fields
  172. // assign the radio button value
  173. objGenForm.hdnintGen_UserGroupMap_radio.value = getRadioButtonValue(objRadio);
  174. // update the nis domain and server values
  175. objGenForm.hdntxtGen_NISDomain.value = objGenForm.txtGen_NISDomain.value.toLowerCase();
  176. objGenForm.hdntxtGen_NISServer.value = objGenForm.txtGen_NISServer.value.toLowerCase();
  177. // assign the refresh interval converting it into minutes
  178. objGenForm.hdntxtGen_RefreshInterval.value = ((intHours * 60)+ intMinutes);
  179. // update the file names
  180. objGenForm.hdntxtGen_PasswdFile.value = objGenForm.txtGen_PasswdFile.value;
  181. objGenForm.hdntxtGen_GroupFile.value = objGenForm.txtGen_GroupFile.value;
  182. }// end of UpdateGenHiddenVaribles()
  183. // enable or disable the form fields
  184. function setFormFieldsStatus(intRadioValue)
  185. {
  186. // take the form handle into a variable
  187. var objGenForm = eval("document.frmTask");
  188. // update the hidden form field
  189. objGenForm.hdnintGen_UserGroupMap_radio.value = intRadioValue;
  190. // if the nis domain radio is selected
  191. if(intRadioValue == JS_CONST_USE_NISSERVER)
  192. {
  193. // disable the password and group files
  194. objGenForm.txtGen_PasswdFile.disabled = true;
  195. objGenForm.txtGen_GroupFile.disabled = true;
  196. // enable the nis domain and server
  197. objGenForm.txtGen_NISDomain.disabled = false;
  198. objGenForm.txtGen_NISServer.disabled = false;
  199. objGenForm.txtGen_RefreshHours.disabled = false;
  200. objGenForm.txtGen_RefreshMinutes.disabled = false;
  201. }
  202. else
  203. {
  204. // if PCNFS is selected
  205. if(intRadioValue == JS_CONST_USE_FILES)
  206. {
  207. // enable the password and group files
  208. objGenForm.txtGen_PasswdFile.disabled = false;
  209. objGenForm.txtGen_GroupFile.disabled = false;
  210. // disable the nis domain and server
  211. objGenForm.txtGen_NISDomain.disabled = true;
  212. objGenForm.txtGen_NISServer.disabled = true;
  213. objGenForm.txtGen_RefreshHours.disabled = true;
  214. objGenForm.txtGen_RefreshMinutes.disabled = true;
  215. }
  216. else
  217. {
  218. // if either radio is not selected, disable all form fields
  219. // this case must not arise
  220. objGenForm.txtGen_NISDomain.disabled = true;
  221. objGenForm.txtGen_NISServer.disabled = true;
  222. objGenForm.txtGen_PasswdFile.disabled = true;
  223. objGenForm.txtGen_GroupFile.disabled = true;
  224. objGenForm.txtGen_RefreshHours.disabled = true;
  225. objGenForm.txtGen_RefreshMinutes.disabled = true;
  226. DisableOK();
  227. } // end of if(intRadioValue == JS_CONST_USE_FILES)
  228. } // end of if(intRadioValue == JS_CONST_USE_NISSERVER)
  229. } // end of setFormFieldsStatus(intRadioValue)
  230. //-->
  231. </SCRIPT>
  232. <%
  233. '-------------------------------------------------------------------------
  234. ' Function name: ServeGenPage(ByRef PageIn, ByVal bIsVisible)
  235. ' Description: Serves in displaying the page Header, Middle and
  236. ' Footer Parts (the User Interface)
  237. ' Input Variables: PageIn
  238. ' bIsVisible - the tab page be displayed?
  239. ' Output Variables: None
  240. ' Returns: None
  241. ' Global Variables: L_(*) - Localization content
  242. ' F_(*) - Form Variables
  243. '-------------------------------------------------------------------------
  244. Function ServeGenPage(ByRef PageIn, ByVal bIsVisible)
  245. On Error Resume Next
  246. Err.Clear
  247. If bIsVisible Then
  248. %>
  249. <TABLE WIDTH=400 VALIGN=middle ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=1>
  250. <TR>
  251. <TD class="TasksBody" align="right" width="5%">
  252. <INPUT type="radio" Class="FormField" value="1" name="radGen_UserGroupMap" <%=F_strUseNISServer_RadioStatus%> onClick="JavaScript:ClearErr();setFormFieldsStatus(parseInt(this.value,10));">&nbsp;
  253. </TD>
  254. <TD class="TasksBody" width="20%">
  255. <%=L_USE_NIS_SERVER_LABEL_TEXT%>
  256. </TD>
  257. <TD class="TasksBody" align="left">
  258. &nbsp;
  259. <!-- TD left empty to complete the table.
  260. The width is mentioned only in the above two TD's.
  261. As width is mentioned, colspan = 2 is not used above.
  262. -->
  263. </TD>
  264. </TR>
  265. <TR>
  266. <TD class="TasksBody" align="right">
  267. &nbsp;
  268. <!-- TD left empty to maintain the gap left by the radio buttons -->
  269. </TD>
  270. <TD class="TasksBody">
  271. <%=L_NIS_DOMAIN_LABEL_TEXT%>
  272. </TD>
  273. <TD class="TasksBody" align="left">
  274. <INPUT type="text" Class="FormField" name="txtGen_NISDomain" size="25" value="<%=Server.HTMLEncode(F_strGen_NisDomain)%>" OnKeyDown="JavaScript:ClearErr();">
  275. </TD>
  276. </TR>
  277. <TR>
  278. <TD class="TasksBody" align="right">
  279. &nbsp;
  280. <!-- TD left empty to maintain the gap left by the radio buttons -->
  281. </TD>
  282. <TD class="TasksBody" nowrap>
  283. <%=L_NIS_SERVER_LABEL_TEXT%>
  284. </TD>
  285. <TD class="TasksBody" align="left">
  286. <INPUT type="text" Class="FormField" name="txtGen_NISServer" size="25" value="<%=Server.HTMLEncode(F_strGen_NisServer)%>" OnKeyDown="JavaScript:ClearErr();">
  287. </TD>
  288. </TR>
  289. <TR>
  290. <TD class="TasksBody" align="right">
  291. &nbsp;
  292. <!-- TD left empty to maintain the gap left by the radio buttons -->
  293. </TD>
  294. <TD class="TasksBody" colspan=2>
  295. <%=L_REFRESH_INTERVAL_NOTE_TEXT%>
  296. </TD>
  297. </TR>
  298. <TR>
  299. <TD class="TasksBody" align="right">
  300. &nbsp;
  301. <!-- TD left empty to maintain the gap left by the radio buttons -->
  302. </TD>
  303. <TD class="TasksBody" colspan=2>
  304. <INPUT type="text" Class="FormField" name="txtGen_RefreshHours" size="4" maxlength=4 OnKeyPress=checkKeyforNumbers(this) value="<%=F_intGen_RefreshHours%>" OnKeyDown="JavaScript:ClearErr();">&nbsp;<%=L_NFS_HOURS_TEXT%>
  305. &nbsp;&nbsp;&nbsp;&nbsp;
  306. <INPUT type=text Class="FormField" name="txtGen_RefreshMinutes" size="4" maxlength=2 OnKeyPress=checkKeyforNumbers(this) value="<%=F_intGen_RefreshMinutes%>" OnKeyDown="JavaScript:ClearErr();">&nbsp;<%=L_NFS_MINUTES_TEXT%>
  307. </TD>
  308. </TR>
  309. <!-- SECOND RADIO BEGINS -->
  310. <TR>
  311. <TD class="TasksBody" align="right">
  312. <INPUT type="radio" Class="FormField" value="0" name="radGen_UserGroupMap" <%=F_strUsePasswdGroupFiles_RadioStatus%> onClick="JavaScript:ClearErr();setFormFieldsStatus(parseInt(this.value,10));">&nbsp;
  313. </TD>
  314. <TD class="TasksBody" colspan=2>
  315. <%=L_USE_PASSWD_GROUP_FILES_LABEL_TEXT%>
  316. </TD>
  317. </TR>
  318. <TR>
  319. <TD class="TasksBody" align="right">
  320. &nbsp;
  321. <!-- TD left empty to maintain the gap left by the radio buttons -->
  322. </TD>
  323. <TD class="TasksBody">
  324. <%=L_PASSWD_FILE_LABEL_TEXT%>
  325. </TD>
  326. <TD class="TasksBody" align="left">
  327. <INPUT type="text" Class="FormField" name="txtGen_PasswdFile" size="25" value="<%=Server.HTMLEncode(F_strGen_PasswdFile)%>" OnKeyDown="JavaScript:ClearErr();">
  328. </TD>
  329. </TR>
  330. <TR>
  331. <TD class="TasksBody" align="right">
  332. &nbsp;
  333. <!-- TD left empty to maintain the gap left by the radio buttons -->
  334. </TD>
  335. <TD class="TasksBody">
  336. <%=L_GROUP_FILE_LABEL_TEXT%>
  337. </TD>
  338. <TD class="TasksBody" align="left">
  339. <INPUT type="text" Class="FormField" name="txtGen_GroupFile" size="25" value="<%=Server.HTMLEncode(F_strGen_GroupFile)%>" OnKeyDown="JavaScript:ClearErr();">
  340. </TD>
  341. </TR>
  342. </TABLE>
  343. <%
  344. End If
  345. ServeGenFooter()
  346. ServeGenPage = gc_ERR_SUCCESS
  347. End Function
  348. '-------------------------------------------------------------------------
  349. ' SubRoutine name: GetGenVariablesFromForm
  350. ' Description: Serves in getting the values from previous form
  351. ' Input Variables: None
  352. ' Output Variables: None
  353. ' Returns: None
  354. ' Global Variables: F_(*) - Form variables
  355. '-------------------------------------------------------------------------
  356. Function GetGenVariablesFromForm
  357. Err.Clear
  358. On Error Resume Next
  359. ' get all the form values to variables
  360. F_intGen_SelectedRadio = Request.Form("hdnintGen_UserGroupMap_radio")
  361. F_strGen_NisDomain = Request.Form("hdntxtGen_NISDomain")
  362. F_strGen_NisServer = Request.Form ("hdntxtGen_NISServer")
  363. F_strGen_PasswdFile = Request.Form("hdntxtGen_PasswdFile")
  364. F_strGen_GroupFile = Request.Form("hdntxtGen_GroupFile")
  365. F_intGen_RefreshInterval = CLng(Request.Form("hdntxtGen_RefreshInterval"))
  366. ' if the NIS domain is selected, Select that radio status accordingly
  367. ' (radio status = "Checked" or "")
  368. If CInt(F_intGen_SelectedRadio) = CONST_RADIO_USE_NISSERVER Then
  369. F_strUseNISServer_RadioStatus = CONST_RADIO_CHECKED_STATUS
  370. F_strUsePasswdGroupFiles_RadioStatus = CONST_RADIO_NOT_CHECKED_STATUS
  371. Else
  372. F_strUseNISServer_RadioStatus = CONST_RADIO_NOT_CHECKED_STATUS
  373. F_strUsePasswdGroupFiles_RadioStatus = CONST_RADIO_CHECKED_STATUS
  374. End If
  375. ' split the refresh interval into Hours and Minutes
  376. If F_intGen_RefreshInterval > 59 Then
  377. F_intGen_RefreshHours = Int(F_intGen_RefreshInterval/60)
  378. F_intGen_RefreshMinutes = (F_intGen_RefreshInterval Mod 60)
  379. Else
  380. F_intGen_RefreshHours = 0
  381. F_intGen_RefreshMinutes = F_intGen_RefreshInterval
  382. End If
  383. End Function
  384. '-------------------------------------------------------------------------
  385. ' SubRoutine name: GetGenVariablesFromSystem
  386. ' Description: Serves in getting the values from system
  387. ' Input Variables: None
  388. ' Output Variables: None
  389. ' Returns: None
  390. ' Global Variables: F_(*) - Form variables
  391. '-------------------------------------------------------------------------
  392. Function GetGenVariablesFromSystem
  393. Err.Clear
  394. On Error Resume Next
  395. Dim objWMIService ' the wmi service object
  396. Dim objInstance ' the instance object
  397. ' No radio button is selected initially
  398. F_intGen_SelectedRadio = -1
  399. F_strUsePasswdGroupFiles_RadioStatus = CONST_RADIO_NOT_CHECKED_STATUS
  400. F_strUseNISServer_RadioStatus = CONST_RADIO_NOT_CHECKED_STATUS
  401. ' get the wmi connection (service object) for the SFUAdmin namespace
  402. Set objWMIService = GetWMIConnection(WMI_SFUADMIN_NAMESPACE)
  403. ' get the object from the wmi
  404. Set objInstance = objWMIService.Get(WMI_SFU_OBJECT_QUERY)
  405. If Err.number <> 0 Then
  406. SA_ServeFailurePage L_READFROM_WMI_FAILED_ERRORMESSAGE
  407. End If
  408. ' assign the values to form variables
  409. F_strGen_NisDomain = objInstance.NisDomain
  410. F_strGen_NisServer = objInstance.NisServer
  411. F_strGen_PasswdFile = objInstance.PasswdFileName
  412. F_strGen_GroupFile = objInstance.GroupFileName
  413. F_intGen_SelectedRadio = CInt(objInstance.ServerType)
  414. ' ServerType = 1 --- use Nis Server
  415. ' ServerType = 0 --- PCNFS.use files
  416. ' select and Check the radio button accordingly
  417. If F_intGen_SelectedRadio = CONST_RADIO_USE_NISSERVER Then
  418. F_strUseNISServer_RadioStatus = CONST_RADIO_CHECKED_STATUS
  419. ElseIf CInt(F_intGen_SelectedRadio) = CONST_RADIO_USE_PASSWD_GROUPFILES Then
  420. F_strUsePasswdGroupFiles_RadioStatus = CONST_RADIO_CHECKED_STATUS
  421. Else
  422. ' nothing will be selected.
  423. End If
  424. ' get the refresh interval. This will be in minutes
  425. F_intGen_RefreshInterval = CLng(objInstance.RefreshInterval)
  426. ' split the refresh interval into hours and minutes for display
  427. If F_intGen_RefreshInterval > 59 Then
  428. F_intGen_RefreshHours = Int(F_intGen_RefreshInterval/60)
  429. F_intGen_RefreshMinutes = (F_intGen_RefreshInterval Mod 60)
  430. Else
  431. F_intGen_RefreshHours = 0
  432. F_intGen_RefreshMinutes = F_intGen_RefreshInterval
  433. End If
  434. ' clean up
  435. Set objWMIService = Nothing
  436. Set objInstance = Nothing
  437. End Function
  438. '-------------------------------------------------------------------------
  439. ' Function name: GenUserGroupMappingProperties
  440. ' Description: To set the general properties
  441. ' Input Variables: None
  442. ' Output Variables: None
  443. ' Returns: True on sucess, False on error (and error msg
  444. ' will be set by SetErrMsg)
  445. ' Global Variables: F_(*) - form values
  446. '-------------------------------------------------------------------------
  447. Function GenUserGroupMappingProperties()
  448. Err.Clear
  449. On Error Resume Next
  450. Dim objWMIService ' the wmi service object
  451. Dim objInstance ' the instance object
  452. Dim LastError ' to store the last error returned by activex object
  453. ' if the files are given, check if they are existing
  454. If CInt(F_intGen_SelectedRadio) = CONST_RADIO_USE_PASSWD_GROUPFILES Then
  455. If NOT IsFileExisting(F_strGen_PasswdFile) Then
  456. GenUserGroupMappingProperties = False
  457. Exit Function
  458. End If
  459. If NOT IsFileExisting(F_strGen_GroupFile) Then
  460. GenUserGroupMappingProperties = False
  461. Exit Function
  462. End If
  463. End If
  464. ' if the NIS domain is given, see if it is valid
  465. If CInt(F_intGen_SelectedRadio) = CONST_RADIO_USE_NISSERVER Then
  466. ' if the nis domain is not valid, display error message
  467. If NOT (isValidNISServer(F_strGen_NisDomain, F_strGen_NisServer,LastError)) Then
  468. SetErrMsg L_INVALID_NISDOMAIN_OR_SERVER_ERRORMESSAGE
  469. GenUserGroupMappingProperties = False
  470. Exit Function
  471. End If
  472. End If
  473. ' get the wmi connection (service object) for the SFUAdmin namespace
  474. Set objWMIService = GetWMIConnection(WMI_SFUADMIN_NAMESPACE)
  475. ' get the object from the wmi
  476. Set objInstance = objWMIService.Get(WMI_SFU_OBJECT_QUERY)
  477. If Err.number <> 0 Then
  478. SetErrMsg L_READFROM_WMI_FAILED_ERRORMESSAGE
  479. GenUserGroupMappingProperties = False
  480. Exit Function
  481. End If
  482. ' set the property in the wmi
  483. objInstance.ServerType = CInt(F_intGen_SelectedRadio)
  484. objInstance.RefreshInterval = CLng(F_intGen_RefreshInterval)
  485. ' set values of nis domain/ files accordingly
  486. If CInt(F_intGen_SelectedRadio) = CONST_RADIO_USE_NISSERVER Then
  487. objInstance.NisDomain = F_strGen_NisDomain
  488. objInstance.NisServer = F_strGen_NisServer
  489. ElseIf CInt(F_intGen_SelectedRadio) = CONST_RADIO_USE_PASSWD_GROUPFILES Then
  490. objInstance.PasswdFileName = F_strGen_PasswdFile
  491. objInstance.GroupFileName = F_strGen_GroupFile
  492. Else
  493. ' this will not occur !!!
  494. End If
  495. ' save the changes
  496. objInstance.Put_
  497. If Err.number Then
  498. SetErrMsg L_WRITETO_WMI_FAILED_ERRORMESSAGE
  499. GenUserGroupMappingProperties = False
  500. Else
  501. GenUserGroupMappingProperties = True
  502. End If
  503. ' clean up
  504. Set objWMIService = Nothing
  505. Set objInstance = Nothing
  506. End function
  507. '-------------------------------------------------------------------------
  508. ' Function name: IsFileExisting
  509. ' Description: To check if the input file is existing
  510. ' Input Variables: inFile - file name(along with path) to be verified
  511. ' Output Variables: None
  512. ' Returns: True if file exits, else False
  513. ' Global Variables: None
  514. ' Uses the file system object to verify the existence of the file
  515. '-------------------------------------------------------------------------
  516. Function IsFileExisting(inFile)
  517. Err.Clear
  518. On Error Resume Next
  519. Dim objFSO ' the file system object
  520. ' create the file system object
  521. Set objFSO = CreateObject(FILE_SYSTEM_OBJECT)
  522. If Err.number <> 0 Then
  523. SetErrMsg L_FILESYSYTEMOBJECT_NOT_CREATED_ERRORMESSAGE
  524. IsFileExisting = False
  525. Exit Function
  526. End If
  527. ' check if file exists
  528. If objFSO.FileExists(inFile) Then
  529. IsFileExisting = True
  530. Else
  531. SetErrMsg L_FILE_DOES_NOT_EXIST_ERRORMESSAGE & " " & inFile
  532. IsFileExisting = False
  533. Exit Function
  534. End If
  535. ' clean up
  536. Set objFSO = Nothing
  537. End Function
  538. '-------------------------------------------------------------------------
  539. ' Function name: isValidNISServer
  540. ' Description: Validates NISServer Name
  541. ' Input Variables: strNISDomainName - domain to be verified
  542. ' strNISServer - server to be verified(can be empty)
  543. ' Output Variables: LastError - the error value
  544. ' Returns: True if valid, else False
  545. ' Global Variables: None
  546. ' Uses activex object to vvalidate the nis domain/server
  547. '-------------------------------------------------------------------------
  548. Function isValidNISServer(strNISDomainName, strNISServer, LastError)
  549. On Error Resume Next
  550. Err.Clear
  551. Dim objNISMapper ' the activex object
  552. Dim intResult ' to store the return value from the method
  553. 'Get the instance of the mapper Class
  554. Set objNISMapper = Server.CreateObject("MapManager.1")
  555. If Err.number <> 0 Then
  556. SA_ServeFailurePage L_MAPPEROBJECT_NOT_CREATED_ERRORMESSAGE
  557. End if
  558. ' Valid the Empty user and check whether it results in Invalid user
  559. ' error or success.
  560. intResult = objNISMapper.IsValidNisUser(strNISDomainName,strNISServer," ")
  561. ' if the NIS Server/domain couldn't be contacted/doesnt exists.
  562. ' Return false
  563. If cstr(objNISMapper.lastError) <> "0" and cstr(objNISMapper.lastError) <> "2202" then
  564. LastError = cstr(objNISMapper.lastError)
  565. isValidNISServer = False
  566. Exit function
  567. End if
  568. ' clean up
  569. Set objNISMapper = Nothing
  570. ' return True
  571. isValidNISServer = True
  572. End Function
  573. '-------------------------------------------------------------------------
  574. ' Function name: ServeGenFooter
  575. ' Description: Serves the hidden form variables
  576. ' Input Variables: None
  577. ' Output Variables: None
  578. ' Returns: None
  579. ' Global Variables: F_(*) - form values
  580. ' This function serves the hidden variables of the form.
  581. ' These are used to get the form values when the form is submitted.
  582. '-------------------------------------------------------------------------
  583. Function ServeGenFooter
  584. Err.Clear
  585. On Error Resume Next
  586. %>
  587. <input type="hidden" name="hdnintGen_UserGroupMap_radio" value="<%=F_intGen_SelectedRadio%>">
  588. <input type="hidden" name="hdntxtGen_NISDomain" value="<%=F_strGen_NisDomain%>">
  589. <input type="hidden" name="hdntxtGen_NISServer" value="<%=F_strGen_NisServer%>">
  590. <input type="hidden" name="hdntxtGen_RefreshInterval" value="<%=F_intGen_RefreshInterval%>">
  591. <input type="hidden" name="hdntxtGen_PasswdFile" value="<%=F_strGen_PasswdFile%>">
  592. <input type="hidden" name="hdntxtGen_GroupFile" value="<%=F_strGen_GroupFile%>">
  593. <%
  594. End Function
  595. %>