ASP IIS アドミニストレーション

  目次







  リモート管理用の仮想ディレクトリを含めたベースディレクトリの作成



ベースディレクトリ : C:\IISMyDirectory
管理ディレクトリ( 仮想ディレクトリ用 ) : C:\IISMyDirectory\IISMyAdmin

IISMyAdmin へのアクセス制限は、NTFS のセキュリティで行います

IIS が稼動しているコンピュータにアドミニストレータ権限でログインし、
以下のスクリプトを実行します

  
TargetFolder = "C:\IISMyDirectory"

Set Fs = CreateObject("Scripting.FileSystemObject")

if Fs.FolderExists( TargetFolder ) Then
	Wscript.Echo TargetFolder & " は既に存在します"
	Wscript.Quit
end if

Call Fs.CreateFolder( TargetFolder )
Set objFolder = Fs.CreateFolder( TargetFolder & "\IISMyAdmin" )

strVDir = "IIS://localhost/W3SVC/1/Root/" & objFolder.Name

bExist = True

on error resume next
Set IIsWebVDirObj = GetObject(strVDir)
if Err.Number <> 0 then
	Set IIsWebVDirRootObj = GetObject("IIS://localhost/W3SVC/1/Root") 
	Set IIsWebVDirObj = IIsWebVDirRootObj.Create("IIsWebVirtualDir", objFolder.Name ) 
	IIsWebVDirObj.Put "Path", TargetFolder & "\IISMyAdmin"
	IIsWebVDirObj.SetInfo
	bExist = False
end if
on error goto 0

if bExist then
	Wscript.Echo "仮想ディレクトリ " & objFolder.Name & " は既に存在します"
	Wscript.Quit
end if

' 匿名認証を不可,基本認証不可、統合Windows認証可
IIsWebVDirObj.Put "AuthFlags", &h4

IIsWebVDirObj.Put "AccessScript", True		' .asp ファイルの実行を許可
IIsWebVDirObj.Put "AccessExecute", True		' 実行可能ファイルの実行を許可

IIsWebVDirObj.Put "AccessSource", False		' スクリプトソースアクセス
IIsWebVDirObj.Put "AccessRead", True		' 読み取り
IIsWebVDirObj.Put "AccessWrite", True		' 書き込み

IIsWebVDirObj.Put "EnableDirBrowsing", True		' ディレクトリの参照
IIsWebVDirObj.Put "DontLog", False			' ログ アクセス
IIsWebVDirObj.Put "ContentIndexed", False		' このリソースに索引を付ける

IIsWebVDirObj.AppCreate2 2			' 0:低,1:高,2:中
IIsWebVDirObj.Put "AppFriendlyName", objFolder.Name
IIsWebVDirObj.Put "AspAllowSessionState", True	' セッション有効
IIsWebVDirObj.Put "AspSessionTimeout", 20		' セッションタイムアウト(分)
IIsWebVDirObj.Put "AspBufferingOn", True		' バッファ処理
IIsWebVDirObj.Put "AspEnableParentPaths", True	' 親のパスを有効にする
IIsWebVDirObj.Put "AspScriptTimeout", 90		' スクリプトタイムアウト(秒)

IIsWebVDirObj.Put "EnableDefaultDoc", True
IIsWebVDirObj.Put "DefaultDoc", "index.htm,index.html"

IIsWebVDirObj.Put "AspScriptFileCacheSize", False

IIsWebVDirObj.SetInfo

Wscript.Echo "仮想ディレクトリ " & objFolder.Name & " を作成しました   "
  



  既存仮想ディレクトリのメタベースプロパティのメンテナンス

以下のコードは、ディレクトリの参照を許す かどうかというプロパティと、
書き込みを許す かどうかというプロパティの設定例です

/IISMyAdmin/MetaBasePropMtn.asp
  
<%
Call Response.AddHeader( "Content-Type", "text/html; Charset=shift_jis" )
Response.ExpiresAbsolute=#May 31,2000 23:59:59#

' **********************************************************
' MODEL
' **********************************************************
function UpdateMetaProp()

	if IsEmpty( IIsWebVDir ) then
		Exit Function
	end if

	' ディレクトリの参照
	if Request.Form( "EnableDirBrowsing" ) = 1 then
		'  ( プロパティを利用してセット )
		IIsWebVDir.EnableDirBrowsing = True
	else
		IIsWebVDir.EnableDirBrowsing = False
	end if
	' 書き込み
	strProp = "AccessWrite"
	if Request.Form( strProp ) = 1 then
		'  ( メソッドを利用してセット )
		IIsWebVDir.Put strProp, True
	else
		IIsWebVDir.Put strProp, False
	end if
	IIsWebVDir.SetInfo

