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.

3987 lines
128 KiB

  1. <%
  2. '
  3. ' Copyright (c) Microsoft Corporation. All rights reserved.
  4. '
  5. Const CONST_SUCCESS = 0
  6. 'const error codes
  7. Const CONST_USER_NOTFOUND_ERRMSG = &H800708AD
  8. Const CONST_OBJECT_EXISTS_ERRMSG = &H80071392
  9. Const CONST_OBJECT_NOTEXISTS_ERRMSG = &H80072030
  10. Const CONST_QUOTA_USER_NOTFOUND_ERRMSG = &H80070002
  11. Const CONST_LDAP_SERVER_NOTOP = &H8007203A
  12. Const CONST_LDAP_SERVER_NOTEXIST = &H8007200A
  13. Const CONST_DOMAINROLE_ERROR = &H10
  14. Const wbemErrNotFound = &H80041002
  15. Const WBEMFLAG = 131072
  16. Const CONST_SITE_STARTED = &H2
  17. Const CONST_SITE_STOPPED = &H4
  18. Const CONST_SITE_PAUSED = &H6
  19. 'file perm constants
  20. Const CONST_FULLCONROL = &H1F01FF
  21. Const CONST_MODIFYDELTE = &H1301BF
  22. Const CONST_READEXEC = &H1200A9
  23. ' From ntioapi.h
  24. ' #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
  25. ' FILE_READ_DATA |\
  26. ' FILE_READ_ATTRIBUTES |\
  27. ' FILE_READ_EA |\
  28. ' SYNCHRONIZE)
  29. Const FILE_GENERIC_READ = &H120089
  30. 'sid string constants
  31. ' From ntseapi.h
  32. '// Interactive S-1-5-4
  33. Const SIDSTRING_INTERACTIVE = "S-1-5-4"
  34. 'reg constants
  35. Const CONST_WEBBLADES_REGKEY = "Software\Microsoft\ServerAppliance"
  36. Const CONST_WEBSITEROOT_REGVAL = "WebSiteRoot"
  37. Const CONST_FTPSITEROOT_REGVAL = "FtpRoot"
  38. Const CONST_FPSEOPTION_REGVAL = "FPSEOption"
  39. Const CONST_FTPSITEID_REGVAL = "AdminFTPServerName"
  40. 'website root and ftp site root constants
  41. Const CONST_DEF_WEBROOT = "Websites"
  42. Const CONST_DEF_FTPROOT = "Web Site Content FTP root"
  43. Const CONST_QUOTASTATE = "Unable to create directory"
  44. Const CONST_FRONTPAGE_PATH = "W3SVC/Filters/fpexedll.dll"
  45. Const CONST_FRONTPAGE_2002_INSTALLED = "Setup Packages"
  46. Const CONST_SHAREPOINT_INSTALLED = "SharePoint"
  47. 'security permission constants
  48. Const ADS_RIGHT_GENERIC_READ = &H80000000
  49. Const ADS_RIGHT_GENERIC_ALL = &H10000000
  50. Const ADS_RIGHT_DS_CREATE_CHILD = &H1
  51. Const ADS_RIGHT_DS_DELETE_CHILD = &H2
  52. Const ADS_ACETYPE_ACCESS_ALLOWED = 0
  53. Const ADS_ACETYPE_ACCESS_ALLOWED_OBJECT = &H5
  54. Const ADS_FLAG_OBJECT_TYPE_PRESENT = &H1
  55. Const ADS_FLAG_INHERITED_OBJECT_TYPE_PRESENT = &H2
  56. Const ADS_ACEFLAG_INHERIT_ACE = &H2
  57. Const ADS_ACEFLAG_INHERIT_ONLY_ACE = &H8
  58. 'A list of the various object GUIDs
  59. Const USERGUID = "{BF967ABA-0DE6-11D0-A285-00AA003049E2}"
  60. Const GROUPGUID = "{bf967a9c-0de6-11d0-a285-00aa003049e2}"
  61. Const OUGUID = "{bf967aa5-0de6-11d0-a285-00aa003049e2}"
  62. 'Error constants for CreateSitePath function
  63. Const CONST_CREATE_FSOBJ_FAILED = &H100
  64. Const CONST_INVALID_DRIVE = &H101
  65. Const CONST_NOTNTFS_DRIVE = &H102
  66. Const CONST_FAILED_TOCREATE_DIR = &H103
  67. ' Front Page related constants
  68. Const CONST_FRONTPAGE_REGLOC = "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\4.0"
  69. Const CONST_FRONTPAGE_2002_REGLOC = "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0"
  70. Const CONST_PORT_REGLOC = "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\Ports\"
  71. Const CONST_NOLIMIT_TEXT = "No limit"
  72. 'Domain Role
  73. Const MEMBER_ADDC = 0
  74. Const MEMBER_NTDC = 1
  75. Const WORKSTATION = 1
  76. Const MEMBER_WORKGROUP = 2
  77. Const MEMBER_DOMAIN = 3
  78. Const BACKUP_DOMAIN_CONTROLLER = 4
  79. Const PRIMARY_DOMAIN_CONTROLLER = 5
  80. Const DOMAIN_CONTROLLER = 6
  81. 'Add for globalization of Web/FTP log settings
  82. Const CONST_MSIISLOGFILE_FORMAT = "Microsoft IIS Log File Format"
  83. Const CONST_NCSALOGFILE_FORMAT = "NCSA Common Log File Format"
  84. Const CONST_ODBCLOGFILE_FORMAT = "ODBC Logging"
  85. Const CONST_W3CEXLOGFILE_FORMAT = "W3C Extended Log File Format"
  86. 'Running state of the service
  87. Const CONST_SERVICE_RUNNING_STATE = "Running"
  88. 'Running state of FTP server (serverstate = 2, started)
  89. Const CONST_FTPSERVER_RUNNING_STATE = 2
  90. 'Stopped state of FTP server (serverstate = 4, stopped)
  91. Const CONST_FTPSERVER_STOPPED_STATE = 4
  92. Dim sReturnURL ' to hold return URL
  93. sReturnURL = "../tasks.asp"
  94. Call SA_MungeURL(sReturnURL, "Tab1", "TabsWelcome")
  95. ' GUID constants for the four IIS logging plug-ins. These GUIDs have been
  96. ' verified with the IIS WMI providers on both Win2K and .Net.
  97. Const CONST_MSIISLOGFILE_GUID = "{FF160657-DE82-11CF-BC0A-00AA006111E0}"
  98. Const CONST_NCSALOGFILE_GUID = "{FF16065F-DE82-11CF-BC0A-00AA006111E0}"
  99. Const CONST_ODBCLOGFILE_GUID = "{FF16065B-DE82-11CF-BC0A-00AA006111E0}"
  100. Const CONST_W3CEXLOGFILE_GUID = "{FF160663-DE82-11CF-BC0A-00AA006111E0}"
  101. '
  102. ' Upload method constants for application settings tab.
  103. Const UPLOADMETHOD_NEITHER = "0"
  104. Const UPLOADMETHOD_FPSE = "1"
  105. Const UPLOADMETHOD_FTP = "2"
  106. '-------------------------------------------------------------------------
  107. 'Function name: IISLogFileGUIDToENName
  108. 'Description: Converts the given IIS Log File Plug-in GUID into
  109. ' the English-US name for that plug-in as
  110. ' long as the GUID is one of the four we recognize.
  111. 'Input Variables: strGUID - The plug-in GUID.
  112. 'Returns: The US English name of the plug-in or an
  113. ' empty string if the GUID is unrecognized.
  114. 'Global Variables: None
  115. '-------------------------------------------------------------------------
  116. Function IISLogFileGUIDToENName(strGUID)
  117. Select Case strGUID
  118. Case CONST_MSIISLOGFILE_GUID
  119. IISLogFileGUIDToENName = CONST_MSIISLOGFILE_FORMAT
  120. Case CONST_NCSALOGFILE_GUID
  121. IISLogFileGUIDToENName = CONST_NCSALOGFILE_FORMAT
  122. Case CONST_ODBCLOGFILE_GUID
  123. IISLogFileGUIDToENName = CONST_ODBCLOGFILE_FORMAT
  124. Case CONST_W3CEXLOGFILE_GUID
  125. IISLogFileGUIDToENName = CONST_W3CEXLOGFILE_FORMAT
  126. Case Else
  127. IISLogFileGUIDToENName = ""
  128. End Select
  129. End Function
  130. '-------------------------------------------------------------------------
  131. 'Function name: IISLogFileENNameToGUID
  132. 'Description: Converts the given IIS Log File Plug-in US
  133. ' English name into the GUID for that plug-in as
  134. ' long as the name is one of the four we recognize.
  135. 'Input Variables: strName - The US English plug-in name.
  136. 'Returns: The GUID of the plug-in or an empty string
  137. ' if the name is unrecognized.
  138. 'Global Variables: None
  139. '-------------------------------------------------------------------------
  140. Function IISLogFileENNameToGUID(strName)
  141. Select Case strName
  142. Case CONST_MSIISLOGFILE_FORMAT
  143. IISLogFileENNameToGUID = CONST_MSIISLOGFILE_GUID
  144. Case CONST_NCSALOGFILE_FORMAT
  145. IISLogFileENNameToGUID = CONST_NCSALOGFILE_GUID
  146. Case CONST_ODBCLOGFILE_FORMAT
  147. IISLogFileENNameToGUID = CONST_ODBCLOGFILE_GUID
  148. Case CONST_W3CEXLOGFILE_FORMAT
  149. IISLogFileENNameToGUID = CONST_W3CEXLOGFILE_GUID
  150. Case Else
  151. IISLogFileENNameToGUID = ""
  152. End Select
  153. End Function
  154. '-------------------------------------------------------------------------
  155. 'Function name: CreateOU
  156. 'Description: Creates the ou under specified parent ou
  157. 'Input Variables: strOuName - ou name
  158. ' objParent - parent of ou to be created
  159. 'Output Variables: objOu - created ou
  160. 'Returns: returns Error Message
  161. 'Global Variables: None
  162. '-------------------------------------------------------------------------
  163. Function CreateOU(strOuName, strDesc, objRoot, ByRef objOu)
  164. On Error Resume Next
  165. Err.clear
  166. Set objOu = objRoot.Create("organizationalUnit", "ou=" & strOuName)
  167. objOu.Put "Description", strDesc
  168. objOu.SetInfo
  169. CreateOU = err.number
  170. End Function
  171. '-------------------------------------------------------------------------
  172. 'Function name: getObjSiteCollection
  173. 'Description: Returns an Instance of IIs_WebServerSetting
  174. 'Input Variables: None
  175. 'Output Variables:
  176. 'Returns: Object -Returns an object
  177. 'Global Variables: None
  178. 'If object fails dislays the error message
  179. '-------------------------------------------------------------------------
  180. Function getObjSiteCollection(objService)
  181. Err.Clear
  182. On Error Resume Next
  183. Dim siteCollection 'holds sitecollection
  184. Dim strQuery 'holds query string
  185. 'form the query
  186. strQuery = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting")
  187. Set siteCollection = objService.ExecQuery(strQuery)
  188. If Err.number <> 0 Then
  189. SA_ServeFailurepageEx L_INFORMATION_ERRORMESSAGE, sReturnURL
  190. getObjSiteCollection = false
  191. exit function
  192. End If
  193. Set getObjSiteCollection = siteCollection
  194. End function
  195. '-------------------------------------------------------------------------
  196. 'Function name: CreateManagedSiteRegKey
  197. 'Description: Creates the reg key for this site under SOFTWARE\
  198. ' Microsoft\WebServerAppliance\ManagedWebSites
  199. 'Input Variables: nSiteNo, strSiteID
  200. 'Output Variables:
  201. 'Returns: None
  202. 'Global Variables: None
  203. '-------------------------------------------------------------------------
  204. Function MakeManagedSite(objService, strSiteNum,servercomment)
  205. On Error Resume Next
  206. Err.Clear
  207. Dim strObjPath 'holds object path
  208. Dim objVirDir 'holds virtualdirectory collection
  209. MakeManagedSite = false
  210. 'set ServerID
  211. strObjPath = GetIISWMIProviderClassName("IIs_WebServerSetting") & ".Name=" & chr(34) & strSiteNum & chr(34)
  212. set objVirDir = objService.Get( strObjPath )
  213. If Err.number <> 0 Then
  214. SA_TraceOut "inc_wsa", "get vir dir object failed " & Hex(Err.Number)
  215. exit Function
  216. End if
  217. 'call the method to set serverID property
  218. objVirDir.serverID = servercomment
  219. objVirDir.put_(WBEMFLAG)
  220. if Err.number <> 0 then
  221. SA_TraceOut "Make Managed Site", "Failed to set ServerID" & "(" & Hex(Err.Number) & ")"
  222. Set objVirDir = nothing
  223. exit function
  224. end if
  225. MakeManagedSite = true
  226. Set objVirDir = nothing
  227. End Function
  228. '-------------------------------------------------------------------------
  229. 'Function name :isValidSiteIdentifier
  230. 'Description :Returns an Instance of IIs_WebServerSetting
  231. 'Input Variables :None
  232. 'Output Variables :None
  233. 'Returns :Object -Returns an object
  234. 'Global Variables :None
  235. 'If object fails dislays the error message
  236. '-------------------------------------------------------------------------
  237. Function isValidSiteIdentifier(strSiteID, _
  238. strAdminName, _
  239. strDirRoot, _
  240. bVerifyUser)
  241. Err.Clear
  242. On Error Resume Next
  243. isValidSiteIdentifier = FALSE
  244. 'verify the siteid
  245. If CStr(GetWebSiteNo(strSiteID)) <> "" Then
  246. SA_TraceOut "inc_wsa", "Failed: isValidSiteIdentifier"
  247. Exit Function
  248. End If
  249. 'verify the administrator
  250. If bVerifyUser Then
  251. If isValidUser(strAdminName, strDirRoot) = FALSE Then
  252. SA_TraceOut "inc_wsa", "Failed: isValidSiteIdentifier"
  253. Exit Function
  254. End If
  255. End If
  256. isValidSiteIdentifier = TRUE
  257. SA_TraceOut "inc_wsa", "success isValidSiteIdentifier"
  258. End function
  259. '-------------------------------------------------------------------------
  260. 'Function name :isValidUser
  261. 'Description :Returns an Instance of IIs_WebServerSetting
  262. 'Input Variables :None
  263. 'Output Variables :
  264. 'Returns :Object -Returns an object
  265. 'Global Variables :None
  266. 'If object fails dislays the error message
  267. '-------------------------------------------------------------------------
  268. Function isValidUser(strUserName, strDirRoot)
  269. On Error Resume Next
  270. Err.Clear
  271. Dim objComputer 'holds Computer object
  272. Dim objUser
  273. isValidUser = False
  274. Set objComputer = GetObject("WinNT://" & strDirRoot)
  275. Set objUser = objComputer.GetObject("User",strUserName)
  276. If Err.number <> 0 Then
  277. isValidUser = True
  278. Set objComputer = nothing
  279. Exit Function
  280. End If
  281. Set objComputer = nothing
  282. Set objUser = nothing
  283. End function
  284. '-------------------------------------------------------------------------
  285. 'Function name :GetNewSiteNo
  286. 'Description :Returns an Free Site no
  287. 'Input Variables :None
  288. 'Output Variables :
  289. 'Returns :siteno
  290. 'Global Variables :None
  291. 'If object fails dislays the error message
  292. '-------------------------------------------------------------------------
  293. Function GetNewSiteNo()
  294. On Error Resume Next
  295. Err.Clear
  296. Dim objService 'holds WMI Connection
  297. Dim objInstances 'holds WebServer Instance
  298. Dim objInstance 'holds instance object
  299. Dim nSiteNo 'holds sitenumber value
  300. Dim nPos 'holds position value
  301. Dim nCount 'holds count value
  302. Dim index 'holds index value
  303. Dim nStart 'holds start value
  304. Dim bFound 'holds boolean value
  305. Dim arrSiteNo 'holsd arraysite number
  306. GetNewSiteNo = -1
  307. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  308. Set objInstances = objService.InstancesOf(GetIISWMIProviderClassName("IIS_WebServer"))
  309. nCount = objInstances.Count
  310. 'store the existing site no. in the array
  311. ReDim arrSiteNo(nCount)
  312. For Each objInstance In objInstances
  313. nPos = InStr(objInstance.Name, "/")
  314. arrSiteNo(nStart) = Right(objInstance.Name, len(objInstance.Name) - nPos)
  315. nStart = nStart + 1
  316. Next
  317. nCount = Ubound(arrSiteNo) - 1
  318. nSiteNo = 1
  319. bFound = FALSE
  320. Do While bFound <> TRUE
  321. For index= 0 to nCount
  322. If Clng(nSiteNo) = Clng(arrSiteNo(index)) Then
  323. Exit For
  324. End If
  325. Next
  326. If index > nCount Then
  327. bFound = TRUE
  328. Else
  329. nSiteNo = nSiteNo + 1
  330. End If
  331. Loop
  332. SA_TraceOut "inc_wsa", "SiteNo=" & nSiteNo
  333. GetNewSiteNo = nSiteNo
  334. Set objService = nothing
  335. Set objInstances = nothing
  336. End function
  337. '-------------------------------------------------------------------------
  338. 'Sub name :GetDomainRole
  339. 'Description :Returns domain and server name of local machine
  340. 'Input Variables :None
  341. 'Output Variables :strDirectoryRoot, strSysName
  342. 'Returns :None
  343. 'Global Variables :None
  344. '-------------------------------------------------------------------------
  345. Sub GetDomainRole(ByRef strDirectoryRoot, ByRef strSysName)
  346. On Error Resume Next
  347. Err.Clear
  348. Dim strDomainName 'holds Domain name
  349. Dim Query 'holds query string
  350. Dim objService 'holds WMI connection
  351. Dim Parent 'holds result query
  352. Dim role 'holds role of the sytem
  353. Dim Domain 'holds domain name
  354. Dim inst 'holds instance of computer object
  355. strDomainName = ""
  356. strSysName = ""
  357. Query = "Select * from Win32_ComputerSystem"
  358. Set objService = getWMIConnection("root\cimv2")
  359. set Parent = objService.ExecQuery(Query)
  360. If Err.number <> 0 Then
  361. SA_TraceOut "Failed to get connection to Computer name space"
  362. Exit Sub
  363. End if
  364. For each inst in Parent
  365. role = inst.DomainRole
  366. strDomainName = inst.Domain
  367. strSysName = inst.Name
  368. exit for
  369. next
  370. If (role = MEMBER_DOMAIN) Then
  371. strDirectoryRoot = strDomainName
  372. ElseIf (role = MEMBER_WORKGROUP) Then
  373. strDirectoryRoot = strSysName
  374. End If
  375. End Sub
  376. '-------------------------------------------------------------------------
  377. 'Function name: GetWebSiteNo
  378. 'Description: gets the web site no
  379. 'Input Variables: strSiteId - site identifier
  380. ' strSysName - system name
  381. 'Returns: strSiteNo
  382. '--------------------------------------------------------------------------
  383. Function GetWebSiteNo(strSiteId)
  384. On Error Resume Next
  385. Err.Clear
  386. Dim Parent 'holds result collection
  387. Dim Query 'holds query string
  388. Dim inst 'holds instance or result collection
  389. Dim strSiteNo 'holds site name
  390. Dim objService 'holds WMI Connection object
  391. Query = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where ServerID=" & chr(34) & strSiteId & chr(34)
  392. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  393. Set Parent = objService.ExecQuery(Query)
  394. If Err.number <> 0 Then
  395. SA_TraceOut "Failed to get the IIs_WebServerSetting object with error " & "(" & Hex(Err.Number) & ")"
  396. exit Function
  397. End if
  398. For Each inst In Parent
  399. strSiteNo = inst.Name
  400. Exit For
  401. Next
  402. GetWebSiteNo = strSiteNo
  403. Set Parent = nothing
  404. Set objService = nothing
  405. End Function
  406. '-------------------------------------------------------------------------
  407. 'Function name: GetWebSiteName
  408. 'Description: gets the web site no
  409. 'Input Variables: strSiteId - site identifier
  410. 'Returns: strSiteNo
  411. '--------------------------------------------------------------------------
  412. Function GetWebSiteName(strSiteId)
  413. On Error Resume Next
  414. Err.Clear
  415. Dim Parent 'holds result query
  416. Dim Query 'holds query string
  417. Dim inst 'holds instance of Parent
  418. Dim strSiteName 'holds sitename
  419. Dim objService 'holds WMI Connection object
  420. Query = GetIISWMIProviderClassName("IIs_WebServerSetting") & ".Name=" & chr(34) & strSiteId & chr(34)
  421. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  422. Set Parent = objService.Get( Query )
  423. If Err.number <> 0 Then
  424. SA_TraceOut "Failed to get the IIs_WebServerSetting object with error " & "(" & Hex(Err.Number) & ")"
  425. exit Function
  426. End if
  427. strSiteName = Parent.ServerComment
  428. GetWebSiteName = strSiteName
  429. 'Release objects
  430. Set Parent = nothing
  431. Set objService = nothing
  432. End Function
  433. '-------------------------------------------------------------------------
  434. 'Function name: SetApplProt
  435. 'Description: Sets Application Protection level
  436. 'Input Variables: objService, strSiteNum, strProtect
  437. 'Returns: boolean
  438. '--------------------------------------------------------------------------
  439. Function SetApplProt( objService, strSiteNum, strProtect )
  440. On Error Resume Next
  441. Err.Clear
  442. Dim strObjPath 'holds Query string
  443. Dim objVirDir 'holds query result
  444. SetApplProt = FALSE
  445. 'set application protection
  446. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDir") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  447. set objVirDir = objService.Get( strObjPath )
  448. If Err.number <> 0 Then
  449. SA_TraceOut "inc_wsa", "get vir dir object failed " & Hex(Err.Number)
  450. exit Function
  451. End if
  452. 'call the method to set the application protection
  453. objVirDir.AppCreate2( cint(strProtect) )
  454. If Err.number <> 0 Then
  455. SA_TraceOut "inc_wsa", "Failed to set the application protection " & Hex(Err.number)
  456. exit Function
  457. End if
  458. SetApplProt = TRUE
  459. 'Release objects
  460. set objVirDir = nothing
  461. End Function
  462. '-------------------------------------------------------------------------
  463. 'Function name: SetApplRead
  464. 'Description: Sets Read permissions on the web site
  465. 'Input Variables: objService, strSiteNum
  466. 'Returns: boolean
  467. '--------------------------------------------------------------------------
  468. Function SetApplRead( objService, strSiteNum)
  469. On Error Resume Next
  470. Err.Clear
  471. Dim strObjPath 'holds Query string
  472. Dim objVirDir 'holds query result
  473. SetApplRead = FALSE
  474. 'set application protection
  475. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  476. set objVirDir = objService.Get( strObjPath )
  477. If Err.number <> 0 Then
  478. SA_TraceOut "inc_wsa", "get vir dir object failed " & Hex(Err.Number)
  479. exit Function
  480. End if
  481. 'call the method to set the application Read property
  482. objVirDir.AccessRead = true
  483. objVirDir.AccessNoRemoteRead = false
  484. objVirDir.AccessSource = false
  485. objVirDir.Put_( WBEMFLAG )
  486. If Err.number <> 0 Then
  487. SA_TraceOut "inc_wsa", "Failed to set the application read property " & Hex(Err.number)
  488. exit Function
  489. End if
  490. SetApplRead = TRUE
  491. 'Release objects
  492. set objVirDir = nothing
  493. End Function
  494. '-------------------------------------------------------------------------
  495. 'Function name: SetAnonProp
  496. 'Description: Sets the Anon user
  497. 'Input Variables: objService, strSiteNum, strAllow, strAnonName, strAnonPwd
  498. 'Returns: boolean
  499. '--------------------------------------------------------------------------
  500. Function SetAnonProp(objService, strSiteNum, strAllow, strAnonName, strAnonPwd, bIIS)
  501. On Error Resume Next
  502. Err.Clear
  503. Dim strObjPath 'holds Query string
  504. Dim objVirDirSet 'holds query result
  505. Dim strPassword
  506. Dim strUserName
  507. Dim objSystem
  508. Dim strDomainName
  509. Dim arrDomain
  510. SA_Traceout "parameters=", strSiteNum + ":" + strAllow + ":" + strAnonName + ":" + strAnonPwd
  511. SetAnonProp = FALSE
  512. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  513. set objVirDirSet = objService.Get(strObjPath)
  514. if Err.number <> 0 then
  515. SA_TraceOut "inc_wsa", "Get WebVirtualDirSetting object failed with error " & "(" & Hex(Err.Number) & ")"
  516. exit Function
  517. End if
  518. 'Set bIIS to false, that's because a new IIS 6.0 security feature, which does not
  519. 'install sub-authenticator on clean installs. bIIS should always be false.
  520. 'It also affects anon access. Now we don't let IIS manage the pwd, and have to set
  521. 'the pwd explicitly. Since user can disable/enable the anon access back and forth,
  522. 'we need to always store the pwd in AnonymousUserPass. The pwd for anon user created
  523. 'by WebUI is randomly generated from SAHelper, it should not be empty. If it's empty,
  524. 'it means user wants to change the anon access permission.
  525. bIIS = false
  526. If strAnonPwd <> "" Then
  527. objVirDirSet.AnonymousUserPass = strAnonPwd
  528. End If
  529. if lcase(strAllow) = "true" then
  530. objVirDirSet.AuthAnonymous = True
  531. objVirDirSet.AuthBasic = False
  532. objVirDirSet.AuthNTLM = True
  533. objVirDirSet.AnonymousUserName = strAnonName
  534. objVirDirSet.AnonymousPasswordSync = False
  535. else
  536. objVirDirSet.AuthAnonymous = False
  537. objVirDirSet.AuthBasic = True
  538. objVirDirSet.AuthNTLM = True
  539. end if
  540. objVirDirSet.Put_( WBEMFLAG )
  541. If Err.number <> 0 Then
  542. SA_TraceOut "inc_wsa", "failed to set the anon settings with error " & "(" & Hex(Err.Number) & ")"
  543. end if
  544. SetAnonProp = TRUE
  545. 'Release objects
  546. set objVirDirSet = nothing
  547. End Function
  548. '-------------------------------------------------------------------------
  549. 'Function name: SetServerBindings
  550. 'Description: Sets the IP address, tcp port and host header values
  551. 'Input Variables: objService, strSiteNum, arrBindings
  552. 'Returns: boolean
  553. '--------------------------------------------------------------------------
  554. Function SetServerBindings( objService, strSiteNum, arrBindings )
  555. On Error Resume Next
  556. Err.Clear
  557. Dim strObjPath 'holds query string
  558. Dim objSite 'holds site
  559. SetServerBindings = FALSE
  560. strObjPath = GetIISWMIProviderClassName("IIs_WebServerSetting") & ".Name=" & chr(34) & strSiteNum & chr(34)
  561. set objSite = objService.Get(strObjPath)
  562. If Err.number <> 0 Then
  563. SA_TraceOut "Failed to get the IIs_WebServerSetting object with error " & "(" & Hex(Err.Number) & ")"
  564. exit Function
  565. End if
  566. SA_TraceOut "inc_wsa", "bindings=" & arrBindings(0)
  567. If IsIIS60Installed() Then
  568. Dim arrTmp
  569. Dim arrObjBindings(0)
  570. 'We need to create a ServerBinding object for IIS6.0 WMI
  571. arrTmp = split( arrBindings(0),":")
  572. set arrObjBindings(0) = objService.Get("ServerBinding").SpawnInstance_
  573. arrObjBindings(0).IP = arrTmp(0) 'IP Address
  574. arrObjBindings(0).Port = arrTmp(1) 'Port
  575. arrObjBindings(0).Hostname = arrTmp(2) 'Hostname - Header in old WMI
  576. objSite.ServerBindings = arrObjBindings
  577. Else
  578. objSite.ServerBindings = arrBindings
  579. End If
  580. objSite.Put_( WBEMFLAG )
  581. If Err.number <> 0 Then
  582. SA_TraceOut "Failed to set the serverbindings with error " & "(" & Hex(Err.Number) & ")"
  583. exit Function
  584. end if
  585. SetServerBindings = TRUE
  586. 'Release objects
  587. set objSite = nothing
  588. End Function
  589. '-------------------------------------------------------------------------
  590. 'Function name: StartWebSite
  591. 'Description: Starts web site after creation
  592. 'Input Variables: objService, strSiteNum
  593. 'Returns: boolean
  594. '--------------------------------------------------------------------------
  595. Function StartWebSite( objService, strSiteNum )
  596. On Error Resume Next
  597. Err.Clear
  598. Dim strObjPath 'holds query string
  599. Dim objWebSite 'holds result site object
  600. StartWebSite = FALSE
  601. strObjPath = GetIISWMIProviderClassName("IIs_WebServer") & ".Name=" & chr(34) & strSiteNum & chr(34)
  602. Set objWebSite = objService.Get(strObjPath)
  603. If Err.number <> 0 Then
  604. SA_TraceOut "inc_wsa", "Failed to get the IIs_WebServer Object with error " & strObjPath & "(" & Hex(Err.Number) & ")" & Err.Description
  605. exit Function
  606. End if
  607. if objWebSite.ServerState = CONST_SITE_STOPPED then
  608. objWebSite.start()
  609. If Err.number <> 0 Then
  610. SA_TraceOut "inc_wsa", "Failed to start the IIs_WebServer Object with error " & "(" & Hex(Err.Number) & ")"
  611. exit Function
  612. end if
  613. elseif objWebSite.ServerState = CONST_SITE_PAUSED then
  614. objWebSite.Continue()
  615. If Err.number <> 0 Then
  616. SA_TraceOut "inc_wsa", "Failed to start the IIs_WebServer Object with error " & "(" & Hex(Err.Number) & ")"
  617. exit Function
  618. end if
  619. end if
  620. StartWebSite = TRUE
  621. 'Release objects
  622. Set objWebSite = nothing
  623. End Function
  624. '-------------------------------------------------------------------------
  625. 'Function name: PauseWebSite
  626. 'Description: Pause web site
  627. 'Input Variables: objService, strSiteNum
  628. 'Returns: boolean
  629. '--------------------------------------------------------------------------
  630. Function PauseWebSite( objService, strSiteNum )
  631. On Error Resume Next
  632. Err.Clear
  633. Dim strObjPath 'holds query string
  634. Dim objWebSite 'holds result site object
  635. PauseWebSite = FALSE
  636. strObjPath = GetIISWMIProviderClassName("IIs_WebServer") & ".Name=" & chr(34) & strSiteNum & chr(34)
  637. Set objWebSite = objService.Get(strObjPath)
  638. If Err.number <> 0 Then
  639. SA_TraceOut "inc_wsa", "Failed to get the IIs_WebServer Object with error " & strObjPath & "(" & Hex(Err.Number) & ")" & Err.Description
  640. exit Function
  641. End if
  642. if objWebSite.ServerState = CONST_SITE_STARTED then
  643. objWebSite.pause()
  644. If Err.number <> 0 Then
  645. SA_TraceOut "inc_wsa", "Failed to pause the IIs_WebServer Object with error " & "(" & Hex(Err.Number) & ")"
  646. exit Function
  647. end if
  648. end if
  649. PauseWebSite = TRUE
  650. 'Release objects
  651. Set objWebSite = nothing
  652. End Function
  653. '-------------------------------------------------------------------------
  654. 'Function name: StopWebSite
  655. 'Description: Starts web site after creation
  656. 'Input Variables: objService, strSiteNum
  657. 'Returns: boolean
  658. '--------------------------------------------------------------------------
  659. Function StopWebSite( objService, strSiteNum )
  660. On Error Resume Next
  661. Err.Clear
  662. Dim strObjPath 'holds query object
  663. Dim objWebSite 'holds query result
  664. StopWebSite = FALSE
  665. strObjPath = GetIISWMIProviderClassName("IIs_WebServer") & ".Name=" & chr(34) & strSiteNum & chr(34)
  666. Set objWebSite = objService.Get(strObjPath)
  667. If Err.number <> 0 Then
  668. SA_TraceOut "site_area.asp", "Failed to get the IIs_WebServer Object with error " & strObjPath & "(" & Hex(Err.Number) & ")" & Err.Description
  669. exit Function
  670. End if
  671. if objWebSite.ServerState = CONST_SITE_STARTED or objWebSite.ServerState = CONST_SITE_PAUSED then
  672. objWebSite.Stop()
  673. If Err.number <> 0 Then
  674. SA_TraceOut "site_area.asp", "Failed to stop the IIs_WebServer Object with error " & "(" & Hex(Err.Number) & ")"
  675. exit Function
  676. end if
  677. end if
  678. StopWebSite = TRUE
  679. 'Release objects
  680. Set objWebSite = nothing
  681. End Function
  682. '-------------------------------------------------------------------------
  683. 'Function name: SA_Sleep
  684. 'Description: Sleep for the given period of time (ms)
  685. 'Input Variables: Time to sleep in ms
  686. 'Output Variables:
  687. 'Returns: None
  688. 'Global Variables:
  689. '-------------------------------------------------------------------------
  690. Public Function SA_Sleep(lngTimeToSleep)
  691. On Error Resume Next
  692. Dim objSystem
  693. Set objSystem = CreateObject("comhelper.SystemSetting")
  694. If Err.Number <> 0 Then
  695. Call SA_TraceOut(SA_GetScriptFileName(), "SA_Sleep failed to create COMHelper object: " + CStr(Hex(Err.Number)))
  696. Set objSystem = Nothing
  697. Exit Function
  698. End If
  699. call objSystem.Sleep(lngTimeToSleep)
  700. If Err.Number <> 0 Then
  701. Call SA_TraceOut(SA_GetScriptFileName(), "SA_Sleep failed: " + CStr(Hex(Err.Number)))
  702. Set objSystem = Nothing
  703. Exit Function
  704. End If
  705. Set objSystem = Nothing
  706. End Function
  707. '-------------------------------------------------------------------------
  708. 'Function name: SetAdminFtpServerName
  709. 'Description: sets the ftp site name in registry
  710. 'Input Variables: strFTPServerName
  711. 'Returns: true/false
  712. 'Global variables: None
  713. '--------------------------------------------------------------------------
  714. Function SetAdminFtpServerName(strFTPServerName)
  715. on error resume next
  716. Err.clear
  717. Dim IRC
  718. Dim objGetHandle
  719. SetAdminFtpServerName = FALSE
  720. set objGetHandle = RegConnection()
  721. IRC = objGetHandle.SetStringValue(G_HKEY_LOCAL_MACHINE,CONST_WEBBLADES_REGKEY,CONST_FTPSITEID_REGVAL,strFTPServerName)
  722. If Err.number <> 0 then
  723. SA_TraceOut "inc_wsa", "Failed to Set adminFTPServerName regval"
  724. exit function
  725. end if
  726. SetAdminFtpServerName = TRUE
  727. End Function
  728. '-------------------------------------------------------------------------
  729. 'Function name: GetAdminFtpServerName
  730. 'Description: gets the ftp site id
  731. 'Input Variables: None
  732. 'Output Variables: none
  733. 'Returns: FTP site ID
  734. '--------------------------------------------------------------------------
  735. Function GetAdminFtpServerName()
  736. On Error Resume Next
  737. Err.Clear
  738. Dim objGetHandle 'holds regconnection value
  739. set objGetHandle = RegConnection()
  740. GetAdminFtpServerName = GetRegKeyValue(objGetHandle,CONST_WEBBLADES_REGKEY,CONST_FTPSITEID_REGVAL,CONST_STRING)
  741. If Err.number <> 0 then
  742. GetAdminFtpServerName = ""
  743. SA_TraceOut "inc_wsa", "Failed to get AdminFtpServerName regval"
  744. exit function
  745. end if
  746. End Function
  747. '-------------------------------------------------------------------------
  748. 'Function name: IsAdminFTPServerExist
  749. 'Description: check whether AdminFTPServer exists
  750. 'Input Variables: None
  751. 'Output Variables: none
  752. 'Returns: true/false
  753. '--------------------------------------------------------------------------
  754. Function IsAdminFTPServerExist()
  755. On Error Resume Next
  756. Err.Clear
  757. dim strAdminFTPServerName
  758. dim objWMIConnection
  759. dim objAdminFTPServer
  760. IsAdminFTPServerExist = false
  761. strAdminFTPServerName = GetAdminFtpServerName()
  762. ' If could not read the admin FTP server name from the registry, return false
  763. if strAdminFTPServerName = "" Then
  764. Exit Function
  765. End if
  766. ' If could not get admin FTP server from WMI, return false
  767. set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  768. Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  769. if Err.number <> 0 or (Not IsObject(objAdminFTPServer)) Then
  770. SA_TraceOut "inc_wsa", "IsAdminFTPServerExist failed"
  771. Exit Function
  772. End If
  773. IsAdminFTPServerExist = true
  774. End Function
  775. '-------------------------------------------------------------------------
  776. 'Function name: IsAdminFTPServerExistAndRunning
  777. 'Description: check whether AdminFTPServer exists and is running
  778. 'Input Variables: None
  779. 'Output Variables: none
  780. 'Returns: true/false
  781. '--------------------------------------------------------------------------
  782. Function IsAdminFTPServerExistAndRunning()
  783. On Error Resume Next
  784. Err.Clear
  785. dim strAdminFTPServerName
  786. dim objWMIConnection
  787. dim objAdminFTPServer
  788. IsAdminFTPServerExistAndRunning = false
  789. strAdminFTPServerName = GetAdminFtpServerName()
  790. ' If could not read the admin FTP server name from the registry, return false
  791. if strAdminFTPServerName = "" Then
  792. Exit Function
  793. End if
  794. ' If could not get admin FTP server from WMI, return false
  795. set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  796. Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  797. if Err.number <> 0 or (Not IsObject(objAdminFTPServer)) Then
  798. SA_TraceOut "inc_wsa", "IsAdminFTPServerExistAndRunning failed"
  799. Exit Function
  800. End If
  801. ' If admin FTP server is not running, return false
  802. if objAdminFTPServer.ServerState <> CONST_FTPSERVER_RUNNING_STATE Then
  803. SA_TraceOut "inc_wsa", "AdminFTPServer is not running"
  804. exit function
  805. End if
  806. IsAdminFTPServerExistAndRunning = true
  807. End Function
  808. '-------------------------------------------------------------------------
  809. 'Function name: IsAdminFTPServerExist
  810. 'Description: check whether AdminFTPServer exists
  811. 'Input Variables: None
  812. 'Output Variables: none
  813. 'Returns: true/false
  814. '--------------------------------------------------------------------------
  815. Function IsAdminFTPServerExist()
  816. On Error Resume Next
  817. Err.Clear
  818. dim strAdminFTPServerName
  819. dim objWMIConnection
  820. dim objAdminFTPServer
  821. IsAdminFTPServerExist = false
  822. strAdminFTPServerName = GetAdminFtpServerName()
  823. ' If could not read the admin FTP server name from the registry, return false
  824. if strAdminFTPServerName = "" Then
  825. Exit Function
  826. End if
  827. ' If could not get admin FTP server from WMI, return false
  828. set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  829. Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  830. if Err.number <> 0 or (Not IsObject(objAdminFTPServer)) Then
  831. SA_TraceOut "inc_wsa", "IsAdminFTPServerExist fails"
  832. Exit Function
  833. End If
  834. IsAdminFTPServerExist = true
  835. End Function
  836. '-------------------------------------------------------------------------
  837. 'Function name: StartAdminFTPServer
  838. 'Description: Start Admin FTP Server
  839. 'Input Variables: None
  840. 'Output Variables: none
  841. 'Returns: true/false
  842. '--------------------------------------------------------------------------
  843. Function StartAdminFTPServer()
  844. On Error Resume Next
  845. Err.Clear
  846. dim strAdminFTPServerName
  847. dim objWMIConnection
  848. dim objAdminFTPServer
  849. StartAdminFTPServer = false
  850. strAdminFTPServerName = GetAdminFtpServerName()
  851. ' If could not read the admin FTP server name from the registry, return false
  852. if strAdminFTPServerName = "" Then
  853. Exit Function
  854. End if
  855. ' If could not get admin FTP server from WMI, return false
  856. set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  857. Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  858. if objAdminFTPServer.ServerState <> CONST_FTPSERVER_RUNNING_STATE Then
  859. objAdminFTPServer.Start
  860. Else
  861. SA_TraceOut "inc_wsa", "Admin FTP Server is already started"
  862. End if
  863. if Err.number <> 0 Then
  864. SA_TraceOut "inc_wsa", "StartAdminFTPServer failed: " & err.Description
  865. Exit Function
  866. End If
  867. StartAdminFTPServer = true
  868. End Function
  869. '-------------------------------------------------------------------------
  870. 'Function name: StopAdminFTPServer
  871. 'Description: Stop Admin FTP Server
  872. 'Input Variables: None
  873. 'Output Variables: none
  874. 'Returns: true/false
  875. '--------------------------------------------------------------------------
  876. Function StopAdminFTPServer()
  877. On Error Resume Next
  878. Err.Clear
  879. dim strAdminFTPServerName
  880. dim objWMIConnection
  881. dim objAdminFTPServer
  882. StopAdminFTPServer = false
  883. strAdminFTPServerName = GetAdminFtpServerName()
  884. ' If could not read the admin FTP server name from the registry, return false
  885. if strAdminFTPServerName = "" Then
  886. Exit Function
  887. End if
  888. ' If could not get admin FTP server from WMI, return false
  889. set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  890. Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  891. if objAdminFTPServer.ServerState = CONST_FTPSERVER_RUNNING_STATE Then
  892. objAdminFTPServer.Stop
  893. Else
  894. SA_TraceOut "inc_wsa", "Admin FTP Server is already stopped"
  895. End if
  896. if Err.number <> 0 Then
  897. SA_TraceOut "inc_wsa", "StopAdminFTPServer failed"
  898. Exit Function
  899. End If
  900. StopAdminFTPServer = true
  901. End Function
  902. '-------------------------------------------------------------------------
  903. 'Function name: StopDefaultFTPServer
  904. 'Description: Before starting admin FTP server, we need try to stop
  905. ' the default FTP server. If it cannot be stopped, or the
  906. ' the running FTP server is not the default FTP server (nor
  907. ' the admin FTP server), return false. Return true otherwise.
  908. 'Input Variables: None
  909. 'Output Variables: none
  910. 'Returns: true/false
  911. '--------------------------------------------------------------------------
  912. Function StopDefaultFTPServer()
  913. On Error Resume Next
  914. Err.Clear
  915. dim objWMIConnection
  916. dim objFTPServers
  917. dim instFTPServer
  918. Const TIME_TO_SLEEP = 500 ' Sleep 1/2 second
  919. StopDefaultFTPServer = false
  920. set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  921. Set objFTPServers = objWMIConnection.InstancesOf(GetIISWMIProviderClassName("IIsFtpServer"))
  922. if Err.number <> 0 Then
  923. SA_TraceOut "inc_wsa", "Fail to stop Default FTP Server:" & err.number
  924. exit function
  925. end if
  926. if objFTPServers.count = 0 then
  927. ' If there is not FTP site, return true
  928. StopDefaultFTPServer = true
  929. exit function
  930. End If
  931. for each instFTPServer in objFTPServers
  932. 'If running site is not default FTP site, return false since we don't want
  933. 'to stop any FTP site other than the default FTP site
  934. if instFTPServer.ServerState = CONST_FTPSERVER_RUNNING_STATE And instFTPServer.Name <> "MSFTPSVC/1" Then
  935. exit function
  936. End If
  937. 'If it's default site, stop it if it's running
  938. if instFTPServer.Name = "MSFTPSVC/1" Then
  939. if instFTPServer.ServerState <> CONST_FTPSERVER_RUNNING_STATE Then
  940. StopDefaultFTPServer = true
  941. Exit Function
  942. Else
  943. instFTPServer.Stop
  944. Dim iCounter
  945. For iCounter = 0 to 10 'loop for 10 times
  946. 'Requery the WMI for the state of the default FTP server
  947. Set instFTPServer = objWMIConnection.Get("IIsFtpServer.Name='MSFTPSVC/1'")
  948. If instFTPServer.ServerState = CONST_FTPSERVER_STOPPED_STATE Then
  949. StopDefaultFTPServer = true
  950. Exit Function
  951. Else
  952. call SA_Sleep(TIME_TO_SLEEP)
  953. End If
  954. Next
  955. if Err.number <> 0 Then
  956. SA_TraceOut "inc_wsa.asp", "Failed to stop default FTP site"
  957. Exit Function
  958. End If
  959. StopDefaultFTPServer = true
  960. Exit Function
  961. End If
  962. End If
  963. Next
  964. End Function
  965. '-------------------------------------------------------------------------
  966. 'Function name: CreateAdminFTPServer
  967. 'Description: Create FTP server for Updating Website Content and save
  968. ' the server name to the registry
  969. 'Input Variables: None
  970. 'Output Variables: none
  971. 'Returns: true/false
  972. '--------------------------------------------------------------------------
  973. Function CreateAdminFTPServer()
  974. On Error Resume Next
  975. Err.Clear
  976. Dim strName
  977. Dim strRoot
  978. Dim strPort
  979. Dim objWMIConnection
  980. Dim Bindings
  981. Dim objFTPService
  982. Dim strSiteObjPath
  983. Dim strSitePath
  984. Dim objPath
  985. Dim objSetting
  986. Dim objSysDrive
  987. Dim strSysDrive
  988. CreateAdminFTPServer = false
  989. 'Get FTP site root dir
  990. Set objSysDrive = server.CreateObject("Scripting.FileSystemObject")
  991. Call GetFTPSiteRootVal(strRoot)
  992. 'If the root dir does not exist, create it
  993. If objSysDrive.FolderExists(strRoot)=false Then
  994. call CreateSitePath(objSysDrive, strRoot)
  995. End If
  996. strName = "Web Site Content"
  997. strPort = "21"
  998. set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  999. Bindings = Array(0)
  1000. Set Bindings(0) = objWMIConnection.get("ServerBinding").SpawnInstance_()
  1001. Bindings(0).IP = "" 'all unsigned
  1002. Bindings(0).Port = strPort
  1003. 'Create and start the admin FTP site
  1004. Set objFTPService = objWMIConnection.Get("IIsFtpService='MSFTPSVC'")
  1005. strSiteObjPath = objFTPService.CreateNewSite(strName, Bindings, strRoot)
  1006. If err.number <> 0 Then
  1007. sa_traceout "inc_wsa", "Failed to create admin FTP site " & err.Description
  1008. Exit Function
  1009. End If
  1010. ' Parse site ID out of WMI object path
  1011. Set objPath = CreateObject("WbemScripting.SWbemObjectPath")
  1012. objPath.Path = strSiteObjPath
  1013. strSitePath = objPath.Keys.Item("")
  1014. ' Set ftp virtual directory properties
  1015. Set objSetting = objWMIConnection.Get("IIsFtpServerSetting.Name='" & strSitePath & "'")
  1016. objSetting.AllowAnonymous = false
  1017. objSetting.AccessRead = true
  1018. objSetting.AccessWrite = false
  1019. objSetting.UserIsolationMode = 0 'not using the user isolation mode
  1020. objSetting.Put_()
  1021. 'Save the admin FTP server name to registry
  1022. call SetAdminFTPServerName(strSitePath)
  1023. If err.number <> 0 Then
  1024. sa_traceout "inc_wsa", "Failed to create admin FTP site " & err.Description
  1025. Exit Function
  1026. End If
  1027. CreateAdminFTPServer = true
  1028. End Function
  1029. '-------------------------------------------------------------------------
  1030. 'Function name: GetWebSiteRootVal
  1031. 'Description: gets the web site root dir
  1032. 'Input Variables: None
  1033. 'Output Variables: strWebRootDir
  1034. 'Returns: error num
  1035. '--------------------------------------------------------------------------
  1036. Function GetWebSiteRootVal(ByRef strWebRootDir)
  1037. On Error Resume Next
  1038. Err.Clear
  1039. Dim IRC 'holds return value
  1040. Dim objGetHandle 'holds regconnection value
  1041. set objGetHandle = RegConnection()
  1042. IRC = ""
  1043. IRC = GetRegKeyValue(objGetHandle,CONST_WEBBLADES_REGKEY,CONST_WEBSITEROOT_REGVAL,CONST_STRING)
  1044. If Err.number <> 0 then
  1045. GetWebSiteRootVal = Err.number
  1046. SA_TraceOut "inc_wsa", "Failed to get the web root dir val from reg"
  1047. exit function
  1048. end if
  1049. set objGetHandle = nothing
  1050. if IRC = "" then
  1051. Dim objSysDrive,strSysDrive
  1052. Set objSysDrive = server.CreateObject("Scripting.FileSystemObject")
  1053. strSysDrive = objSysDrive.GetSpecialFolder(1).Drive ' 1 for systemfolder,0 for windows folder
  1054. strWebRootDir = strSysDrive & "\" & CONST_DEF_WEBROOT
  1055. else
  1056. strWebRootDir = IRC
  1057. end if
  1058. set objSysDrive = nothing
  1059. GetWebSiteRootVal = CONST_SUCCESS
  1060. End Function
  1061. '-------------------------------------------------------------------------
  1062. 'Function name: GetFTPSiteRootVal
  1063. 'Description: gets the FTP site roor dir
  1064. 'Input Variables: None
  1065. 'Output Variables: strWebRootDir
  1066. 'Returns: error num
  1067. '--------------------------------------------------------------------------
  1068. Function GetFTPSiteRootVal(ByRef strWebRootDir)
  1069. On Error Resume Next
  1070. Err.Clear
  1071. Dim IRC 'holds return value
  1072. Dim objGetHandle 'holds registry connection
  1073. set objGetHandle = RegConnection()
  1074. IRC = ""
  1075. IRC = GetRegKeyValue(objGetHandle,CONST_WEBBLADES_REGKEY,CONST_FTPSITEROOT_REGVAL,CONST_STRING)
  1076. If Err.number <> 0 then
  1077. ' Ignore registry error and use default value.
  1078. IRC = ""
  1079. end if
  1080. set objGetHandle = nothing
  1081. if IRC = "" then
  1082. Dim objSysDrive,strSysDrive
  1083. Set objSysDrive = server.CreateObject("Scripting.FileSystemObject")
  1084. strSysDrive = objSysDrive.GetSpecialFolder(1).Drive ' 1 for systemfolder,0 for windows folder
  1085. strWebRootDir = strSysDrive & "\" & CONST_DEF_FTPROOT
  1086. set objSysDrive = nothing
  1087. else
  1088. strWebRootDir = IRC
  1089. end if
  1090. GetFTPSiteRootVal = CONST_SUCCESS
  1091. End Function
  1092. '----------------------------------------------------------------------------
  1093. 'Function name :CreateSitePath
  1094. 'Description :Create Directory path if not exists
  1095. 'Input Variables :None
  1096. 'Output Variables :None
  1097. 'Returns :Boolean
  1098. 'Global Variables :None
  1099. '----------------------------------------------------------------------------
  1100. Function CreateSitePath(objFso, strRootDir)
  1101. on error resume next
  1102. Err.Clear
  1103. Dim strIndx 'holds index value
  1104. Dim strDriveName 'holds drive name
  1105. Dim strDirStruct 'holds directory path
  1106. Dim strDirList
  1107. Dim strMain
  1108. Dim count
  1109. Dim strEachDir
  1110. Dim strCreateDir
  1111. Dim objDirList
  1112. Dim objDir
  1113. Dim objDriveType
  1114. strIndx = instr(1,strRootDir,":\")
  1115. strDriveName = left(strRootDir,strIndx)
  1116. strDirStruct = mid(strRootDir,strIndx+1)
  1117. strDirList = split(strDirStruct,"\")
  1118. if NOT objFso.DriveExists(ucase(strDriveName)) then
  1119. CreateSitePath = CONST_INVALID_DRIVE
  1120. exit function
  1121. end if
  1122. set objDriveType = objFso.GetDrive(strDriveName)
  1123. if objDriveType.FileSystem <> "NTFS" then
  1124. CreateSitePath = CONST_NOTNTFS_DRIVE
  1125. exit function
  1126. end if
  1127. for count = 0 to UBound(strDirList)
  1128. if count>=UBound(strDirList) then exit for
  1129. if count=0 then
  1130. strMain = strDriveName & "\" & strDirList(count+1)
  1131. if objFso.FolderExists(strMain)=false then
  1132. objFso.CreateFolder(strMain)
  1133. if err.number <> 0 then
  1134. SA_TraceOut "inc_wsa", "CreateSitePath:Failed to create dir " & "(" & Hex(Err.Number) & ")" & Err.Description
  1135. CreateSitePath = CONST_FAILED_TOCREATE_DIR
  1136. Exit Function
  1137. end if
  1138. end if
  1139. else
  1140. strEachDir = strEachDir & "\" & strDirList(count+1)
  1141. strCreateDir = strMain & strEachDir
  1142. if objFso.FolderExists(strCreateDir)=false then
  1143. objFso.CreateFolder(strCreateDir)
  1144. if err.number <> 0 then
  1145. SA_TraceOut "inc_wsa", "CreateSitePath: Failed to create directory " & "(" & Hex(Err.Number) & ")" & Err.Description
  1146. CreateSitePath = CONST_FAILED_TOCREATE_DIR
  1147. Exit Function
  1148. end if
  1149. end if
  1150. end if
  1151. next
  1152. CreateSitePath = CONST_SUCCESS
  1153. end function
  1154. '----------------------------------------------------------------------------
  1155. 'Function name :DelegateOuToSiteAdmin
  1156. 'Description :Delegate Permissions to Site-Identifier_Admins group
  1157. 'Input Variables :strOu, strTrustee
  1158. 'Output Variables :None
  1159. 'Returns :Boolean
  1160. 'Global Variables :None
  1161. '----------------------------------------------------------------------------
  1162. Function DelegateOuToSiteAdmin(strOu, strTrustee)
  1163. On Error Resume Next
  1164. Err.Clear
  1165. Dim strDn 'holds query value
  1166. Dim oRootDSE 'holds root value
  1167. Dim oDelegationOU
  1168. Dim oSecDescriptor
  1169. Dim oAcl
  1170. DelegateOuToSiteAdmin = FALSE
  1171. Set oRootDSE = GetObject("LDAP://RootDSE")
  1172. strDn = "ou=" & strOu & ",ou=WebSites," & oRootDSE.Get("DefaultNamingContext")
  1173. SA_TraceOut "inc_wsa", "strDn=" & strDn
  1174. ' Get the security descriptor from the object
  1175. Set oDelegationOU = GetObject("LDAP://" & strDN)
  1176. Set oSecDescriptor = oDelegationOU.Get("ntSecurityDescriptor")
  1177. Set oAcl = oSecDescriptor.DiscretionaryAcl
  1178. 'Give ability to read this object
  1179. ' Grant a Read permission
  1180. ' Allow Ace
  1181. ' Apply to this object only
  1182. ' ObjectType is not present
  1183. ' No specific class
  1184. ' No children will inherit
  1185. if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_GENERIC_READ, ADS_ACETYPE_ACCESS_ALLOWED, 0, 0, "", "" ) then
  1186. SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1187. exit function
  1188. end if
  1189. 'Give ability to create and delete users
  1190. ' Allow create and delete right
  1191. ' Allow object ace, This applies to this object and children
  1192. ' ObjectType is present
  1193. ' Applies to User object
  1194. ' No children will inherit
  1195. if NOT AddAceToAcl (oAcl, strTrustee, ADS_RIGHT_DS_CREATE_CHILD OR ADS_RIGHT_DS_DELETE_CHILD, _
  1196. ADS_ACETYPE_ACCESS_ALLOWED_OBJECT, ADS_ACEFLAG_INHERIT_ACE, _
  1197. ADS_FLAG_OBJECT_TYPE_PRESENT, USERGUID, "" ) then
  1198. SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1199. exit function
  1200. end if
  1201. 'Give full control over user objects
  1202. ' Grant full control
  1203. ' Allow Ace for an object
  1204. ' This should be applied only to children, not to this object
  1205. ' ObjectType is present
  1206. ' Applies to User class
  1207. ' No children will inherit
  1208. if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_GENERIC_ALL, ADS_ACETYPE_ACCESS_ALLOWED_OBJECT, _
  1209. ADS_ACEFLAG_INHERIT_ACE Or ADS_ACEFLAG_INHERIT_ONLY_ACE, _
  1210. ADS_FLAG_INHERITED_OBJECT_TYPE_PRESENT, "", USERGUID ) then
  1211. SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1212. exit function
  1213. end if
  1214. 'Give ablity to read this OU
  1215. ' Grant a Read
  1216. ' Allow Ace
  1217. ' Apply to this object only
  1218. ' ObjectType is present
  1219. ' This applies to the OU class
  1220. ' No children will inherit
  1221. if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_GENERIC_READ, ADS_ACETYPE_ACCESS_ALLOWED, _
  1222. 0, ADS_FLAG_OBJECT_TYPE_PRESENT, OUGUID, "" ) then
  1223. SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1224. exit function
  1225. end if
  1226. 'Give ability to create and delete group objects
  1227. ' Allow create and delete right
  1228. ' Allow object ace
  1229. ' This applies to this object only
  1230. ' ObjectType is present
  1231. ' Applies to group object
  1232. ' No children will inherit an objectAce
  1233. if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_DS_CREATE_CHILD OR ADS_RIGHT_DS_DELETE_CHILD, _
  1234. ADS_ACETYPE_ACCESS_ALLOWED_OBJECT, ADS_ACEFLAG_INHERIT_ACE, _
  1235. ADS_FLAG_OBJECT_TYPE_PRESENT, GROUPGUID, "" ) then
  1236. SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1237. exit function
  1238. end if
  1239. 'Give full control to group objects
  1240. ' Grant full control
  1241. ' Allow Ace for an object
  1242. ' This should be applied only to children, not to this object
  1243. ' ObjectType is present
  1244. ' Applies to group object
  1245. ' No children will inherit an objectAce
  1246. if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_GENERIC_ALL, ADS_ACETYPE_ACCESS_ALLOWED_OBJECT, _
  1247. ADS_ACEFLAG_INHERIT_ACE Or ADS_ACEFLAG_INHERIT_ONLY_ACE, _
  1248. ADS_FLAG_INHERITED_OBJECT_TYPE_PRESENT, "", GROUPGUID ) then
  1249. SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1250. exit function
  1251. end if
  1252. 'Commit all of the changes to the Active Directory
  1253. oSecDescriptor.DiscretionaryAcl = oAcl
  1254. oDelegationOU.Put "ntSecurityDescriptor", oSecDescriptor
  1255. oDelegationOU.SetInfo
  1256. if Err.Number <> 0 then
  1257. Exit Function
  1258. end if
  1259. DelegateOuToSiteAdmin = TRUE
  1260. End Function
  1261. '=========================================================================================================================
  1262. ' The AddAceToAcl function will create a new Access control entry. It will set the trustee to the global trustee variable
  1263. ' passed into the script. The other attibutes of the ACE are determined by the parameters. The ACE is added to the
  1264. ' global oACL variable.
  1265. '=========================================================================================================================
  1266. Function AddAceToAcl(oAcl, strTrustee, iAccessMask, iAceType, iAceFlags, iFlags, strObjectGUID, strInheritGUID)
  1267. On Error Resume Next
  1268. Err.Clear
  1269. Dim oAce 'As IADsAccessControlEntry
  1270. AddAceToAcl = FALSE
  1271. set oAce = CreateObject("AccessControlEntry")
  1272. if Err.Number <> 0 then
  1273. SA_TraceOut "inc_wsa", "CreateObject AccessControlEntry failed " & "(" & Hex(Err.Number) & ")"
  1274. Exit Function
  1275. end if
  1276. oAce.Trustee = strTrustee
  1277. oAce.AccessMask = iAccessMask
  1278. oAce.AceType = iAceType
  1279. oAce.Flags = iFlags
  1280. oAce.AceFlags = iAceFlags
  1281. If Len(strObjectGUID) > 0 then
  1282. oAce.ObjectType = strObjectGUID
  1283. End If
  1284. If Len(strInheritGUID) > 0 then
  1285. oAce.InheritedObjectType = strInheritGUID
  1286. End If
  1287. oACL.AddAce oAce
  1288. if Err.Number <> 0 then
  1289. SA_TraceOut "inc_wsa", "Add ace to acl failed " & "(" & Hex(Err.Number) & ")"
  1290. Exit Function
  1291. end if
  1292. AddAceToAcl = TRUE
  1293. Set oAce = nothing
  1294. End Function
  1295. '-------------------------------------------------------------------------
  1296. 'Function name :GetNonInheritedSites
  1297. 'Description :Gets all sites that are not Inheriting settings from the master
  1298. 'Input Variables :objService,strClassName,strMasterClassName,arrProp
  1299. 'Output Variables :None
  1300. 'Returns :Boolean
  1301. '-------------------------------------------------------------------------
  1302. Function GetNonInheritedSites(objService,strClassName,strMasterClassName,arrProp)
  1303. On Error Resume Next
  1304. Err.Clear
  1305. Dim strQuery 'holds query string
  1306. Dim objInstances 'holds instance values
  1307. Dim objInst
  1308. Dim count
  1309. Dim strPropCollection 'holds prop collection
  1310. Dim arrMasterPropVal
  1311. Dim strTemp
  1312. Dim arrWebSites 'holds array of web sites
  1313. Dim strManagedSites 'holds managed websites value
  1314. Dim managedCount 'holds managed count value
  1315. redim arrMasterPropVal(ubound(arrProp))
  1316. if strClassName = GetIISWMIProviderClassName("IIS_FTPServerSetting") then
  1317. arrWebSites = getManagedFTPSites
  1318. else
  1319. arrWebSites = getManagedWebSites
  1320. end if
  1321. if arrWebSites = 0 then
  1322. GetNonInheritedSites = 0
  1323. exit function
  1324. end if
  1325. for count =0 to UBound(arrProp)
  1326. strPropCollection = strPropCollection & arrProp(count) & ","
  1327. next
  1328. strPropCollection = left(strPropCollection,len(strPropCollection)-1)
  1329. strQuery = "select " & strPropCollection & " from " & strMasterClassName
  1330. set objInstances = objService.ExecQuery(strQuery)
  1331. for each objInst in objInstances
  1332. for count = 0 to UBound(arrProp)
  1333. if vartype(objInst.Properties_.Item(arrProp(count))) = 11 then '11 for boolean
  1334. 'if the property type is boolean, we cannot convert it to a string directly
  1335. 'string conversion of vbscript is browser preference dependent
  1336. 'we need to convert boolean to english strings(true/false), otherwise wmi query fails
  1337. if objInst.Properties_.Item(arrProp(count)) then
  1338. arrMasterPropVal(count) = "'" & "True" & "'"
  1339. else
  1340. arrMasterPropVal(count) = "'" & "False" & "'"
  1341. end if
  1342. elseif vartype(objInst.Properties_.Item(arrProp(count))) = 8 then '8 for string
  1343. arrMasterPropVal(count) = "'" & objInst.Properties_.Item(arrProp(count)) & "'"
  1344. elseif vartype(objInst.Properties_.Item(arrProp(count))) = 3 then '3 for integer
  1345. arrMasterPropVal(count) = objInst.Properties_.Item(arrProp(count))
  1346. end if
  1347. next
  1348. next
  1349. 'Release objects
  1350. set objInstances = nothing
  1351. for count = 0 to UBound(arrProp)
  1352. strTemp = strTemp & arrProp(count) & " !=" & arrMasterPropVal(count) & " or "
  1353. next
  1354. strTemp = left(strTemp,len(strTemp)-3)
  1355. strTemp = " ( " & strTemp & " ) "
  1356. for managedCount = 0 to UBound(arrWebSites)
  1357. if strClassName = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") then
  1358. strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "/Root' and " & strTemp & " or "
  1359. else
  1360. strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "' and " & strTemp & " or "
  1361. end if
  1362. next
  1363. strManagedSites = left(strManagedSites,len(strManagedSites)-3)
  1364. strQuery = "select * from " & strClassName & " where " & strManagedSites
  1365. set objInstances = objService.ExecQuery(strQuery)
  1366. set GetNonInheritedSites = objInstances
  1367. End Function
  1368. '-------------------------------------------------------------------------
  1369. 'Function name: getManagedWebSites
  1370. 'Description: Returns an array of Managed web sites from reg loc
  1371. ' WebServerAppliance\ManagedWebSites
  1372. 'Input Variables: None
  1373. 'Output Variables:
  1374. 'Returns: returns an array
  1375. 'Global Variables: None
  1376. 'If object fails dislays the error message
  1377. '-------------------------------------------------------------------------
  1378. Function getManagedWebSites()
  1379. On Error Resume Next
  1380. Err.Clear
  1381. Dim Child 'hold child object
  1382. Dim count
  1383. Dim arrWebSites() 'hold array of websites
  1384. Dim objService 'hold WMI Connection object
  1385. Dim siteCollection 'hold site collection
  1386. Dim strQuery 'hold query string
  1387. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  1388. 'form the query
  1389. strQuery = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where ServerID = ServerComment"
  1390. Set siteCollection = objService.ExecQuery(strQuery)',"WQL",48)
  1391. If Err.number <> 0 Then
  1392. SA_ServeFailurepage L_INFORMATION_ERRORMESSAGE
  1393. getObjSiteCollection = false
  1394. exit function
  1395. End If
  1396. if siteCollection.count = 0 then
  1397. getManagedWebSites = 0
  1398. exit function
  1399. end if
  1400. count =0
  1401. For Each Child In siteCollection
  1402. redim preserve arrWebSites(count)
  1403. arrWebSites(count) = Child.Name
  1404. count = count + 1
  1405. Next
  1406. 'use the script managed_site.vbs here
  1407. getManagedWebSites = arrWebSites
  1408. 'Release the object
  1409. set siteCollection = nothing
  1410. set objService = nothing
  1411. End function
  1412. '-------------------------------------------------------------------------
  1413. 'Function name: getManagedFTPSites
  1414. 'Description: Returns an array of Managed FTP sites from reg loc
  1415. ' WebServerAppliance\ManagedWebSites
  1416. 'Input Variables: None
  1417. 'Output Variables:
  1418. 'Returns: returns an array
  1419. 'Global Variables: None
  1420. 'If object fails dislays the error message
  1421. '-------------------------------------------------------------------------
  1422. Function getManagedFTPSites()
  1423. On Error Resume Next
  1424. Err.Clear
  1425. Dim Child
  1426. Dim count
  1427. Dim arrFTPSites() 'holds array of FTP sites
  1428. Dim objService
  1429. Dim siteCollection
  1430. Dim strQuery
  1431. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  1432. 'form the query
  1433. strQuery = "select * from " & GetIISWMIProviderClassName("IIs_FTPServerSetting")
  1434. Set siteCollection = objService.ExecQuery(strQuery)
  1435. If Err.number <> 0 Then
  1436. SA_ServeFailurepage L_INFORMATION_ERRORMESSAGE
  1437. getObjSiteCollection = false
  1438. exit function
  1439. End If
  1440. if siteCollection.count = 0 then
  1441. getManagedFTPSites = 0
  1442. exit function
  1443. end if
  1444. count =0
  1445. For Each Child In siteCollection
  1446. redim preserve arrFTPSites(count)
  1447. arrFTPSites(count) = Child.Name
  1448. count = count + 1
  1449. Next
  1450. getManagedFTPSites = arrFTPSites
  1451. 'Release objects
  1452. set objService = nothing
  1453. set siteCollection = nothing
  1454. End function
  1455. '-------------------------------------------------------------------------
  1456. 'Function name :SetDaclForFtpDir
  1457. 'Description :Sets DACL entries for FTP directory
  1458. 'Input Variables :bAllowFTP, strDir, AdminName, AnonName, FTPName, strDirRoot
  1459. 'Output Variables :None
  1460. 'Returns :Boolean
  1461. '-------------------------------------------------------------------------
  1462. Function SetDaclForFtpDir(bAllowFTP, strDir, strAdminName, strAnonName, strFTPName, strDirRoot)
  1463. On Error Resume Next
  1464. Err.Clear
  1465. SetDaclForFtpDir = FALSE
  1466. Dim objService 'holds WMI Connection
  1467. Dim strTemp
  1468. Dim objSecSetting
  1469. Dim objSecDescriptor 'holds Security descriptor value
  1470. Dim strPath 'holds path
  1471. Dim objDACL
  1472. Dim objSiteAdminAce 'holds site admin ace
  1473. Dim objAdminAce 'holds admin ace
  1474. Dim objAnonAce 'holds anon ace
  1475. Dim objAuthAce 'holds auth ace
  1476. Dim objFTPAce 'hold FTP ace
  1477. Dim retval 'holds return value
  1478. Set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  1479. objService.security_.impersonationlevel = 3
  1480. 'get the sec seting for file
  1481. strPath = "Win32_LogicalFileSecuritySetting.Path='" & strDir & "'"
  1482. set objSecSetting = objService.Get(strPath)
  1483. if Err.number <> 0 then
  1484. SA_TraceOut "inc_wsa", "Failed to get Sec object for dir " & "(" & Hex(Err.Number) & ")"
  1485. exit function
  1486. end if
  1487. 'get the ace's for all req users
  1488. if NOT GetUserAce(objService, strAdminName , strDirRoot, CONST_FULLCONROL, objSiteAdminAce ) then
  1489. SA_TraceOut "inc_wsa", "Failed to get ACE object for Site Admin user " & "(" & Hex(Err.Number) & ")"
  1490. exit function
  1491. end if
  1492. if NOT GetUserAce(objService, SA_GetAccount_Administrator() , strDirRoot, CONST_FULLCONROL, objAdminAce ) then
  1493. SA_TraceOut "inc_wsa", "Failed to get ACE object for Admin user " & "(" & Hex(Err.Number) & ")"
  1494. exit function
  1495. end if
  1496. if NOT GetUserAce(objService, strAnonName, strDirRoot, CONST_MODIFYDELTE, objAnonAce ) then
  1497. SA_TraceOut "inc_wsa", "Failed to get ACE object for Anon user " & "(" & Hex(Err.Number) & ")"
  1498. exit function
  1499. end if
  1500. if bAllowFTP = "true" then
  1501. if NOT GetUserAce(objService, strFTPName, strDirRoot, CONST_MODIFYDELTE, objFTPAce ) then
  1502. SA_TraceOut "inc_wsa", "Failed to get ACE object for Anon user " & "(" & Hex(Err.Number) & ")"
  1503. exit function
  1504. end if
  1505. end if
  1506. Set objSecDescriptor = objService.Get("Win32_SecurityDescriptor").SpawnInstance_()
  1507. if Err.Number <> 0 then
  1508. SA_TraceOut "inc_wsa", "Failed to get create the Win32_SecurityDescriptor object " & "(" & Hex(Err.Number) & ")"
  1509. exit function
  1510. end if
  1511. objSecDescriptor.Properties_.Item("DACL") = Array()
  1512. Set objDACL = objSecDescriptor.Properties_.Item("DACL")
  1513. objDACL.Value(0) = objSiteAdminAce
  1514. objDACL.Value(1) = objAdminAce
  1515. objDACL.Value(2) = objAnonAce
  1516. if bAllowFTP = "true" then
  1517. objDACL.Value(3) = objFTPAce
  1518. end if
  1519. objSecDescriptor.Properties_.Item("ControlFlags") = 32772
  1520. Set objSecDescriptor.Properties_.Item("Owner") = objSiteAdminAce.Trustee
  1521. Err.Clear
  1522. retval = objSecSetting.SetSecurityDescriptor( objSecDescriptor )
  1523. if Err.number <> 0 then
  1524. SA_TraceOut "site_new", "Failed to set the Security Descriptor for Root dir " & "(" & Hex(Err.Number) & ")"
  1525. exit function
  1526. end if
  1527. SA_TraceOut "site_new", "In SetDaclForFtpDir success"
  1528. SetDaclForFtpDir = TRUE
  1529. 'Release the objects
  1530. set objService = nothing
  1531. set objAdminAce = nothing
  1532. set objAnonAce = nothing
  1533. set objAuthAce = nothing
  1534. set objSecSetting = nothing
  1535. set objSecDescriptor = nothing
  1536. End function
  1537. '-------------------------------------------------------------------------
  1538. 'Function name :RemoveDaclEntry
  1539. 'Description :Removes the DACL entry
  1540. 'Input Variables :strDir, strDirRoot
  1541. 'Output Variables :None
  1542. 'Returns :Boolean
  1543. '-------------------------------------------------------------------------
  1544. Function RemoveDaclEntry(strDir, strDirRoot)
  1545. On Error Resume Next
  1546. Err.Clear
  1547. RemoveDaclEntry = FALSE
  1548. Dim objService
  1549. Dim objSecSetting 'hold sec setting value
  1550. Dim objSecDescriptor 'hold security descriptor value
  1551. Dim strPath
  1552. Dim objDACL
  1553. Dim objSiteAdminAce 'hold admin ace
  1554. Dim retval 'holds return value
  1555. Set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  1556. objService.security_.impersonationlevel = 3
  1557. 'get the sec setting for file
  1558. strPath = "Win32_LogicalFileSecuritySetting.Path='" & strDir & "'"
  1559. set objSecSetting = objService.Get(strPath)
  1560. if Err.number <> 0 then
  1561. SA_TraceOut "inc_wsa", "Failed to get Sec object for dir " & "(" & Hex(Err.Number) & ")"
  1562. exit function
  1563. end if
  1564. 'get the ace's for all req users
  1565. if NOT GetUserAce(objService, SA_GetAccount_Administrators() , strDirRoot, CONST_FULLCONROL, objSiteAdminAce ) then
  1566. SA_TraceOut "inc_wsa", "Failed to get ACE object for Administrators " & "(" & Hex(Err.Number) & ")"
  1567. exit function
  1568. end if
  1569. Set objSecDescriptor = objService.Get("Win32_SecurityDescriptor").SpawnInstance_()
  1570. if Err.Number <> 0 then
  1571. SA_TraceOut "inc_wsa", "Failed to get create the Win32_SecurityDescriptor object " & "(" & Hex(Err.Number) & ")"
  1572. exit function
  1573. end if
  1574. objSecDescriptor.Properties_.Item("DACL") = Array()
  1575. Set objDACL = objSecDescriptor.Properties_.Item("DACL")
  1576. objDACL.Value(0) = objSiteAdminAce
  1577. objSecDescriptor.Properties_.Item("ControlFlags") = 32772
  1578. Set objSecDescriptor.Properties_.Item("Owner") = objSiteAdminAce.Trustee
  1579. Err.Clear
  1580. retval = objSecSetting.SetSecurityDescriptor( objSecDescriptor )
  1581. if Err.number <> 0 then
  1582. SA_TraceOut "site_Delete", "Failed to set the Security Descriptor for Root dir " & "(" & Hex(Err.Number) & ")"
  1583. exit function
  1584. end if
  1585. SA_TraceOut "site_Delete", "In RemoveDaclEntry success"
  1586. RemoveDaclEntry = TRUE
  1587. 'Release the objects
  1588. set objService = nothing
  1589. set objSecSetting = nothing
  1590. set objSecDescriptor = nothing
  1591. set objSiteAdminAce = nothing
  1592. End function
  1593. '-------------------------------------------------------------------------
  1594. 'Function name: SetExecPerms
  1595. 'Description: Sets Execute permissions for the web site
  1596. 'Input Variables: objService, strSiteNum
  1597. 'Returns: boolean
  1598. '--------------------------------------------------------------------------
  1599. Function SetExecPerms(ActiveFormat, objService, strSiteNum)
  1600. On Error Resume Next
  1601. Err.Clear
  1602. Dim strObjPath 'holds objpath value
  1603. Dim objVirDir 'hold virtualdirectory path
  1604. SetExecPerms = FALSE
  1605. 'set application protection
  1606. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  1607. set objVirDir = objService.Get( strObjPath )
  1608. If Err.number <> 0 Then
  1609. SA_TraceOut "inc_wsa", "get vir dir object failed " & Hex(Err.Number)
  1610. exit Function
  1611. End if
  1612. 'call the method to set the application Read property
  1613. if ActiveFormat = 2 then
  1614. objVirDir.AccessExecute = TRUE
  1615. objVirDir.AccessScript = TRUE
  1616. elseif ActiveFormat = 1 then
  1617. objVirDir.AccessExecute = FALSE
  1618. objVirDir.AccessScript = TRUE
  1619. elseif ActiveFormat = 0 then
  1620. objVirDir.AccessExecute = FALSE
  1621. objVirDir.AccessScript = FALSE
  1622. end if
  1623. objVirDir.put_(WBEMFLAG)
  1624. if Err.number <> 0 then
  1625. SA_TraceOut "Web_ExecutePerms", "Failed to set exec perms" & "(" & Hex(Err.Number) & ")"
  1626. exit function
  1627. end if
  1628. SetExecPerms = TRUE
  1629. 'Release the object
  1630. set objVirDir = nothing
  1631. End Function
  1632. '------------------------------------------------------------------------------------
  1633. 'Function name :GetNonInheritedIISSites
  1634. 'Description :Gets all sites that are not Inheriting settings from the master
  1635. 'Input Variables :objService,strClassName,strMasterClassName,arrProp
  1636. 'Output Variables :None
  1637. 'Returns :Boolean
  1638. '-------------------------------------------------------------------------------------
  1639. Function GetNonInheritedIISSites(objService,strClassName,strMasterClassName,arrProp)
  1640. On Error Resume Next
  1641. Err.Clear
  1642. Dim strQuery 'holds query value
  1643. Dim objInstances
  1644. Dim objInst
  1645. Dim count
  1646. Dim strPropCollection
  1647. Dim arrMasterPropVal
  1648. Dim strTemp
  1649. Dim arrWebSites()
  1650. Dim strManagedSites
  1651. Dim managedCount
  1652. Dim siteCollection
  1653. Dim Child
  1654. strQuery = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where ServerID = ServerComment"
  1655. Set siteCollection = objService.ExecQuery(strQuery)
  1656. If Err.number <> 0 or siteCollection.count=0 Then
  1657. GetNonInheritedIISSites = 0
  1658. exit function
  1659. End If
  1660. count =0
  1661. For Each Child In siteCollection
  1662. redim preserve arrWebSites(count)
  1663. arrWebSites(count) = Child.Name
  1664. count = count + 1
  1665. Next
  1666. redim arrMasterPropVal(ubound(arrProp))
  1667. for count =0 to UBound(arrProp)
  1668. strPropCollection = strPropCollection & arrProp(count) & ","
  1669. next
  1670. strPropCollection = left(strPropCollection,len(strPropCollection)-1)
  1671. strQuery = "select " & strPropCollection & " from " & strMasterClassName
  1672. set objInstances = objService.ExecQuery(strQuery)
  1673. for each objInst in objInstances
  1674. for count = 0 to UBound(arrProp)
  1675. if vartype(objInst.Properties_.Item(arrProp(count))) = 11 then '11 for boolean
  1676. 'if the property type is boolean, we cannot convert it to a string directly
  1677. 'string conversion of vbscript is browser preference dependent
  1678. 'we need to convert boolean to english strings(true/false), otherwise wmi query fails
  1679. if objInst.Properties_.Item(arrProp(count)) then
  1680. arrMasterPropVal(count) = "'" & "True" & "'"
  1681. else
  1682. arrMasterPropVal(count) = "'" & "False" & "'"
  1683. end if
  1684. elseif vartype(objInst.Properties_.Item(arrProp(count))) = 8 then '8 for string
  1685. arrMasterPropVal(count) = "'" & objInst.Properties_.Item(arrProp(count)) & "'"
  1686. elseif vartype(objInst.Properties_.Item(arrProp(count))) = 3 then '3 for integer
  1687. arrMasterPropVal(count) = objInst.Properties_.Item(arrProp(count))
  1688. end if
  1689. next
  1690. next
  1691. 'Release objects
  1692. set objInstances = nothing
  1693. for count = 0 to UBound(arrProp)
  1694. strTemp = strTemp & arrProp(count) & " !=" & arrMasterPropVal(count) & " or "
  1695. next
  1696. strTemp = left(strTemp,len(strTemp)-3)
  1697. strTemp = " ( " & strTemp & " ) "
  1698. for managedCount = 0 to UBound(arrWebSites)
  1699. if strClassName = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") then
  1700. strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "/Root' and " & strTemp & " or "
  1701. else
  1702. strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "' and " & strTemp & " or "
  1703. end if
  1704. next
  1705. strManagedSites = left(strManagedSites,len(strManagedSites)-3)
  1706. strQuery = "select * from " & strClassName & " where " & strManagedSites
  1707. set objInstances = objService.ExecQuery(strQuery)
  1708. set GetNonInheritedIISSites = objInstances
  1709. End Function
  1710. '------------------------------------------------------------------------------------
  1711. 'Function name :GetNonInheritedFTPSites
  1712. 'Description :Gets all sites that are not Inheriting settings from the master
  1713. 'Input Variables :objService,strClassName,strMasterClassName,arrProp
  1714. 'Output Variables :None
  1715. 'Returns :Boolean
  1716. '-------------------------------------------------------------------------------------
  1717. Function GetNonInheritedFTPSites(objService,strClassName,strMasterClassName,arrProp)
  1718. On error Resume Next
  1719. Err.Clear
  1720. Dim strQuery
  1721. Dim objInstances
  1722. Dim objInst
  1723. Dim count
  1724. Dim strPropCollection 'holds prop collection
  1725. Dim arrMasterPropVal
  1726. Dim strTemp
  1727. Dim arrWebSites() 'holds array websites collection
  1728. Dim strManagedSites 'holds managed webites collection
  1729. Dim managedCount
  1730. Dim siteCollection
  1731. Dim Child
  1732. strQuery = "select * from " & GetIISWMIProviderClassName("IIs_FTPServerSetting")
  1733. Set siteCollection = objService.ExecQuery(strQuery)
  1734. If Err.number <> 0 or siteCollection.count=0 Then
  1735. GetNonInheritedFTPSites = 0
  1736. exit function
  1737. End If
  1738. count =0
  1739. For Each Child In siteCollection
  1740. redim preserve arrWebSites(count)
  1741. arrWebSites(count) = Child.Name
  1742. count = count + 1
  1743. Next
  1744. redim arrMasterPropVal(ubound(arrProp))
  1745. for count =0 to UBound(arrProp)
  1746. strPropCollection = strPropCollection & arrProp(count) & ","
  1747. next
  1748. strPropCollection = left(strPropCollection,len(strPropCollection)-1)
  1749. strQuery = "select " & strPropCollection & " from " & strMasterClassName
  1750. set objInstances = objService.ExecQuery(strQuery)
  1751. for each objInst in objInstances
  1752. for count = 0 to UBound(arrProp)
  1753. if vartype(objInst.Properties_.Item(arrProp(count))) = 11 then '11 for boolean
  1754. 'if the property type is boolean, we cannot convert it to a string directly
  1755. 'string conversion of vbscript is browser preference dependent
  1756. 'we need to convert boolean to english strings(true/false), otherwise wmi query fails
  1757. if objInst.Properties_.Item(arrProp(count)) then
  1758. arrMasterPropVal(count) = "'" & "True" & "'"
  1759. else
  1760. arrMasterPropVal(count) = "'" & "False" & "'"
  1761. end if
  1762. elseif vartype(objInst.Properties_.Item(arrProp(count))) = 8 then '8 for string
  1763. arrMasterPropVal(count) = "'" & objInst.Properties_.Item(arrProp(count)) & "'"
  1764. elseif vartype(objInst.Properties_.Item(arrProp(count))) = 3 then '3 for integer
  1765. arrMasterPropVal(count) = objInst.Properties_.Item(arrProp(count))
  1766. end if
  1767. next
  1768. next
  1769. 'Release objects
  1770. set objInstances = nothing
  1771. for count = 0 to UBound(arrProp)
  1772. ' Must handle null values in the WMI master service object to prevent invalid
  1773. ' queries from causing errors even when non-inherited sites existed.
  1774. if (not IsNull(arrMasterPropVal(count))) then
  1775. strTemp = strTemp & arrProp(count) & " !=" & arrMasterPropVal(count) & " or "
  1776. else
  1777. strTemp = strTemp & arrProp(count) & " IS NOT NULL or "
  1778. end if
  1779. next
  1780. strTemp = left(strTemp,len(strTemp)-3)
  1781. strTemp = " ( " & strTemp & " ) "
  1782. for managedCount = 0 to UBound(arrWebSites)
  1783. if strClassName = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") then
  1784. strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "/Root' and " & strTemp & " or "
  1785. else
  1786. strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "' and " & strTemp & " or "
  1787. end if
  1788. next
  1789. strManagedSites = left(strManagedSites,len(strManagedSites)-3)
  1790. strQuery = "select * from " & strClassName & " where " & strManagedSites
  1791. ' "WQL" and 0 parameters used to get error information immediately rather than
  1792. ' when first accessing the results.
  1793. set objInstances = objService.ExecQuery(strQuery, "WQL", 0)
  1794. set GetNonInheritedFTPSites = objInstances
  1795. End Function
  1796. '------------------------------------------------------------------------------------
  1797. 'Function name :GetDomainName
  1798. 'Description :Function to get the domain name
  1799. 'Input Variables :none
  1800. 'Output Variables :None
  1801. 'Returns :String -domain name
  1802. '-------------------------------------------------------------------------------------
  1803. Function GetDomainName
  1804. Err.clear
  1805. On Error Resume Next
  1806. Dim objSystem
  1807. Set objSystem = CreateObject("WinntSystemInfo")
  1808. GetDomainName = objSystem.domainname
  1809. 'Checking for the error condition
  1810. If Err.number <> 0 then
  1811. GetDomainName = ""
  1812. end IF
  1813. End function
  1814. '-------------------------------------------------------------------------
  1815. 'Function name :SetWebDefaultPage
  1816. 'Description :set the default page of web
  1817. 'Input Variables :strDefaultPage
  1818. 'Output Variables :None
  1819. 'Returns :Boolean
  1820. 'Global Variables :None
  1821. '-------------------------------------------------------------------------
  1822. Function SetWebDefaultPage(objService,strDefaultPage,strSiteNum)
  1823. On Error Resume Next
  1824. Err.Clear
  1825. Dim strObjPath
  1826. Dim objWebSite
  1827. SetWebDefaultPage = False
  1828. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  1829. Set objWebSite = objService.Get(strObjPath)
  1830. If Err.number <> 0 Then
  1831. SA_TraceOut "site_new", "Failed to get the IIs_WebServer Object with error " & strObjPath
  1832. Exit Function
  1833. End if
  1834. objWebSite.DefaultDoc = strDefaultPage
  1835. objWebSite.put_(WBEMFLAG)
  1836. If Err.number <> 0 Then
  1837. SA_TraceOut "inc_wsa", "Failed to set default Page"
  1838. Set objWebSite = Nothing
  1839. Exit Function
  1840. End If
  1841. SetWebDefaultPage = True
  1842. Set objWebSite = Nothing
  1843. End Function
  1844. '-------------------------------------------------------------------------
  1845. 'Function name :GetWebDefaultPage
  1846. 'Description :get the default page of web
  1847. 'Input Variables :strDefaultPage
  1848. 'Output Variables :None
  1849. 'Returns :Boolean
  1850. 'Global Variables :None
  1851. '-------------------------------------------------------------------------
  1852. Function GetWebDefaultPage(objService,strDefaultPage,strSiteNum)
  1853. On Error Resume Next
  1854. Err.Clear
  1855. Dim strObjPath
  1856. Dim objWebSite
  1857. GetWebDefaultPage = ""
  1858. strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  1859. Set objWebSite = objService.Get(strObjPath)
  1860. If Err.number <> 0 Then
  1861. SA_TraceOut "site_new", "Failed to get the IIs_WebServer Object with error " & strObjPath
  1862. Exit Function
  1863. End if
  1864. GetWebDefaultPage = objWebSite.DefaultDoc
  1865. If Err.number <> 0 Then
  1866. SA_TraceOut "inc_wsa", "Failed to get default Page"
  1867. Set objWebSite = Nothing
  1868. Exit Function
  1869. End If
  1870. Set objWebSite = Nothing
  1871. End Function
  1872. '-------------------------------------------------------------------------
  1873. 'Function name :UpdateFrontPage
  1874. 'Description :updates the frontpage extensions
  1875. 'Input Variables :strSiteName
  1876. 'Output Variables :None
  1877. 'Returns :Boolean
  1878. 'Global Variables :None
  1879. '-------------------------------------------------------------------------
  1880. Function UpdateFrontPage(bUpdateFront, strSiteName, strUserName)
  1881. On Error Resume Next
  1882. Err.Clear
  1883. '
  1884. ' Default return value is success (TRUE)
  1885. UpdateFrontPage = TRUE
  1886. if (bUpdateFront = TRUE OR Trim(UCase(bUpdateFront)) = "TRUE") then
  1887. UpdateFrontPage = InstallFrontPageWeb(strSiteName, strUserName)
  1888. elseif (bUpdateFront = FALSE OR Trim(UCase(bUpdateFront)) = "FALSE") then
  1889. UpdateFrontPage = UnInstallFrontPageWeb(strSiteName)
  1890. else
  1891. Call SA_TraceOut("INC_WSA", "Function UpdateFrontPage: Invalid argument bUpdateFront=(" & bUpdateFront & ")")
  1892. end if
  1893. End function
  1894. '----------------------------------------------------------------------------
  1895. 'Function name :GetBindings
  1896. 'Description :Serves in Getting the data in the form of "ipaddress:tcpport:hostheader"
  1897. 'Input Variables :TCP/IP,PORT,HOST HEADER
  1898. 'Output Variables :None
  1899. 'Returns :Bindings
  1900. 'Global Variables :None
  1901. '----------------------------------------------------------------------------
  1902. function GetBindings (tempip, temptcp, temphost )
  1903. Err.Clear
  1904. On Error Resume Next
  1905. Dim retval ' To hold the return value
  1906. ' if tcpport not specified set default to 80
  1907. if trim(temptcp)= "" then
  1908. temptcp = "80"
  1909. end if
  1910. ' return in the form "ipaddress:tcpport:hostheader"
  1911. if isempty(tempip) = false then
  1912. retval = tempip & ":" & temptcp & ":"
  1913. else
  1914. retval = ":" & temptcp & ":"
  1915. end if
  1916. if isempty(temphost) = false then
  1917. retval = retval & temphost
  1918. end if
  1919. GetBindings = retval
  1920. end function
  1921. '----------------------------------------------------------------------------
  1922. 'Function name :GetWebAdministrtorRole
  1923. 'Description :used to get the web adminitrator role
  1924. 'Input Variables :TCP/IP,PORT,HOST HEADER
  1925. 'Output Variables :None
  1926. 'Returns :"Domain user" or "localuser"
  1927. 'Global Variables :None
  1928. '----------------------------------------------------------------------------
  1929. Function GetWebAdministrtorRole(objService, strSiteNum, ByRef strAdminName)
  1930. On Error Resume Next
  1931. Err.Clear
  1932. Dim strQuery
  1933. Dim objAdminColection
  1934. Dim inst
  1935. Dim strAdminRole
  1936. Dim arrField
  1937. Dim strSysName
  1938. Dim strDirectoryRoot
  1939. GetWebAdministrtorRole = ""
  1940. strAdminName = ""
  1941. strQuery = "select * from " & GetIISWMIProviderClassName("IIs_ACE") & " where name = "& _
  1942. chr(34)&strSiteNum&chr(34)
  1943. Set objAdminColection = objService.ExecQuery(strQuery)
  1944. If Err.number <> 0 Then
  1945. SA_TraceOut "Failed to get web Administrator"
  1946. exit Function
  1947. End if
  1948. For each inst in objAdminColection
  1949. If inst.AccessMask = 11 Then
  1950. strAdminName = inst.Trustee
  1951. Exit For
  1952. End If
  1953. Next
  1954. If strAdminName = "" Then
  1955. Exit Function
  1956. End If
  1957. arrField = split(strAdminName,"\")
  1958. If ubound(arrField) <> 1 Then
  1959. Exit Function
  1960. End If
  1961. strAdminRole = ucase(arrField(0))
  1962. Call GetDomainRole(strDirectoryRoot, strSysName)
  1963. If strAdminRole = ucase(strSysName) Then
  1964. GetWebAdministrtorRole = "Local User"
  1965. Else
  1966. GetWebAdministrtorRole = "Domain User"
  1967. End If
  1968. Set objAdminColection = nothing
  1969. Set inst = nothing
  1970. End Function
  1971. '----------------------------------------------------------------------------
  1972. 'Function name :CreateVirFTPSite
  1973. 'Description :Serves in create virtual ftp site
  1974. 'Input Variables :None
  1975. 'Output Variables :None
  1976. 'Returns :Boolean (True if new site is created else returns False)
  1977. 'Global Variables :None
  1978. 'Functions Used :
  1979. '----------------------------------------------------------------------------
  1980. Function CreateVirFTPSite(objService, user, path, bRead, bWrite, bLog)
  1981. On Error Resume Next
  1982. Err.Clear
  1983. Dim objVirFTP
  1984. Dim strUser
  1985. CreateVirFTPSite = False
  1986. Set objVirFTP = objService.Get(GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting")).SpawnInstance_
  1987. If Err.number <> 0 Then
  1988. Call SA_TraceOut("inc_wsa", "Failed to get new Instance of "& _
  1989. "IIs_FtpVirtualDirSetting " & "(" & Hex(Err.Number) & ")")
  1990. Exit Function
  1991. End If
  1992. '
  1993. ' objVirFTP.put_(WBEMFLAG) will silently fail (Err variable will not be set correctly)
  1994. ' if we use a user name that has the form <DomainName>\<UserName>.
  1995. ' So we remove the <DomainName>, if it is part of the user name
  1996. '
  1997. If ( InStr(F_strAdminName, "\") <> 0 ) Then
  1998. Dim arrId
  1999. arrId = split(F_strAdminName,"\")
  2000. strUser = arrId(1)
  2001. Else
  2002. strUser = F_strAdminName
  2003. End If
  2004. objVirFTP.Name = GetAdminFTPServerName() & "/ROOT/"& strUser
  2005. objVirFTP.Path = path
  2006. objVirFTP.AccessRead = bRead
  2007. objVirFTP.AccessWrite = bWrite
  2008. objVirFTP.DontLog = NOT bLog
  2009. objVirFTP.put_(WBEMFLAG)
  2010. If Err.number <> 0 Then
  2011. Call SA_TraceOut("inc_wsa", "Failed to Create FTP site "& _
  2012. "(" & Hex(Err.Number) & ")")
  2013. Exit Function
  2014. End If
  2015. Set objVirFTP = Nothing
  2016. CreateVirFTPSite = True
  2017. End Function
  2018. '----------------------------------------------------------------------------
  2019. 'Function name :DeleteVirFTPSite
  2020. 'Description :Serves in delete virtual ftp site
  2021. 'Input Variables :None
  2022. 'Output Variables :None
  2023. 'Returns :Boolean (True if new site is created else returns False)
  2024. 'Global Variables :None
  2025. 'Functions Used :
  2026. '----------------------------------------------------------------------------
  2027. Function DeleteVirFTPSite(objService, user)
  2028. On Error Resume Next
  2029. Err.Clear
  2030. Dim strObjPath 'holds site collection
  2031. Dim objVirFTPSite 'holds instance of the site
  2032. DeleteVirFTPSite = False
  2033. strObjPath = GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting") & ".Name=" & chr(34) & GetAdminFTPServerName() & "/ROOT/"&user & chr(34)
  2034. Set objVirFTPSite = objService.Get(strObjPath)
  2035. If Err.Number <> 0 Then
  2036. Call SA_TraceOut("inc_wsa","Unable to get the virtual ftp site object ")
  2037. Exit Function
  2038. End If
  2039. 'delete the object
  2040. objVirFTPSite.Delete_
  2041. if Err.Number <> 0 then
  2042. SA_TraceOut "inc_wsa", "Unable to delete the virtual ftp site "
  2043. Exit Function
  2044. End If
  2045. DeleteVirFTPSite = True
  2046. 'Release the object
  2047. set objVirFTPSite = nothing
  2048. End Function
  2049. '----------------------------------------------------------------------------
  2050. 'Function name :IsUserVirFTPInstalled
  2051. 'Description :Serves in determin that user vir FTP Installed
  2052. 'Input Variables :None
  2053. 'Output Variables :None
  2054. 'Returns :Boolean (True if new site is created else returns False)
  2055. 'Global Variables :None
  2056. 'Functions Used :
  2057. '----------------------------------------------------------------------------
  2058. Function IsUserVirFTPInstalled(objService, user)
  2059. On Error Resume Next
  2060. Err.Clear
  2061. Dim strQuery 'holds query string
  2062. Dim objVirFTPSiteCollect 'holds site collection
  2063. IsUserVirFTPInstalled = False
  2064. 'strQuery = "Select * from " & GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting") & " where Name="&chr(34)&"MSFTPSVC/1/ROOT/"&user&chr(34)
  2065. strQuery = "Select * from " & GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting") & " where Name="&chr(34)& GetAdminFTPServerName() & "/ROOT/"&user&chr(34)
  2066. Set objVirFTPSiteCollect = objService.ExecQuery(strQuery)
  2067. If Err.Number <> 0 or objVirFTPSiteCollect.count=0 Then
  2068. set objVirFTPSiteCollect = nothing
  2069. Exit Function
  2070. End If
  2071. IsUserVirFTPInstalled = True
  2072. 'Release the object
  2073. set objVirFTPSiteCollect = nothing
  2074. End Function
  2075. '----------------------------------------------------------------------------
  2076. 'Function name :IsFTPServiceInstalled
  2077. 'Description :Serves in wheather the FTP service be installed
  2078. 'Input Variables :None
  2079. 'Output Variables :None
  2080. 'Returns :Boolean (True if new site is created else returns False)
  2081. 'Global Variables :None
  2082. 'Functions Used :
  2083. '----------------------------------------------------------------------------
  2084. Function IsFTPServiceInstalled(objService)
  2085. On Error Resume Next
  2086. Err.Clear
  2087. Dim ObjCollection
  2088. Dim objInst
  2089. IsFTPServiceInstalled = False
  2090. Set ObjCollection = objService.Instancesof(GetIISWMIProviderClassName("IIs_FtpServiceSetting"))
  2091. If Err.number <>0 then
  2092. Call SA_TRACEOUT("IsFTPServiceInstalled","Failed to get service")
  2093. Exit Function
  2094. end if
  2095. For Each objInst In ObjCollection
  2096. If ucase(objService.name) = "objInst" Then
  2097. IsFTPServiceInstalled = True
  2098. Exit Function
  2099. End If
  2100. Next
  2101. Set ObjCollection = Nothing
  2102. Set objInst = Nothing
  2103. End Function
  2104. '----------------------------------------------------------------------------
  2105. 'Function name :IsValidWebPort(strSiteID,strPort)
  2106. 'Description :Used to determin wheather the web port is valid
  2107. 'Input Variables :None
  2108. 'Output Variables :None
  2109. 'Returns :Boolean (True for valid web port)
  2110. 'Global Variables :None
  2111. 'Functions Used :
  2112. '----------------------------------------------------------------------------
  2113. Function IsValidWebPort(strSiteID, strPort)
  2114. On Error Resume Next
  2115. Err.Clear
  2116. Dim objService
  2117. Dim objCollection
  2118. Dim objSite
  2119. Dim arrBindings
  2120. Dim strTmp
  2121. IsValidWebPort = True
  2122. If strPort = "" Then
  2123. strPort = "80"
  2124. End If
  2125. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  2126. If Err.Number <> 0 Then
  2127. Call SA_TRACEOUT("inc_wsa","Faild to connect WMI object")
  2128. End If
  2129. Set ObjCollection = objService.Instancesof(GetIISWMIProviderClassName("IIs_WebServerSetting"))
  2130. For Each objSite In ObjCollection
  2131. 'Check to see if iis6.0 wmi provider is intalled
  2132. If IsIIS60Installed Then
  2133. strTmp = objSite.ServerBindings(0).Port
  2134. Else
  2135. arrBindings = Split(objSite.ServerBindings(0),":")
  2136. strTmp = arrBindings(1)
  2137. End If
  2138. If strPort = strTmp Then
  2139. Call SA_TRACEOUT("IsValidWebPort", "strSiteID="&strSiteID)
  2140. Call SA_TRACEOUT("IsValidWebPort", "objSite.ServerID="&objSite.ServerID)
  2141. If CStr(objSite.ServerID) <> strSiteID Then
  2142. IsValidWebPort = False
  2143. Exit Function
  2144. End If
  2145. End If
  2146. Next
  2147. Set objSite = Nothing
  2148. Set ObjCollection = Nothing
  2149. Set objService = Nothing
  2150. End Function
  2151. '
  2152. ' The following two function is very useful to set the permissiton to
  2153. ' directory, when set the web root permission, we call these function
  2154. '
  2155. '-------------------------------------------------------------------------
  2156. 'Function name: GetUserAce
  2157. 'Description: Get the ACLs of the user
  2158. 'Input Variables: objService, strUserName, strDomain, nAccessMask, ByRef objACE
  2159. 'Returns: boolean
  2160. '--------------------------------------------------------------------------
  2161. Function GetUserAce(objService, strUserName, strDomain, nAccessMask, ByRef objACE)
  2162. On Error Resume Next
  2163. Err.Clear
  2164. Dim strObjPath 'holds query string
  2165. Dim objAcct 'holds query result
  2166. Dim objSID 'holds security identifier
  2167. Dim objTrustee 'holds trustee value
  2168. GetUserAce = FALSE
  2169. strObjPath = "Win32_UserAccount.Domain=" & chr(34) & strDomain & chr(34) & ",Name=" & chr(34) & strUserName & chr(34)
  2170. set objAcct = objService.Get(strObjPath)
  2171. if Err.number <> 0 then
  2172. SA_TraceOut "inc_wsa", "Failed to get Win32_UserAccount Object " & "(" & Hex(Err.Number) & ")"
  2173. exit function
  2174. end if
  2175. set objSID = objService.Get("Win32_SID.SID='" & objAcct.SID & "'")
  2176. if Err.number <> 0 then
  2177. SA_TraceOut "inc_wsa", "Failed to get Win32_SID Object " & "(" & Hex(Err.Number) & ")"
  2178. exit function
  2179. end if
  2180. set objTrustee = objService.Get("Win32_Trustee").SpawnInstance_
  2181. if Err.number <> 0 then
  2182. SA_TraceOut "inc_wsa", "Failed to get new Instance of Win32_Trustee " & "(" & Hex(Err.Number) & ")"
  2183. exit function
  2184. end if
  2185. objTrustee.Name = strUserName
  2186. objTrustee.Domain = strDomain
  2187. objTrustee.SID = objSID.BinaryRepresentation
  2188. objTrustee.SIDString = objSID.SID
  2189. objTrustee.SidLength = objSID.SidLength
  2190. set objACE = objService.Get("Win32_ACE").SpawnInstance_
  2191. if Err.number <> 0 then
  2192. SA_TraceOut "inc_wsa", "Failed to Create Win32_Ace Object " & "(" & Hex(Err.Number) & ")"
  2193. exit function
  2194. end if
  2195. objACE.AccessMask = nAccessMask
  2196. objACE.Aceflags = 3
  2197. objACE.AceType = 0
  2198. objACE.Trustee = objTrustee
  2199. SA_TraceOut "inc_wsa", "In GetUserAce function success"
  2200. GetUserAce = TRUE
  2201. 'Release objects
  2202. set objAcct = nothing
  2203. set objSID = nothing
  2204. set objTrustee = nothing
  2205. End Function
  2206. '-------------------------------------------------------------------------
  2207. 'Function name: GetGroupAce
  2208. 'Description: Get the ACLs of the group
  2209. 'Input Variables: objService, strGroupName, strDomain, nAccessMask, ByRef objACE
  2210. 'Returns: boolean
  2211. '--------------------------------------------------------------------------
  2212. Function GetGroupAce(objService, strGroupName, strDomain, nAccessMask, ByRef objACE)
  2213. On Error Resume Next
  2214. Err.Clear
  2215. Dim strObjPath 'holds query string
  2216. Dim objAcct 'holds query result
  2217. Dim objSID 'holds security identifier
  2218. Dim objTrustee 'holds trustee value
  2219. GetGroupAce = FALSE
  2220. strObjPath = "Win32_Group.Domain=" & chr(34) & strDomain & chr(34) & ",Name=" & chr(34) & strGroupName & chr(34)
  2221. set objAcct = objService.Get(strObjPath)
  2222. if Err.number <> 0 then
  2223. Call SA_TraceOut("inc_wsa", "Get Win32_Group failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  2224. Call SA_TraceOut("inc_wsa", "-->Object path: " + CStr(strObjPath) )
  2225. exit function
  2226. end if
  2227. set objSID = objService.Get("Win32_SID.SID='" & objAcct.SID & "'")
  2228. if Err.number <> 0 then
  2229. SA_TraceOut "inc_wsa", "Failed to get Win32_SID Object " & "(" & Hex(Err.Number) & ")"
  2230. exit function
  2231. end if
  2232. set objTrustee = objService.Get("Win32_Trustee").SpawnInstance_
  2233. if Err.number <> 0 then
  2234. SA_TraceOut "inc_wsa", "Failed to get new Instance of Win32_Trustee " & "(" & Hex(Err.Number) & ")"
  2235. exit function
  2236. end if
  2237. objTrustee.Name = strGroupName
  2238. objTrustee.Domain = strDomain
  2239. objTrustee.SID = objSID.BinaryRepresentation
  2240. objTrustee.SIDString = objSID.SID
  2241. objTrustee.SidLength = objSID.SidLength
  2242. set objACE = objService.Get("Win32_ACE").SpawnInstance_
  2243. if Err.number <> 0 then
  2244. SA_TraceOut "inc_wsa", "Failed to Create Win32_Ace Object " & "(" & Hex(Err.Number) & ")"
  2245. exit function
  2246. end if
  2247. objACE.AccessMask = nAccessMask
  2248. objACE.Aceflags = 3
  2249. objACE.AceType = 0
  2250. objACE.Trustee = objTrustee
  2251. SA_TraceOut "inc_wsa", "In GetGroupAce function success"
  2252. GetGroupAce = TRUE
  2253. 'Release objects
  2254. set objAcct = nothing
  2255. set objSID = nothing
  2256. set objTrustee = nothing
  2257. End Function
  2258. '-------------------------------------------------------------------------
  2259. 'Function name :ModifyUserInOu
  2260. 'Description :Modify User settings in OU
  2261. ' group
  2262. 'Input Variables :strUserName,strOuName, strGrpName
  2263. 'Output Variables :None
  2264. 'Returns :Boolean
  2265. 'Global Variables :None
  2266. '-------------------------------------------------------------------------
  2267. Function ModifyUserInOu(strSiteID,strDomain,strUserName, strPassword, strGrpName)
  2268. On Error Resume Next
  2269. Err.Clear
  2270. Dim oUser 'holds user object
  2271. Dim objComputer 'holds computer object
  2272. ModifyUserInOu = false
  2273. SA_TraceOut "inc_wsa.asp", "In ModifyUserInOu"
  2274. Set objComputer = GetObject("WinNT://" & strDomain)
  2275. Set oUser = objComputer.GetObject("user" , trim(strUserName))
  2276. If Err.number <> 0 Then
  2277. SA_TraceOut "inc_wsa.asp", "In ModifyUserInOu, get user pswd failed "
  2278. SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2279. Array("user " & trim(strUserName)))
  2280. Exit Function
  2281. End if
  2282. oUser.setPassword(trim(strPassword))
  2283. oUser.SetInfo()
  2284. if Err.number <> 0 then
  2285. mintTabSelected = 0
  2286. If Err.number = &H800708C5 Then
  2287. SetErrMsg L_ERR_PASSWORD_POLICY
  2288. Else
  2289. SetErrMsg L_SETPW_ERRORMESSAGE
  2290. End If
  2291. exit Function
  2292. end if
  2293. SA_TraceOut "inc_wsa.asp", "In ModifyUserInOu successfull"
  2294. 'release objects
  2295. set oUser = nothing
  2296. set objComputer = nothing
  2297. ModifyUserInOu = true
  2298. End function
  2299. '-------------------------------------------------------------------------
  2300. 'Function name :GetRandomPassword
  2301. 'Description :Generates a random password
  2302. 'Input Variables :None
  2303. 'Output Variables :strPassword
  2304. 'Returns :string
  2305. 'Global Variables :None
  2306. '-------------------------------------------------------------------------
  2307. Function GetRandomPassword
  2308. On Error Resume Next
  2309. Err.Clear
  2310. GetRandomPassword = ""
  2311. Dim objSAHelper
  2312. Dim strPassword
  2313. Set objSAHelper = server.CreateObject("ServerAppliance.SAHelper")
  2314. if Err.number <> 0 then
  2315. Call SA_TraceOut ("inc_wsa", "createobject for sahelper failed")
  2316. exit function
  2317. else
  2318. strPassword = objSAHelper.GenerateRandomPassword(14)
  2319. if Err.number <> 0 then
  2320. Call SA_TraceOut ("inc_wsa", "generate random password failed")
  2321. Set objSAHelper = Nothing
  2322. exit function
  2323. end if
  2324. end if
  2325. GetRandomPassword = strPassword
  2326. End Function
  2327. '-------------------------------------------------------------------------
  2328. 'Function name :SetPasswdInAD
  2329. 'Description :Create Users in OU and adds the user to specified
  2330. ' group
  2331. 'Input Variables :strUserName,strOuName
  2332. 'Output Variables :None
  2333. 'Returns :Boolean
  2334. 'Global Variables :None
  2335. '-------------------------------------------------------------------------
  2336. Function SetPasswdInAD(strSiteID,strUserName, strPassword)
  2337. On Error Resume Next
  2338. Err.Clear
  2339. Dim oUser 'holds user object
  2340. Dim oRoot 'holds root object
  2341. Dim oOUWebSites 'holds OU website
  2342. Dim oOUSiteID 'holds OU siteid
  2343. SetPasswdInAD = False
  2344. SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD"
  2345. SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD strSiteID: " + strSiteID
  2346. SA_traceOut "G_strDirRoot: " , G_strDirRoot
  2347. Set oRoot = GetObject("LDAP://" & G_strDirRoot)
  2348. If Err.number <> 0 Then
  2349. SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2350. Array("LDAP://" & G_strDirRoot))
  2351. SA_TraceOut "inc_wsa.asp", "Connect to LDAP failed"
  2352. Exit Function
  2353. End if
  2354. Set oOUWebSites = oRoot.GetObject("organizationalUnit", "ou=WebSites")
  2355. If err.number <> 0 Then
  2356. SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2357. Array("WebSites organizational unit"))
  2358. SA_TraceOut "inc_wsa.asp", _
  2359. "In SetPasswdInAD, get ou web sites failed"
  2360. Exit Function
  2361. End If
  2362. Set oOUSiteID = oOUWebSites.GetObject("organizationalUnit", "ou=" & strSiteID)
  2363. If err.number<>0 Then
  2364. SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2365. Array(strSiteID & " organizational unit"))
  2366. SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD, get ou siteid failed"
  2367. Exit Function
  2368. End If
  2369. SA_traceout "strUserName: ", strUserName
  2370. Set oUser = oOUSiteID.GetObject("User", "cn=" + strUserName )
  2371. If Err.number <> 0 Then
  2372. SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD, GetObject user failed "
  2373. SetErrMsg L_CREATEUSER_ERRORMESSAGE
  2374. Exit Function
  2375. End If
  2376. oUser.setPassword(strPassword)
  2377. If Err.number <> 0 Then
  2378. SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD, SetPassword ** failed ** "
  2379. SetErrMsg L_CREATEUSER_ERRORMESSAGE
  2380. Exit Function
  2381. End If
  2382. oUser.SetInfo()
  2383. if Err.number <> 0 then
  2384. SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD, SetInfo failed "
  2385. SetErrMsg L_CREATEUSER_ERRORMESSAGE
  2386. Exit Function
  2387. end if
  2388. SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD successfull"
  2389. 'release objects
  2390. Set oUser = nothing
  2391. Set oOUWebSites = nothing
  2392. Set oOUSiteID = nothing
  2393. Set oRoot = nothing
  2394. SetPasswdInAD = true
  2395. End function
  2396. '-------------------------------------------------------------------------
  2397. 'Function name :SetPasswdInNT
  2398. 'Description :Set password in NT
  2399. 'Input Variables :strUserName -- username to set the password for
  2400. 'Input Variables :strPassword -- password to be used
  2401. 'Returns :True or False
  2402. 'Global Variables :None
  2403. '-------------------------------------------------------------------------
  2404. Function SetPasswdInNT( strDomainName, strUserName, strPassword )
  2405. On Error Resume Next
  2406. Err.Clear
  2407. Dim objComputer
  2408. Dim objUser
  2409. SetPasswdInNT = False
  2410. SA_TraceOut "inc_wsa.asp", "In SetPasswdInNT"
  2411. SA_TraceOut "strDomainName:", strDomainName
  2412. 'SA_TraceOut "G_strSysName:", G_strSysName
  2413. Set objComputer = GetObject("WinNT://" & strDomainName)
  2414. If Err.number <> 0 Then
  2415. SA_TraceOut "inc_wsa", "failed to GetObject in SetPasswdinNT : G_strSysName: " + G_strSysName
  2416. SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2417. Array("WinNT://" & strDomain))
  2418. Exit Function
  2419. End if
  2420. Set objUser = objComputer.GetObject("User" , strUserName)
  2421. If Err.number <> 0 Then
  2422. SA_TraceOut "inc_wsa", "failed to GetObject in SetPasswdinNT : strUserName: " + strUserName
  2423. SetErrmsg L_ERR_GET_USER_OBJECT
  2424. Exit Function
  2425. End If
  2426. objUser.setPassword(trim(strPassword))
  2427. objUser.SetInfo()
  2428. If Err.number <> 0 Then
  2429. SA_TraceOut "inc_wsa", "failed to SetInfo in SetPasswdinNT : strPassword: " + strPassword
  2430. If Err.number = &H800708C5 Then
  2431. SetErrMsg L_ERR_PASSWORD_POLICY
  2432. Else
  2433. SetErrMsg L_UNABLETOSET_PASSWORD_ERRORMESSAGE
  2434. End If
  2435. Exit Function
  2436. End If
  2437. 'Release the object
  2438. set objUser = nothing
  2439. set objComputer = nothing
  2440. SetPasswdInNT = TRUE
  2441. Call SA_TRACEOUT("SetPasswdInNT","return success")
  2442. End Function
  2443. '---------------------------------------------------------------------
  2444. ' Function name: isFileExisting
  2445. ' Description: To verify the existence of the file
  2446. ' Input Variables: strFileToVerify-file name along with its path
  2447. ' Output Variables: None
  2448. ' Return Values: TRUE - if file exists , else FALSE
  2449. ' Global Variables: None
  2450. '---------------------------------------------------------------------
  2451. Function isFileExisting(strFile)
  2452. Err.Clear
  2453. On Error Resume Next
  2454. Dim objFSO
  2455. Set objFSO = CreateObject("Scripting.FileSystemObject")
  2456. ' If the file is existing, return true, else false
  2457. If objFSO.FileExists(strFile) Then
  2458. isFileExisting = True
  2459. Else
  2460. isFileExisting = False
  2461. End If
  2462. Set objFSO = Nothing
  2463. End Function
  2464. '-------------------------------------------------------------------------
  2465. 'Function name :LaunchProcess
  2466. 'Description :Launches a new process
  2467. 'Input Variables :strCommand, strCurDir
  2468. 'Output Variables :None
  2469. 'Returns :Boolean
  2470. '-------------------------------------------------------------------------
  2471. Function LaunchProcess(strCommand, strCurDir)
  2472. On error Resume Next
  2473. Err.Clear
  2474. Dim objService 'holds WMI Connection
  2475. Dim objClass 'holds query result
  2476. Dim objProc 'holds query result of Win32_process
  2477. Dim objProcStartup 'holds class spawninstance value
  2478. Dim nretval 'holds return value
  2479. Dim nPID
  2480. Dim objTemp 'holds temporary value
  2481. nretval = 0
  2482. Set objService=getWMIConnection("root\cimv2")
  2483. Set objClass = objService.Get("Win32_ProcessStartup")
  2484. Set objProcStartup = objClass.SpawnInstance_()
  2485. objProcStartup.ShowWindow = 2
  2486. Set objProc = objService.Get("Win32_Process")
  2487. nretval = objProc.Create(strCommand, strCurDir, objProcStartup,nPID)
  2488. If Err.number <> 0 Then
  2489. Call SA_TraceOut(SA_GetScriptFileName(), "Function LaunchProcess failed, error: " & Hex(Err.Number) & " " & Err.Description)
  2490. LaunchProcess = FALSE
  2491. Exit function
  2492. End If
  2493. SA_TraceOut "inc_wsa", "Launch Process " & strCommand & " from path " & strCurDir & " successful "
  2494. LaunchProcess = TRUE
  2495. 'Release objects
  2496. Set objService= nothing
  2497. Set objClass = nothing
  2498. Set objProcStartup = nothing
  2499. Set objProc = nothing
  2500. End Function
  2501. '-------------------------------------------------------------------------
  2502. '-------------------------------------------------------------------------
  2503. '
  2504. ' Functions to handle FrontPageServerExtension.
  2505. '
  2506. ' 1) FPSE (2000, 2002) may be installed on the server (host).
  2507. ' 2) For IIS 6.0, FPSE may be enabled or diabled.
  2508. ' 3) For each website, FPSE may be installed.
  2509. '
  2510. ' The interfaces are:
  2511. '
  2512. ' 1) IsFrontPageInstalled (return true if any version installed)
  2513. ' 2) IsFrontPageInstalledOnWebSite (return true if any version installed on the website)
  2514. ' 3) InstallFrontPageWeb (install FPSE 2002 if found, otherwise install 2000)
  2515. ' 4) UnInstallFrontPageWeb (uninstall the correct version of FPSE on the website)
  2516. '
  2517. '-------------------------------------------------------------------------
  2518. '-------------------------------------------------------------------------
  2519. '-------------------------------------------------------------------------
  2520. 'Function name :isFrontPageInstalled
  2521. 'Description :Returns whether fron page extensions are installed on
  2522. ' server or not
  2523. 'Input Variables :None
  2524. 'Output Variables :None
  2525. 'Returns :Boolean
  2526. 'Global Variables :None
  2527. '-------------------------------------------------------------------------
  2528. Public Function isFrontPageInstalled(objService)
  2529. '
  2530. ' Check if FP 2000 is installed
  2531. isFrontPageInstalled = isFrontPage2000Installed(objService)
  2532. '
  2533. ' If NOT then check if FP 2002 is installed
  2534. If ( false = isFrontPageInstalled ) Then
  2535. isFrontPageInstalled = isFrontPage2002Installed(objService)
  2536. End If
  2537. End Function
  2538. '-------------------------------------------------------------------------
  2539. 'Function name :isFrontPage2000Installed
  2540. 'Description :Returns whether FPSE2000 are installed or not
  2541. 'Input Variables :None
  2542. 'Output Variables :None
  2543. 'Returns :Boolean
  2544. 'Global Variables :None
  2545. '-------------------------------------------------------------------------
  2546. Private Function isFrontPage2000Installed(ByRef objService)
  2547. On Error Resume Next
  2548. Err.Clear
  2549. Dim objFrontPage 'holds frontpage query result
  2550. isFrontPage2000Installed = false
  2551. set objFrontPage = objService.Get("IIs_filter.Name=" & chr(34) & CONST_FRONTPAGE_PATH & chr(34))
  2552. If Err.number <> 0 then
  2553. SA_TraceOut "inc_wsa.asp", "Frontpage extensions not set. Error = " & Err.number
  2554. exit function
  2555. else
  2556. if NOT IsObject(objFrontPage) then
  2557. exit function
  2558. end if
  2559. isFrontPage2000Installed = true
  2560. end if
  2561. 'release the object
  2562. set objFrontPage = nothing
  2563. End Function
  2564. '-------------------------------------------------------------------------
  2565. 'Function name :isFrontPage2002Installed
  2566. 'Description :Returns whether FPSE2002 are installed or not
  2567. 'Input Variables :None
  2568. 'Output Variables :None
  2569. 'Returns :Boolean
  2570. 'Global Variables :None
  2571. '-------------------------------------------------------------------------
  2572. Private Function isFrontPage2002Installed(ByRef objService)
  2573. on error resume next
  2574. isFrontPage2002Installed = FALSE
  2575. Dim aValues
  2576. Dim x
  2577. Dim objRegistry
  2578. Set objRegistry = RegConnection()
  2579. If (NOT IsObject(objRegistry)) Then
  2580. Call SA_TraceOut(SA_GetScriptFileName(), "RegConnection() failed in function isFrontPage2002Installed, error: " & Hex(Err.Number) & " " & Err.Description )
  2581. Exit Function
  2582. End If
  2583. '
  2584. ' Search for FP Server Extensions 2002 installed reg key
  2585. aValues = RegEnumKey( objRegistry, "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0")
  2586. If ( IsNull(aValues) ) Then
  2587. Exit Function
  2588. End If
  2589. 'Call SA_TraceOut(SA_GetScriptFileName(), "RegEnumKey: " & "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0")
  2590. for x = LBound(aValues) to UBound(aValues)
  2591. If ( IsNull(aValues(x)) ) Then
  2592. Exit Function
  2593. End If
  2594. 'Call SA_TraceOut(SA_GetScriptFileName(), "RegKeyValue: " & aValues(x))
  2595. If ( Trim(aValues(x)) = Trim(CONST_FRONTPAGE_2002_INSTALLED) ) Then
  2596. isFrontPage2002Installed = true
  2597. exit for
  2598. End If
  2599. Next
  2600. '
  2601. ' Search for SharePoint installed reg key
  2602. aValues = RegEnumKeyValues( objRegistry, "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0")
  2603. If ( IsNull(aValues) ) Then
  2604. Exit Function
  2605. End If
  2606. 'Call SA_TraceOut(SA_GetScriptFileName(), "RegEnumKeyValues for: " & "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0")
  2607. for x = LBound(aValues) to UBound(aValues)
  2608. If ( IsNull(aValues(x)) ) Then
  2609. Exit Function
  2610. End If
  2611. 'Call SA_TraceOut(SA_GetScriptFileName(), "RegKeyValue: " & aValues(x))
  2612. If ( Trim(aValues(x)) = Trim(CONST_SHAREPOINT_INSTALLED) ) Then
  2613. isFrontPage2002Installed = true
  2614. exit for
  2615. End If
  2616. Next
  2617. Set objRegistry = nothing
  2618. End Function
  2619. '-------------------------------------------------------------------------
  2620. 'Function name :InstallFrontPageWeb
  2621. 'Description :Installs Front Page Extensions on the machine
  2622. 'Input Variables :None
  2623. 'Output Variables :None
  2624. 'Returns :Boolean
  2625. '-------------------------------------------------------------------------
  2626. Function InstallFrontPageWeb(strSiteName, strUserName)
  2627. On Error Resume Next
  2628. Err.Clear
  2629. Dim objRegConn 'holds regeconnection
  2630. Dim strLocationFPSE2000 'holds location of string in registry
  2631. Dim strLocationFPSE2002 'holds location of the FPSE 2002 location
  2632. Dim strCommand 'holds string
  2633. Dim retval 'holds return value
  2634. InstallFrontPageWeb = FALSE
  2635. Set objRegConn = RegConnection()
  2636. if isFrontPage2002Installed Then
  2637. strLocationFPSE2002 = GetRegKeyValue(objRegConn,CONST_FRONTPAGE_2002_REGLOC,"Location",CONST_STRING)
  2638. strLocationFPSE2002 = strLocationFPSE2002 & "\" & "bin"
  2639. 'SA_TraceOut "inc_wsa", "strLocationFPSE2002: " & strLocationFPSE2002
  2640. strCommand = "cmd.exe /c " & chr(34) & "owsadm.exe -o install -p /LM/" & strSiteName & " -type msiis -u " & strUserName & chr(34)
  2641. 'SA_TraceOut "inc_wsa", "strCommandFPSE2002: " & strCommand
  2642. InstallFrontPageWeb = LaunchProcess(strCommand, strLocationFPSE2002)
  2643. ElseIf isFrontPage2000Installed Then
  2644. strLocationFPSE2000 = GetRegKeyValue(objRegConn,CONST_FRONTPAGE_REGLOC,"Location",CONST_STRING)
  2645. strLocationFPSE2000 = strLocationFPSE2000 & "\" & "bin"
  2646. 'SA_TraceOut "inc_wsa", "strLocationFPSE2000: " & strLocationFPSE2000
  2647. strCommand = "cmd.exe /c " & chr(34) & "fpsrvadm.exe -o install -p /LM/" & strSiteName & " -type msiis -u " & strUserName & chr(34)
  2648. 'SA_TraceOut "inc_wsa", "strCommandFPSE2000: " & strCommand
  2649. InstallFrontPageWeb = LaunchProcess(strCommand, strLocationFPSE2000)
  2650. Else
  2651. call SA_TraceOut("inc_wsa", "Function InstallFrontPageWeb: Frontpage Extension not Installed on the server")
  2652. End If
  2653. 'Release objects
  2654. Set objRegConn = nothing
  2655. End Function
  2656. '-------------------------------------------------------------------------
  2657. 'Function name :UnInstallFrontPageWeb
  2658. 'Description :UnInstalls Front Page Extensions on the machine
  2659. 'Input Variables :None
  2660. 'Output Variables :None
  2661. 'Returns :Boolean
  2662. '-------------------------------------------------------------------------
  2663. Function UnInstallFrontPageWeb(strSiteName)
  2664. On Error Resume Next
  2665. Err.Clear
  2666. Dim objRegConn 'holds regeconnection
  2667. Dim strLocationFPSE2000 'holds location of string in registry
  2668. Dim strLocationFPSE2002 'holds location of the FPSE 2002 location
  2669. Dim strCommand 'holds string
  2670. Dim retval 'holds return value
  2671. UnInstallFrontPageWeb = FALSE
  2672. Set objRegConn = RegConnection()
  2673. if IsFrontPage2002InstalledOnWebSite(strSiteName) Then
  2674. strLocationFPSE2002 = GetRegKeyValue(objRegConn,CONST_FRONTPAGE_2002_REGLOC,"Location",CONST_STRING)
  2675. strLocationFPSE2002 = strLocationFPSE2002 & "\" & "bin"
  2676. 'SA_TraceOut "inc_wsa", "strLocationFPSE2002: " & strLocationFPSE2002
  2677. strCommand = "cmd.exe /c " & chr(34) & "owsadm.exe -o uninstall -p /LM/" & strSiteName & chr(34)
  2678. 'Call SA_TraceOut("inc_wsa", "Function UnInstallFrontPageWeb: FPSE 2002 command: " & strCommand)
  2679. UnInstallFrontPageWeb = LaunchProcess(strCommand, strLocationFPSE2002)
  2680. ElseIf IsFrontPage2000InstalledOnWebSite(strSiteName) Then
  2681. strLocationFPSE2000 = GetRegKeyValue(objRegConn,CONST_FRONTPAGE_REGLOC,"Location",CONST_STRING)
  2682. strLocationFPSE2000 = strLocationFPSE2000 & "\" & "bin"
  2683. 'SA_TraceOut "inc_wsa", "strLocationFPSE2000: " & strLocationFPSE2000
  2684. strCommand = "cmd.exe /c " & chr(34) & "fpsrvadm.exe -o uninstall -p /LM/" & strSiteName & chr(34)
  2685. 'Call SA_TraceOut("inc_wsa", "Function UnInstallFrontPageWeb: FPSE 2000 command: " & strCommand)
  2686. UnInstallFrontPageWeb = LaunchProcess(strCommand, strLocationFPSE2000)
  2687. Else
  2688. call SA_TraceOut("inc_wsa", "Function UnInstallFrontPageWeb: Frontpage Extension not installed on the server")
  2689. End If
  2690. 'Release objects
  2691. Set objRegConn = nothing
  2692. End Function
  2693. '-------------------------------------------------------------------------
  2694. 'Function name :IsFrontPageInstalledOnWebSite
  2695. 'Description :Determines whether front page extensions are installed
  2696. ' on that web site
  2697. 'Input Variables :strSysName, strSiteName
  2698. 'Output Variables :None
  2699. 'Returns :Boolean
  2700. '-------------------------------------------------------------------------
  2701. Function IsFrontPageInstalledOnWebSite(strSysName, strSiteName)
  2702. On Error Resume Next
  2703. Err.Clear
  2704. 'Dim objSite 'holds IIS root object
  2705. IsFrontPageInstalledOnWebSite = false
  2706. If IsFrontPage2000InstalledOnWebSite( strSiteName) or IsFrontPage2002InstalledOnWebSite( strSiteName) Then
  2707. IsFrontPageInstalledOnWebSite = true
  2708. End If
  2709. 'Set objSite = GetObject("IIS:")
  2710. 'Set objSite = objSite.OpenDSObject("IIS://" & strSysName & "/" & strSiteName, "", "", 1)
  2711. 'if Err.number <> 0 then
  2712. ' Err.Clear
  2713. ' SA_TraceOut "inc_wsa", "Failed to determine whether front page extensions are installed for site: " & strSiteName
  2714. ' Exit function
  2715. 'end if
  2716. 'IsFrontPageInstalledOnWebSite = objSite.FrontPageWeb
  2717. 'Release the objects
  2718. 'set objSite = nothing
  2719. End Function
  2720. '-------------------------------------------------------------------------
  2721. 'Function name :IsFrontPage2000InstalledOnWebSite
  2722. 'Description :Determines whether front page extensions are installed
  2723. ' on that web site
  2724. 'Input Variables :strSysName, strSiteName
  2725. 'Output Variables :None
  2726. 'Returns :Boolean
  2727. '-------------------------------------------------------------------------
  2728. Function IsFrontPage2000InstalledOnWebSite( strSiteName)
  2729. On Error Resume Next
  2730. Err.Clear
  2731. Dim objRegConn 'registry connection
  2732. Dim strSitePortLoc 'registry key location of the website
  2733. Dim strFrontPageRoot
  2734. Dim strAuthoring
  2735. IsFrontPage2000InstalledOnWebSite = false
  2736. ' The registry key is the same for all OS versions
  2737. strSitePortLoc = CONST_PORT_REGLOC & "Port /LM/" & strSiteName & ":"
  2738. Set objRegConn = RegConnection()
  2739. strAuthoring = GetRegKeyValue(objRegConn,strSitePortLoc,"authoring",CONST_STRING)
  2740. strFrontPageRoot = GetRegKeyValue(objRegConn,strSitePortLoc,"frontpageroot",CONST_STRING)
  2741. if Ucase(strAuthoring) = "ENABLED" and instr(strFrontPageRoot, "\40") Then
  2742. IsFrontPage2000InstalledOnWebSite = true
  2743. End If
  2744. set objRegConn = nothing
  2745. End Function
  2746. '-------------------------------------------------------------------------
  2747. 'Function name :IsFrontPage2002InstalledOnWebSite
  2748. 'Description :Determines whether front page extensions are installed
  2749. ' on that web site
  2750. 'Input Variables :strSysName, strSiteName
  2751. 'Output Variables :None
  2752. 'Returns :Boolean
  2753. '-------------------------------------------------------------------------
  2754. Function IsFrontPage2002InstalledOnWebSite( strSiteName)
  2755. On Error Resume Next
  2756. Err.Clear
  2757. Dim objRegConn 'registry connection
  2758. Dim strSitePortLoc 'registry key location of the website
  2759. Dim strFrontPageRoot
  2760. Dim strAuthoring
  2761. IsFrontPage2002InstalledOnWebSite = false
  2762. ' The registry key is the same for all OS versions
  2763. strSitePortLoc = CONST_PORT_REGLOC & "Port /LM/" & strSiteName & ":"
  2764. Set objRegConn = RegConnection()
  2765. strAuthoring = GetRegKeyValue(objRegConn,strSitePortLoc,"authoring",CONST_STRING)
  2766. strFrontPageRoot = GetRegKeyValue(objRegConn,strSitePortLoc,"frontpageroot",CONST_STRING)
  2767. if Ucase(strAuthoring) = "ENABLED" and instr(strFrontPageRoot, "\50") Then
  2768. IsFrontPage2002InstalledOnWebSite = true
  2769. End If
  2770. set objRegConn = nothing
  2771. End Function
  2772. '-------------------------------------------------------------------------
  2773. '-------------------------------------------------------------------------
  2774. '
  2775. ' Functions to handle FTP
  2776. '
  2777. '
  2778. '
  2779. '-------------------------------------------------------------------------
  2780. '-------------------------------------------------------------------------
  2781. '-------------------------------------------------------------------------
  2782. 'Function name: IsFTPEnabled
  2783. 'Description: Initialization of global variables is done
  2784. 'Input Variables: None
  2785. 'Returns: true/false
  2786. 'Global Variables: G_objService
  2787. ' G_objSites
  2788. '--------------------------------------------------------------------------
  2789. Function IsFTPEnabled()
  2790. Err.Clear
  2791. on error resume next
  2792. Dim objFTP
  2793. Dim objFTPList
  2794. Dim objService
  2795. IsFTPEnabled = false
  2796. ' Get instances of IIS_FTPServiceSetting that are visible throughout
  2797. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  2798. set objFTPList = objService.InstancesOf(GetIISWMIProviderClassName("IIS_FTPService"))
  2799. For each objFTP in objFTPList
  2800. if objFTP.State = CONST_SERVICE_RUNNING_STATE Then
  2801. IsFTPEnabled = true
  2802. End If
  2803. Next
  2804. if Err.number <> 0 then
  2805. IsFTPEnabled = false
  2806. Err.Clear
  2807. end if
  2808. set objtFTPList = nothing
  2809. set objFTP = nothing
  2810. set objService = nothing
  2811. end function
  2812. '-------------------------------------------------------------------------
  2813. 'Function name: EnableFTP
  2814. 'Description: Enable FTP service and set it's state to automatic
  2815. 'Input Variables: None
  2816. 'Returns: None
  2817. 'Global Variables:
  2818. '--------------------------------------------------------------------------
  2819. Function EnableFTP()
  2820. Err.Clear
  2821. on error resume next
  2822. Dim objFTP
  2823. Dim objService
  2824. EnableFTP = false
  2825. ' Get instances of IIS_FTPServiceSetting that are visible throughout
  2826. Set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  2827. set objFTP = objService.get("Win32_Service.Name='MSFTPSVC'")
  2828. Call objFTP.ChangeStartMode("Automatic")
  2829. Call objFTP.StartService()
  2830. EnableFTP = true
  2831. if Err.number <> 0 then
  2832. EnableFTP = false
  2833. Err.Clear
  2834. end if
  2835. set objFTP = nothing
  2836. set objService = nothing
  2837. end function
  2838. '-------------------------------------------------------------------------
  2839. 'Function name: DisableFTP
  2840. 'Description: Diable FTP service and set it's state to manual
  2841. 'Input Variables: None
  2842. 'Returns: None
  2843. 'Global Variables:
  2844. '--------------------------------------------------------------------------
  2845. Function DisableFTP()
  2846. Err.Clear
  2847. on error resume next
  2848. Dim objFTP
  2849. Dim objService
  2850. DisableFTP = false
  2851. ' Get instances of IIS_FTPServiceSetting that are visible throughout
  2852. Set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  2853. set objFTP = objService.get("Win32_Service.Name='MSFTPSVC'")
  2854. Call objFTP.ChangeStartMode("Manual")
  2855. Call objFTP.StopService()
  2856. DisableFTP = true
  2857. if Err.number <> 0 then
  2858. DisableFTP = false
  2859. Err.Clear
  2860. end if
  2861. set objFTP = nothing
  2862. set objService = nothing
  2863. end function
  2864. '-------------------------------------------------------------------------
  2865. 'Function name: SetFPSEOption
  2866. 'Description: Set FPSE Option in the registry
  2867. 'Input Variables:
  2868. 'Returns: None
  2869. 'Global Variables:
  2870. '--------------------------------------------------------------------------
  2871. Function SetFPSEOption(bEnableFPSE)
  2872. dim objRegConn
  2873. dim iFPSEOption
  2874. Set objRegConn = RegConnection()
  2875. 'Init the value to be set to the regval
  2876. if bEnableFPSE Then
  2877. iFPSEOption = 1
  2878. Else
  2879. iFPSEOption = 0
  2880. End If
  2881. call updateRegkeyvalue(objRegConn,CONST_WEBBLADES_REGKEY,CONST_FPSEOPTION_REGVAL,iFPSEOption,CONST_DWORD)
  2882. If Err.number <> 0 Then
  2883. SA_TraceOut "inc_wsa", "Set regvalue for FPSEOption failed " & Hex(Err.Number)
  2884. exit Function
  2885. End if
  2886. End Function
  2887. '-------------------------------------------------------------------------
  2888. 'Function name: GetFPSEOption
  2889. 'Description: Get FPSE Option in the registry. If the regval is 1, it means
  2890. ' PFSE is enabled by default for all Website created thru WebUI,
  2891. ' and GetFPSEOption return true. Otherwise return false.
  2892. 'Input Variables:
  2893. 'Returns: True if PFSE is enabled by default for all Website created thru WebUI
  2894. 'Global Variables:
  2895. '--------------------------------------------------------------------------
  2896. Function GetFPSEOption()
  2897. dim objRegConn
  2898. dim iFPSEOption
  2899. GetFPSEOption = false
  2900. Set objRegConn = RegConnection()
  2901. iFPSEOption = GetRegKeyValue(objRegConn,CONST_WEBBLADES_REGKEY,CONST_FPSEOPTION_REGVAL,CONST_DWORD)
  2902. If Err.number <> 0 Then
  2903. SA_TraceOut "inc_wsa", "Get regvalue for FPSEOption failed " & Hex(Err.Number)
  2904. exit Function
  2905. End if
  2906. if iFPSEOption = 1 then
  2907. GetFPSEOption = true
  2908. End If
  2909. End Function
  2910. '-------------------------------------------------------------------------
  2911. '-------------------------------------------------------------------------
  2912. '
  2913. ' Functions to handle ASP enable/disable
  2914. '
  2915. '
  2916. '
  2917. '-------------------------------------------------------------------------
  2918. '-------------------------------------------------------------------------
  2919. '-------------------------------------------------------------------------
  2920. 'Function name: IsASPEnabled
  2921. 'Description: Check if ASP is enable at the webroot (for all website)
  2922. 'Input Variables: None
  2923. 'Returns: None
  2924. 'Global Variables:
  2925. '--------------------------------------------------------------------------
  2926. Function IsASPEnabled()
  2927. Err.Clear
  2928. on error resume next
  2929. IsASPEnabled = false
  2930. end function
  2931. '-------------------------------------------------------------------------
  2932. 'Function name: EnableASP
  2933. 'Description: Enable ASP for all the website (at the webroot)
  2934. 'Input Variables: None
  2935. 'Returns: None
  2936. 'Global Variables:
  2937. '--------------------------------------------------------------------------
  2938. Function EnableASP()
  2939. Err.Clear
  2940. on error resume next
  2941. end function
  2942. '-------------------------------------------------------------------------
  2943. 'Function name: DisableASP
  2944. 'Description: Diable ASP at the webroot (except Administration site)
  2945. 'Input Variables: None
  2946. 'Returns: None
  2947. 'Global Variables:
  2948. '--------------------------------------------------------------------------
  2949. Function DisableASP()
  2950. Err.Clear
  2951. on error resume next
  2952. end function
  2953. '-------------------------------------------------------------------------
  2954. '-------------------------------------------------------------------------
  2955. '
  2956. ' Helper functions for common UI between site.new and site.modify
  2957. '
  2958. '
  2959. '
  2960. '-------------------------------------------------------------------------
  2961. '-------------------------------------------------------------------------
  2962. '-------------------------------------------------------------------------
  2963. 'Function name: IsFTPAllowedOnSite
  2964. 'Description: Determines whether we should allow an FTP virtual
  2965. ' directory to be created for this site based on
  2966. ' the ACLs on the root directory for the site. If
  2967. ' interactive users are allowed access, we
  2968. ' deem the site unsafe for FTP access and disable
  2969. ' the option.
  2970. 'Input Variables: strPath Local path of root directory
  2971. ' for this site.
  2972. 'Returns: True if FTP access should be allowed and False
  2973. ' otherwise.
  2974. 'Global Variables: None
  2975. '--------------------------------------------------------------------------
  2976. Function IsFTPAllowedOnSite(strPath)
  2977. On Error Resume Next
  2978. IsFTPAllowedOnSite = True
  2979. '
  2980. ' Get the WMI path to the security settings for the web root.
  2981. '
  2982. Dim strFolderSecurityPath
  2983. strFolderSecurityPath = "Win32_LogicalFileSecuritySetting.Path=""" & strPath & """"
  2984. ' Replace single backslashes with double backslashes.
  2985. Dim oRegExp
  2986. Set oRegExp = New RegExp
  2987. oRegExp.Pattern = "\\"
  2988. oRegExp.Global = true
  2989. strFolderSecurityPath = oRegExp.Replace(strFolderSecurityPath, "\\")
  2990. '
  2991. ' Open the object for the web root directory. If the directory doesn't
  2992. ' exist, assume this is a new site.
  2993. '
  2994. Dim oService
  2995. Set oService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  2996. Dim oFolderSecurity
  2997. Set oFolderSecurity = oService.Get(strFolderSecurityPath)
  2998. If (wbemErrNotFound = Err.number) Then
  2999. ' The directory doesn't exist, so allow FTP
  3000. IsFTPAllowedOnSite = True
  3001. Exit Function
  3002. End If
  3003. Dim oSecurityDescriptor
  3004. If (0 = oFolderSecurity.GetSecurityDescriptor(oSecurityDescriptor)) Then
  3005. Dim oACE
  3006. For Each oACE In oSecurityDescriptor.DACL
  3007. Dim oTrustee
  3008. Set oTrustee = oACE.Trustee
  3009. If ((SIDSTRING_INTERACTIVE = oTrustee.SIDString) And _
  3010. (0 <> oACE.AccessMask)) Then
  3011. '
  3012. ' Interactive users have access, which suggests that
  3013. ' FPSE have been installed on this site before. Even if
  3014. ' FPSE haven't been installed, this site is not secure
  3015. ' enough to allow FTP access.
  3016. IsFTPAllowedOnSite = False
  3017. End If
  3018. Next
  3019. End If
  3020. If (Err.number <> 0) Then
  3021. ' This should never happen, but fail securely if it does.
  3022. IsFTPAllowedOnSite = False
  3023. End If
  3024. End Function
  3025. '-------------------------------------------------------------------------
  3026. 'Sub name: ServeAppSettings
  3027. 'Description: Serves common UI between site new and site modify
  3028. ' pages on application settings tabs. Currently
  3029. ' displays only settings below default page values.
  3030. ' Should be expanded in the future to include all UI
  3031. ' for this tab.
  3032. 'Input Variables: strPath Local path of root directory
  3033. ' for this site.
  3034. ' strUploadMethod The method currently used to
  3035. ' upload content to this site.
  3036. ' See constants defined above
  3037. ' for valid values (e.g.,
  3038. ' UPLOADMETHOD_NEITHER)
  3039. ' strAnonymousChecked The value passed in the form
  3040. ' submission for the anonymous
  3041. ' checkbox (e.g., "true").
  3042. 'Returns: None
  3043. 'Global Variables: Localized strings from resources.asp
  3044. '--------------------------------------------------------------------------
  3045. Sub ServeAppSettings(strPath, strUploadMethod, strAnonymousChecked, bNewSite)
  3046. On Error Resume Next
  3047. '
  3048. ' Calculate the attributes of the radio buttons and checkbox based on
  3049. ' the current settings on the site.
  3050. '
  3051. Dim oIISService
  3052. Set oIISService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  3053. Dim strNeitherAttributes
  3054. strNeitherAttributes = "CHECKED"
  3055. Dim strFPSEAttributes
  3056. Dim strFTPAttributes
  3057. ' Check FrontPage extensions
  3058. If (isFrontPageInstalled(oIISService)) Then
  3059. If (strUploadMethod = UPLOADMETHOD_FPSE) Then
  3060. strFPSEAttributes = "CHECKED"
  3061. strNeitherAttributes = ""
  3062. Else
  3063. strFPSEAttributes = ""
  3064. End If
  3065. Else
  3066. strFPSEAttributes = "DISABLED"
  3067. End If
  3068. ' Check FTP
  3069. If ((Not IsFTPEnabled()) Or (Not IsAdminFTPServerExistAndRunning())) Then
  3070. strFTPAttributes = "DISABLED"
  3071. ElseIf (Not IsFTPAllowedOnSite(strPath)) Then
  3072. If (strUploadMethod = UPLOADMETHOD_FTP) Then
  3073. strFTPAttributes = "CHECKED DISABLED"
  3074. strNeitherAttributes = ""
  3075. Else
  3076. strFTPAttributes = "DISABLED"
  3077. End If
  3078. Else
  3079. If (strUploadMethod = UPLOADMETHOD_FTP) Then
  3080. strFTPAttributes = "CHECKED"
  3081. strNeitherAttributes = ""
  3082. Else
  3083. strFTPAttributes = ""
  3084. End If
  3085. End If
  3086. ' Check anonymous access
  3087. Dim strAnonymousAttributes
  3088. If ("true" = strAnonymousChecked) Then
  3089. strAnonymousAttributes = "CHECKED"
  3090. Else
  3091. strAnonymousAttributes = ""
  3092. End If
  3093. '
  3094. ' Output the UI based on the settings processed above.
  3095. '
  3096. '
  3097. ' Note: FrontPage messages not HTML encoded to allow &reg; to be
  3098. ' displayed correctly.
  3099. '
  3100. %>
  3101. <TABLE WIDTH="400" ALIGN="left" BORDER="0" CELLSPACING="0" CELLPADDING="0"
  3102. CLASS="TasksBody">
  3103. <TR>
  3104. <TD CLASS="TasksBody" COLSPAN="3" NOWRAP>
  3105. <%=Server.HTMLEncode(L_CONTENT_UPLOADMETHOD_TITLE)%>
  3106. </TD>
  3107. </TR>
  3108. <TR>
  3109. <TD CLASS="TasksBody" WIDTH="15px">&nbsp;</TD>
  3110. <TD CLASS="TasksBody">
  3111. <INPUT TYPE="radio" CLASS="FormRadioButton" NAME="radUploadMethod"
  3112. VALUE="<%=UPLOADMETHOD_FPSE%>" <%=strFPSEAttributes%>>
  3113. </TD>
  3114. <TD CLASS="TasksBody" NOWRAP>
  3115. <%=L_APPL_FRONT_PAGE_EXTN_TEXT%>
  3116. </TD>
  3117. </TR>
  3118. <TR>
  3119. <TD CLASS="TasksBody" COLSPAN="2">&nbsp;</TD>
  3120. <TD CLASS="TasksBody">
  3121. <%=Server.HTMLEncode(L_FRONTPAGEFTP_WARNING_TEXT)%>
  3122. </TD>
  3123. </TR>
  3124. <TR>
  3125. <TD CLASS="TasksBody" WIDTH="15px">&nbsp;</TD>
  3126. <TD CLASS="TasksBody">
  3127. <INPUT TYPE="radio" CLASS="FormRadioButton" NAME="radUploadMethod"
  3128. VALUE="<%=UPLOADMETHOD_FTP%>" <%=strFTPAttributes%>>
  3129. <TD CLASS="TasksBody" NOWRAP>
  3130. <%=Server.HTMLEncode(L_CREATE_FTP_SITE)%>
  3131. </TD>
  3132. </TR>
  3133. <TR>
  3134. <TD CLASS="TasksBody" WIDTH="15px">&nbsp;</TD>
  3135. <TD CLASS="TasksBody">
  3136. <INPUT TYPE="radio" CLASS="FormRadioButton" NAME="radUploadMethod"
  3137. VALUE="<%=UPLOADMETHOD_NEITHER%>" <%=strNeitherAttributes%> ID="Radio1">
  3138. </TD>
  3139. <TD CLASS="TasksBody" NOWRAP>
  3140. <%=Server.HTMLEncode(L_CONTENT_UPLOADMETHOD_NEITHER)%>
  3141. </TD>
  3142. </TR>
  3143. <TR><TD CLASS="TasksBody" COLSPAN="3">&nbsp;</TD></TR>
  3144. <TR>
  3145. <TD CLASS="TasksBody" COLSPAN="3" NOWRAP>
  3146. <INPUT TYPE="checkbox" CLASS="formField" NAME="chkAllow" VALUE="ON"
  3147. <%=strAnonymousAttributes%>>
  3148. <%=Server.HTMLEncode(L_ALLOW_ANONYMOUS_ACCESS)%>
  3149. </TD>
  3150. </TR>
  3151. </TABLE>
  3152. <%
  3153. End Sub
  3154. %>