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.

800 lines
24 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. ' Response.Buffer = True
  5. '-------------------------------------------------------------------------
  6. ' site_modify.asp: Serves in creating a new site
  7. '
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Date Description
  11. ' 14-Jan-2001 Creation Date
  12. ' 25-Jan-2001 Last Modified Date
  13. '-------------------------------------------------------------------------
  14. %>
  15. <!-- #include virtual="/admin/inc_framework.asp" -->
  16. <!-- #include file="resources.asp" -->
  17. <!-- #include file="inc_wsa.asp" -->
  18. <!-- #include file="Sitemodify_prop.asp" -->
  19. <%
  20. Err.Clear
  21. 'On Error Resume Next
  22. '-------------------------------------------------------------------------
  23. ' Global Constants and Variables
  24. '-------------------------------------------------------------------------
  25. Dim G_strDirRoot 'to hold Domainname value
  26. Dim G_strSysName 'to hold system name
  27. Dim G_strSiteNum 'to hold site name
  28. Dim G_AnonUserName 'to hold anonymouse username created by IIS
  29. Dim rc 'to hold return count value
  30. Dim page 'to hold page object
  31. Dim idTabGeneral 'to hold Ist tab value
  32. Dim idTabSiteID 'to hold IInd tab value
  33. Dim idTabAppSetting 'to hold Vth tab value
  34. '=========================================================================
  35. ' Entry point
  36. '=========================================================================
  37. ' Set username value
  38. G_AnonUserName = GetIISAnonUsername()
  39. ' Create a Tabbed Property Page
  40. rc = SA_CreatePage( L_TASKTITLE_TEXT, "", PT_TABBED, page )
  41. ' Add five tabs
  42. rc = SA_AddTabPage( page, L_GENERAL_TEXT, idTabGeneral)
  43. rc = SA_AddTabPage( page, L_SITEIDENTITY_TEXT, idTabSiteID)
  44. rc = SA_AddTabPage( page, L_APPLICATIONSETTINGS_TEXT, idTabAppSetting)
  45. ' Show the page
  46. rc = SA_ShowPage( page )
  47. '=========================================================================
  48. ' Web Framework Event Handlers
  49. '=========================================================================
  50. '-------------------------------------------------------------------------
  51. ' Function: OnInitPage
  52. '
  53. ' Synopsis: Called to signal first time processing for this page. Use
  54. ' this method to do first time initialization tasks.
  55. '
  56. ' Returns: TRUE to indicate initialization was successful. FALSE to
  57. ' indicate errors. Returning FALSE will cause the page to be
  58. ' abandoned.
  59. '
  60. '-------------------------------------------------------------------------
  61. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  62. Err.clear
  63. on Error Resume Next
  64. G_strSiteNum = Request.QueryString("PKey")
  65. SetFormVarsFromSystem()
  66. OnInitPage = TRUE
  67. End Function
  68. '-------------------------------------------------------------------------
  69. ' Function: OnPostBackPage
  70. '
  71. ' Synopsis: Called to signal that the page has been posted-back. A post-
  72. ' back occurs in tabbed property pages and wizards as the user
  73. ' navigates through pages. It is differentiated from a Submit
  74. ' or Close operationin that the user is still working with the
  75. ' page.
  76. '
  77. ' The PostBack event should be used to save the state of page.
  78. '
  79. ' Returns: TRUE to indicate initialization was successful. FALSE to
  80. ' indicate errors. Returning FALSE will cause the page to be
  81. ' abandoned.
  82. '-------------------------------------------------------------------------
  83. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  84. Err.clear
  85. on Error Resume Next
  86. 'get variables from form
  87. call SetGenFormVariables()
  88. call SetSiteIdentitiesFormVariables()
  89. call SetApplnSettingsFormVariables()
  90. Call SA_TRACEOUT("OnPostBackPage","OnPostBackPage called")
  91. OnPostBackPage = TRUE
  92. End Function
  93. '--------------------------------------------------------------------------
  94. ' Function: OnServeTabbedPropertyPage
  95. '
  96. ' Synopsis: Called when the page needs to be served. Use this method to
  97. ' serve content.
  98. '
  99. ' Returns: TRUE to indicate not problems occured. FALSE to indicate errors.
  100. ' Returning FALSE will cause the page to be abandoned.
  101. '
  102. '--------------------------------------------------------------------------
  103. Public Function OnServeTabbedPropertyPage(ByRef PageIn, _
  104. ByVal iTab, _
  105. ByVal bIsVisible, _
  106. ByRef EventArg)
  107. ' Emit Web Framework required functions
  108. If ( iTab = idTabGeneral) Then
  109. Call ServeCommonJavaScript()
  110. End If
  111. ' Emit content for the requested tab
  112. Select Case iTab
  113. Case idTabGeneral
  114. Call ServeTabGeneral(PageIn, bIsVisible)
  115. Case idTabSiteID
  116. Call ServeTabSiteID(PageIn, bIsVisible)
  117. Case idTabAppSetting
  118. Call ServeTabAppSetting(PageIn, bIsVisible)
  119. Case Else
  120. SA_TraceOut "TEMPLAGE_TABBED", _
  121. "OnServeTabbedPropertyPage unrecognized tab id: " + _
  122. CStr(iTab)
  123. End Select
  124. OnServeTabbedPropertyPage = TRUE
  125. End Function
  126. '-------------------------------------------------------------------------
  127. ' Function: OnSubmitPage
  128. '
  129. ' Synopsis: Called when the page has been submitted for processing. Use
  130. ' this method to process the submit request.
  131. '
  132. ' Returns: TRUE if the submit was successful, FALSE to indicate error(s).
  133. ' Returning FALSE will cause the page to be served again using
  134. ' a call to OnServePropertyPage.
  135. '
  136. '-------------------------------------------------------------------------
  137. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  138. OnSubmitPage = ModifySite()
  139. End Function
  140. '-------------------------------------------------------------------------
  141. ' Function: OnClosePage
  142. '
  143. ' Synopsis: Called when the page is about to be closed. Use this method
  144. ' to perform clean-up processing.
  145. '
  146. ' Returns: TRUE to allow close, FALSE to prevent close. Returning FALSE
  147. ' will result in a call to OnServePropertyPage.
  148. '
  149. '-------------------------------------------------------------------------
  150. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  151. OnClosePage = TRUE
  152. End Function
  153. '=========================================================================
  154. ' Private Functions
  155. '=========================================================================
  156. '-------------------------------------------------------------------------
  157. 'Function name :ServeTabGeneral
  158. 'Description :Serves General tab
  159. 'Input Variables :PageIn, bIsVisible
  160. 'Output Variables :None
  161. 'Returns :Success(Return value)
  162. 'Global Variables :None
  163. '-------------------------------------------------------------------------
  164. Function ServeTabGeneral(ByRef PageIn, ByVal bIsVisible)
  165. If ( bIsVisible ) Then
  166. call GeneralViewTab()
  167. Else
  168. 'update hidden variables
  169. call GeneralHiddenTab()
  170. End If
  171. ServeTabGeneral = gc_ERR_SUCCESS
  172. End Function
  173. '-------------------------------------------------------------------------
  174. 'Function name :ServeTabSiteID
  175. 'Description :Serves the Site identities tab
  176. 'Input Variables :PageIn, bIsVisible
  177. 'Output Variables :None
  178. 'Returns :Success(Return value)
  179. 'Global Variables :None
  180. '-------------------------------------------------------------------------
  181. Function ServeTabSiteID(ByRef PageIn, ByVal bIsVisible)
  182. If ( bIsVisible ) Then
  183. call SiteIdentitiesViewTab()
  184. Else
  185. 'update hidden variables
  186. call SiteIdentitiesHiddenTab()
  187. End If
  188. ServeTabSiteID = gc_ERR_SUCCESS
  189. End Function
  190. '-------------------------------------------------------------------------
  191. 'Function name :ServeTabAppSetting
  192. 'Description :Serve the Application Settings tab
  193. 'Input Variables :PageIn, bIsVisible
  194. 'Output Variables :None
  195. 'Returns :Success(Return value)
  196. 'Global Variables :None
  197. '-------------------------------------------------------------------------
  198. Function ServeTabAppSetting(ByRef PageIn, ByVal bIsVisible)
  199. If ( bIsVisible ) Then
  200. call ApplicationSettingsViewTab()
  201. Else
  202. 'update hidden variables
  203. call ApplicationSettingsHiddenTab()
  204. end if
  205. ServeTabAppSetting = gc_ERR_SUCCESS
  206. End Function
  207. '-------------------------------------------------------------------------
  208. ' Function: ServeCommonJavaScript
  209. '
  210. ' Synopsis: Common javascript functions that are required by the Web
  211. ' Framework.
  212. '
  213. '------------------------------------------------------------------------
  214. Function ServeCommonJavaScript()
  215. Err.clear
  216. on Error Resume Next
  217. %>
  218. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  219. </script>
  220. <script language="JavaScript">
  221. //
  222. // Microsoft Server Appliance Web Framework Support Functions
  223. // Copyright (c) Microsoft Corporation. All rights reserved.
  224. //
  225. // Init Function
  226. // -----------
  227. // This function is called by the Property Page web framework to
  228. // allow the page to perform first time initialization.
  229. //
  230. // This function must be included or a javascript runtime error will
  231. // occur.
  232. function Init()
  233. {
  234. //Get the selected tab
  235. var temp = top.main.document.forms['frmTask'].TabSelected.value;
  236. switch(temp)
  237. {
  238. //for General prop
  239. case '0':
  240. GenInit();
  241. break;
  242. //for Site prop
  243. case '1':
  244. SiteInit();
  245. break;
  246. //for Appl prop
  247. case '2':
  248. ApplInit();
  249. break;
  250. }
  251. }
  252. // ValidatePage Function
  253. // ------------------
  254. // This function is called by the Property Page framework as part of
  255. // the submit processing. Use this function to validate user input.
  256. // Returning false will cause the submit to abort.
  257. //
  258. // This function must be included or a javascript runtime error will
  259. // occur.
  260. // Returns: True if the page is OK, false if error(s) exist.
  261. function ValidatePage()
  262. {
  263. //Get the selected tab
  264. var temp = top.main.document.forms['frmTask'].TabSelected.value;
  265. switch(temp)
  266. {
  267. //for general prop
  268. case '0':
  269. return GenValidatePage();
  270. break;
  271. //for Site prop
  272. case '1':
  273. return SiteValidatePage();
  274. break;
  275. //for Appl prop
  276. case '2':
  277. return ApplValidatePage();
  278. break;
  279. }
  280. }
  281. // SetData Function
  282. // --------------
  283. // This function is called by the Property Page framework and is called
  284. // only if ValidatePage returned a success (true) code. Typically you
  285. // would modify hidden form fields at this point.
  286. //
  287. // This function must be included or a javascript runtime error will
  288. // occur.
  289. function SetData()
  290. {
  291. //Get the selected tab
  292. var temp = top.main.document.forms['frmTask'].TabSelected.value;
  293. switch(temp)
  294. {
  295. //for general prop
  296. case '0':
  297. GenSetData();
  298. break;
  299. //for Site prop
  300. case '1':
  301. SiteSetData();
  302. break;
  303. //for Appl prop
  304. case '2':
  305. ApplSetData();
  306. break;
  307. }
  308. }
  309. </script>
  310. <%
  311. End Function
  312. '----------------------------------------------------------------------------
  313. 'Function name :ModifySite
  314. 'Description :Serves in Modifying the Site
  315. 'Input Variables :None
  316. 'Output Variables :None
  317. 'Returns :Boolean (True if new site is created else returns False)
  318. 'Global Variables :None
  319. 'Functions Used :ModifySite
  320. '----------------------------------------------------------------------------
  321. Function ModifySite()
  322. on error resume next
  323. Err.Clear
  324. ModifySite = False
  325. '1)Modify Web site
  326. if NOT blnModifyWebSite() then
  327. Exit Function
  328. End if
  329. '2) config virtual FTP site
  330. Dim objService
  331. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  332. If F_strUploadMethod = UPLOADMETHOD_FTP Then
  333. If NOT IsUserVirFTPInstalled(objService, F_strAdminName) Then
  334. If NOT CreateVirFTPSite(objService, F_strAdminName, F_strDir, _
  335. True, True, True) Then
  336. SetErrMsg L_ERR_CREATE_VIR_FTP_SITE
  337. Exit Function
  338. End If
  339. End If
  340. Else
  341. If IsUserVirFTPInstalled(objService, F_strAdminName) Then
  342. If NOT DeleteVirFTPSite(objService, F_strAdminName) Then
  343. SetErrMsg L_ERR_DELETE_VIR_FTP_SITE
  344. Exit Function
  345. End If
  346. End If
  347. End If
  348. ModifySite = True
  349. Set objService = Nothing
  350. end function
  351. '----------------------------------------------------------------------------
  352. 'Function name :blnModifyWebSite
  353. 'Description :Modifying the web site
  354. 'Input Variables :None
  355. 'Output Variables :None
  356. 'Returns :Boolean (True if site is modified else returns False)
  357. 'Global Variables :G_strDirRoot, G_strSysName
  358. '----------------------------------------------------------------------------
  359. Function blnModifyWebSite()
  360. Err.Clear
  361. On Error Resume Next
  362. Dim objService ' To hold WMI connection object
  363. Dim arrBindings ' To hold Full IP address as array
  364. Dim strUserName ' To hold Admin user name
  365. Dim strAnonName ' To hold Anon user name
  366. Dim retVal
  367. Dim bIISControlPswd
  368. blnModifyWebSite = FALSE
  369. G_strSiteNum = GetWebSiteNo(F_strSiteID)
  370. Call GetDomainRole( G_strDirRoot, G_strSysName )
  371. 'get the wmi iis service object
  372. set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  373. objService.security_.impersonationlevel = 3
  374. '1) modify user passwd
  375. if F_strPswdChanged = 1 then
  376. if SetUserPassword(objService, F_strAdminName, F_strAdminPswd) = FALSE then
  377. SA_TraceOut "site_modify", "modify user passwd failed"
  378. exit function
  379. end if
  380. end if
  381. '2) moidify web bindings
  382. arrBindings = Array(GetBindings(F_strIPAddr, trim(F_strPort), F_strHeader))
  383. if SetServerBindings( objService, G_strSiteNum, arrBindings ) = FALSE then
  384. SA_TraceOut "site_modify", "set Server bindings failed"
  385. exit function
  386. end if
  387. '3)set Allow Anonymous property
  388. If F_strUserLocation = "1" Then
  389. 'Get anon user
  390. If isValidUser(F_strSiteID&"_Anon",G_strSysName) Then
  391. strAnonName = G_AnonUserName
  392. Else
  393. strAnonName = F_strSiteID&"_Anon"
  394. End If
  395. if SetAnonProp(objService, G_strSiteNum, F_strchkAllow, strAnonName, "", True) = FALSE then
  396. SA_TraceOut "site_modify", "set anonymous prop failed"
  397. exit function
  398. end if
  399. Else 'F_strUserLocation = "0" or "2"
  400. If isValidUser(F_strSiteID&"_Anon",G_strDirRoot) Then
  401. strAnonName = G_AnonUserName
  402. bIISControlPswd = True
  403. Else
  404. strAnonName = G_strDirRoot&"\"&F_strSiteID&"_Anon"
  405. bIISControlPswd =False
  406. End If
  407. if SetAnonProp(objService, G_strSiteNum, F_strchkAllow, strAnonName, "", bIISControlPswd) = FALSE then
  408. SA_TraceOut "site_modify", "set anonymous prop failed"
  409. exit function
  410. end if
  411. End If
  412. '4) set execute permissions
  413. if F_selectActiveFormat = "" then
  414. Dim objSetting
  415. Set objSetting =objService.Get(GetIISWMIProviderClassName("IIs_WebServiceSetting") & ".Name='W3SVC'")
  416. if objSetting.Name = "W3SVC" then
  417. if objSetting.AccessExecute = TRUE and objSetting.AccessScript = TRUE then
  418. F_selectActiveFormat = 2
  419. elseif objSetting.AccessExecute = false and objSetting.AccessScript = TRUE then
  420. F_selectActiveFormat = 1
  421. elseif objSetting.AccessExecute = false and objSetting.AccessScript = false then
  422. F_selectActiveFormat =0
  423. elseif isnull(objSetting.AccessExecute) and isnull(objSetting.AccessScript) then
  424. F_selectActiveFormat = 0
  425. end if
  426. end if
  427. set objSetting = nothing
  428. end if
  429. if NOT SetExecPerms(F_selectActiveFormat, objService, G_strSiteNum) then
  430. SA_TraceOut "site_modify", "set execute permissions failed"
  431. exit function
  432. end if
  433. '5) try to start the web site
  434. if StartWebSite(objService, G_strSiteNum ) = FALSE then
  435. SA_TraceOut "site_modify", "Failed to start the Web site"
  436. end if
  437. '6) Update front page extensions
  438. retVal = IsFrontPageInstalledOnWebSite(G_strSysName, G_strSiteNum)
  439. Call GetWebAdministrtorRole(objService, G_strSiteNum, strUserName)
  440. If ((F_strUploadMethod = UPLOADMETHOD_FPSE) and (NOT retVal)) Then
  441. If UpdateFrontPage("true", G_strSiteNum, strUserName) = FALSE Then
  442. SA_TraceOut "site_modify", "Failed to update frontpage"
  443. SetErrMsg L_ERR_FRONTPAGE_CONFIGURATION
  444. exit function
  445. end if
  446. ElseIf ((F_strUploadMethod <> UPLOADMETHOD_FPSE) and retVal) Then
  447. If UpdateFrontPage("false", G_strSiteNum, strUserName) = FALSE Then
  448. SA_TraceOut "site_modify", "Failed to update frontpage"
  449. SetErrMsg L_ERR_FRONTPAGE_CONFIGURATION
  450. exit function
  451. end if
  452. End If
  453. '7) set default web page
  454. Call SetWebDefaultPage(objService,F_strDefaultPageText,G_strSiteNum)
  455. 'release objects
  456. set objService = nothing
  457. Call SA_MungeURL(mstrReturnURL, "PKey",G_strSiteNum)
  458. blnModifyWebSite = true
  459. End function
  460. '-------------------------------------------------------------------------
  461. 'Function name :SetFormVarsFromSystem
  462. 'Description :updates the frontpage extensions
  463. 'Input Variables :strSiteName
  464. 'Output Variables :None
  465. 'Returns :Boolean
  466. 'Global Variables :None
  467. '-------------------------------------------------------------------------
  468. Function SetFormVarsFromSystem()
  469. On Error Resume Next
  470. Err.Clear
  471. Const CONST_PWD = "********"
  472. Dim objService
  473. Dim strRoot
  474. Dim strObjPath
  475. Dim objVirDir
  476. Dim ObjIPCollection ' To hold IP collection object
  477. Dim instIPAddr ' To hold IP collection instance
  478. Dim IPCount ' To hold IP count
  479. Dim strIPArr, ObjSiteCollection
  480. Dim strIPAddr,strQuery, arrIndx
  481. Dim AdminName ' To hold Admin user name
  482. Dim blnAdminUser ' To hold boolean value for Admin user
  483. Dim VirDirSetInst ' To hold Virtual Dir setting object
  484. Dim arrID
  485. Dim retVal
  486. Dim strAdminRole
  487. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  488. objService.security_.impersonationlevel = 3
  489. '1) init the general tab vars
  490. strAdminRole = GetWebAdministrtorRole(objService, G_strSiteNum, AdminName)
  491. arrID = split(AdminName,"\")
  492. F_strAdminName = arrID(1)
  493. strRoot = G_strSiteNum & "/ROOT"
  494. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strRoot & chr(34)
  495. set objVirDir = objService.Get(strObjPath)
  496. If Err.number <> 0 Then
  497. SA_ServeFailurePage L_INFORMATION_ERRORMESSAGE
  498. exit function
  499. End if
  500. F_strDir = objVirDir.Path
  501. F_strAdminPswd = CONST_PWD
  502. F_strConfirmPswd = CONST_PWD
  503. F_strPswdChanged = 0
  504. set objVirDir = nothing
  505. F_strSiteID = GetWebSiteName(G_strSiteNum)
  506. If strAdminRole = "Domain User" Then
  507. F_strUserLocation = "0"
  508. Elseif strAdminRole = "Local User" Then
  509. F_strUserLocation = "1"
  510. End If
  511. '2) init the identifier tab vars
  512. strObjPath = GetIISWMIProviderClassName("IIs_WebServerSetting") & ".Name='"& G_strSiteNum & "'"
  513. set objSiteCollection = objService.Get(strObjPath)
  514. If Err.number <> 0 Then
  515. SA_ServeFailurePage L_INFORMATION_ERRORMESSAGE
  516. exit function
  517. End if
  518. 'Getting the Site Description , IP Address and Port for site
  519. if IsIIS60Installed Then
  520. F_strPort = objSiteCollection.ServerBindings(0).Port
  521. F_strIPAddr = objSiteCollection.ServerBindings(0).IP
  522. F_strHeader = objSiteCollection.ServerBindings(0).Hostname
  523. Else
  524. strIPArr=split(objSiteCollection.ServerBindings(0),":")
  525. if strIPArr(0)="" then
  526. strIPAddr= "All Unassigned"
  527. else
  528. F_strIPAddr = strIPArr(0)
  529. end if
  530. if strIPArr(1) = "" then
  531. F_strPort = 80
  532. else
  533. F_strPort=strIPArr(1)
  534. end if
  535. if ubound(strIPArr) > 2 then
  536. for arrIndx = 2 to ubound(strIPArr)
  537. F_strHeader = F_strHeader & strIPArr(arrIndx) & ":"
  538. next
  539. F_strHeader = left(F_strHeader,len(F_strHeader)-1)
  540. else
  541. F_strHeader = strIPArr(2)
  542. end if
  543. set objSiteCollection = nothing
  544. End If ' If IsIIS60Installed
  545. '3) init application settings tab vars
  546. strQuery = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name='" & G_strSiteNum & "/ROOT'"
  547. set VirDirSetInst = objService.get(strQuery)
  548. If Err.number <> 0 Then
  549. SA_ServeFailurepage L_INFORMATION_ERRORMESSAGE
  550. exit function
  551. End if
  552. if VirDirSetInst.AccessExecute = TRUE and VirDirSetInst.AccessScript = TRUE then
  553. F_selectActiveFormat = 2
  554. elseif VirDirSetInst.AccessExecute = false and VirDirSetInst.AccessScript = TRUE then
  555. F_selectActiveFormat = 1
  556. elseif VirDirSetInst.AccessExecute = false and VirDirSetInst.AccessScript = false then
  557. F_selectActiveFormat =0
  558. elseif isnull(VirDirSetInst.AccessExecute) and isnull(VirDirSetInst.AccessScript) then
  559. F_selectActiveFormat = 0
  560. end if
  561. retVal = VirDirSetInst.AuthAnonymous
  562. If retVal Then
  563. F_strchkAllow = "true"
  564. Else
  565. F_strchkAllow = "false"
  566. End If
  567. F_strDefaultPageText = VirDirSetInst.DefaultDoc
  568. If Err.number <> 0 Then
  569. SetErrMsg L_INFORMATION_ERRORMESSAGE
  570. exit function
  571. End if
  572. '
  573. ' Determine the current upload method. If both FPSE and FTP are
  574. ' enabled (which would have had to happen outside our UI), FPSE will
  575. ' be selected.
  576. '
  577. F_strUploadMethod = UPLOADMETHOD_NEITHER
  578. ' Determine whether FrontPage Extensions are installed
  579. If (isFrontPageInstalled(objService)) Then
  580. Call GetDomainRole(G_strDirRoot, G_strSysName)
  581. If (IsFrontPageInstalledOnWebSite(G_strSysName, G_strSiteNum)) Then
  582. F_strUploadMethod = UPLOADMETHOD_FPSE
  583. End If
  584. End If
  585. ' If FrontPage Extensions weren't installed, check FTP.
  586. If ((F_strUploadMethod <> UPLOADMETHOD_FPSE) And _
  587. IsUserVirFTPInstalled(objService, F_strAdminName)) Then
  588. F_strUploadMethod = UPLOADMETHOD_FTP
  589. End If
  590. End Function
  591. '----------------------------------------------------------------------------
  592. 'Function name :SetUserPassword
  593. 'Description :Serves in to set password
  594. 'Input Variables :UserName,Password
  595. 'Output Variables :None
  596. 'Returns :Boolean
  597. 'Global Variables :G_strDirRoot, G_strSysName
  598. '----------------------------------------------------------------------------
  599. Function SetUserPassword(objService, UserName, Password)
  600. On Error Resume Next
  601. Err.Clear
  602. Dim objUser ' To hold user object
  603. Dim objComputer ' To hold computer object
  604. Dim strAdminName
  605. Dim strDomain
  606. Dim arrID
  607. Dim retval
  608. SetUserPassword = FALSE
  609. G_strSiteNum = GetWebSiteNo(F_strSiteID)
  610. Call GetDomainRole( G_strDirRoot, G_strSysName )
  611. retval = GetWebAdministrtorRole(objService, G_strSiteNum, strAdminName)
  612. arrID = split(strAdminName,"\")
  613. strDomain = arrID(0)
  614. If ucase(strDomain) = ucase(G_strSysName) Then
  615. Set objComputer = GetObject("WinNT://" & strDomain)
  616. If Err.number <> 0 Then
  617. SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  618. Array("WinNT://" & strDomain))
  619. Exit Function
  620. End if
  621. Set objUser = objComputer.GetObject("User" , UserName)
  622. if Err.number <> 0 Then
  623. if Err.number = CONST_USER_NOTFOUND_ERRMSG Then
  624. 'user does not exist, create the user
  625. Set objUser = Nothing
  626. Set objUser = objComputer.Create("user" , trim(UserName))
  627. else
  628. setErrmsg L_ERR_GET_USER_OBJECT
  629. exit Function
  630. end if
  631. end if
  632. objUser.setPassword(trim(Password))
  633. objUser.FullName = UserName
  634. objUser.SetInfo()
  635. If Err.number <> 0 Then
  636. 'The password does not meet the password policy requirrments
  637. mintTabSelected = 0
  638. If Err.number = &H800708C5 Then
  639. SetErrMsg L_ERR_PASSWORD_POLICY
  640. Else
  641. SetErrMsg L_UNABLETOSET_PASSWORD_ERRORMESSAGE
  642. End If
  643. exit Function
  644. end if
  645. 'Release the object
  646. set objUser = nothing
  647. set objComputer = nothing
  648. Else
  649. If Instr(UserName,"_Admin") <> 0 Then
  650. SA_TraceOut "site_modify.asp", "calling ModifyUserInOu"
  651. 'create the OU with site identifier and create Admin user in that OU
  652. if ModifyUserInOu(F_strSiteID,strDomain,UserName, Password, F_strSiteID & "_Admins") = false then
  653. exit function
  654. end if
  655. End If
  656. End If
  657. SetUserPassword = TRUE
  658. Call SA_TRACEOUT("SetUserPassword","return success")
  659. End Function
  660. %>