end function

' **********************************************************
' CONTROL
' **********************************************************
	if Request.Form( "VDIR" ) <> "" then
		strVDir = "IIS://localhost/W3SVC/1/Root/" & Request.Form( "VDIR" )
		on error resume next
		Set IIsWebVDir = GetObject(strVDir)
		if Err.Number <> 0 then
			strMessage = "指定した仮想ディレクトリは存在しません"
			Set IIsWebVDir = Nothing
			IIsWebVDir = Empty
		end if
		on error goto 0
	end if

	if Request.Form( "send" ) = "更新" then
		Call UpdateMetaProp()
	end if

%>

<!-- **********************************************************
  VIEW
*********************************************************** -->
<FORM method=POST>
仮想ディレクトリ名 <INPUT type=text name=VDIR value="<%= Request.Form( "VDIR" ) %>">
<INPUT type=submit name=send value="表示">
<INPUT type=submit name=send value="更新">
<HR>
<%= strMessage %>
<% if not IsEmpty( IIsWebVDir ) then %>

<PRE>
<%= IIsWebVDir.Path %>

ディレクトリの参照 <INPUT type=checkbox name=EnableDirBrowsing value=1
 <% if IIsWebVDir.EnableDirBrowsing then Response.Write "checked" end if %>>
書き込み <INPUT type=checkbox  name=AccessWrite value=1
 <% if IIsWebVDir.AccessWrite then Response.Write "checked" end if %>>
</PRE>

<%	end if %>

</FORM>
  



  開発用仮想ディレクトリ作成

/IISMyAdmin/CreateVDir.asp
  
<%
Call Response.AddHeader( "Content-Type", "text/html; Charset=shift_jis" )
Response.ExpiresAbsolute=#May 31,2000 23:59:59#

Dim strMessage

' **********************************************************
' MODEL
' **********************************************************
function CreateVDir()

	if Trim( Request.Form("VDIR") ) = "" then
		strMessage = "仮想ディレクトリを入力して下さい"
		Exit Function
	end if

	BaseFolder = "C:\IISMyDirectory"
	TargetFolder = BaseFolder & "\" & Request.Form("VDIR")

	Set Fs = CreateObject("Scripting.FileSystemObject")

	if Fs.FolderExists( TargetFolder ) Then
		strMessage = TargetFolder & " は既に存在します"
		Exit Function
	end if

	Call Fs.CreateFolder( TargetFolder )

	strVDir = "IIS://localhost/W3SVC/1/Root/" & Request.Form("VDIR")

	bExist = True

	on error resume next
	Set obj = GetObject(strVDir)
	if Err.Number <> 0 then
		Set IIsWebVDirRootObj = GetObject("IIS://localhost/W3SVC/1/Root") 
		Set obj = IIsWebVDirRootObj.Create _
			("IIsWebVirtualDir", Request.Form("VDIR") ) 
		obj.Put "Path", TargetFolder
		obj.SetInfo
		bExist = False
	end if
	on error goto 0

	if bExist then
		strMessage = "仮想ディレクトリ " _
			& Request.Form("VDIR") & " は既に存在します"
		Exit Function
	end if

	obj.Put "AccessScript", True
	obj.Put "AccessExecute", True

	obj.Put "AccessSource", False
	obj.Put "AccessRead", True
	obj.Put "AccessWrite", True

	obj.Put "EnableDirBrowsing", True
	obj.Put "DontLog", False
	obj.Put "ContentIndexed", False

	obj.AppCreate2 2
	obj.Put "AppFriendlyName", Request.Form("VDIR")
	obj.Put "AspAllowSessionState", True
	obj.Put "AspSessionTimeout", 20
	obj.Put "AspBufferingOn", True
	obj.Put "AspEnableParentPaths", True
	obj.Put "AspScriptTimeout", 90

	obj.Put "EnableDefaultDoc", True
	obj.Put "DefaultDoc", "index.htm,index.html"

	obj.Put "AspScriptFileCacheSize", False

	obj.SetInfo

	strMessage = "仮想ディレクトリ " _
		& Request.Form("VDIR") & " を作成しました"

end function

' **********************************************************
' CONTROL
' **********************************************************
	if Request.Form( "send" ) = "作成" then
		Call CreateVDir()
	end if

%>

<!-- **********************************************************
  VIEW
*********************************************************** -->
<FORM method=POST>
仮想ディレクトリ名 <INPUT type=text name=VDIR value="<%= Request.Form( "VDIR" ) %>">
<INPUT type=submit name=send value="作成">
<HR>
<%= strMessage %>
</FORM>
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