|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
其实Java之所以在曾经独步天下,就是因为他的跨平台、安全性,这两方面,效率可不是Java的强项,反而是他最短的一块挡板,虽然net总是用理论证明比.NET快。iis|创立|剧本|假造目次两种言语在IIS中创立假造目次
用.net在IIS中创立假造目次
利用.NET的目次服务就能够会见IIS的设置,增加假造目次实在就是创立一个DirectoryEntry
庞大的在于DirectoryEntry的属性,实在就是假造目标一些设置,好比,权限,是不是要log,使用程序名等
Properties十分多,并且文档不太好找
具体能够参考MSDN以下内容
help://MS.MSDNQTR.2004JUL.1033/iissdk/iis/configuring_properties_in_the_iis_user_interface.htm
代码示例:
constStringconstIISWebSiteRoot="IIS://localhost/W3SVC/1/ROOT";
DirectoryEntryroot=newDirectoryEntry(constIISWebSiteRoot);
DirectoryEntryentry=newDirectoryEntry(constIISWebSiteRoot+"/"+virtualDirName);
DirectoryEntrytbEntry=root.Children.Add(virtualDirName,"IIsWebVirtualDir");
//mustbeendwitha
tbEntry.Properties["Path"][0]=virtualDirPath;
tbEntry.Invoke("AppCreate",true);
tbEntry.Properties["AccessRead"][0]=true;
tbEntry.Properties["ContentIndexed"][0]=false;
tbEntry.Properties["DefaultDoc"][0]="index.asp";
tbEntry.Properties["AppFriendlyName"][0]=virtualDirName;
tbEntry.Properties["AppIsolated"][0]=2;
tbEntry.Properties["AccessScript"][0]=true;
tbEntry.Properties["DontLog"][0]=true;
tbEntry.CommitChanges();
//************************************************************
用windows剧本言语创立假造目次.
Setshell=Wscript.CreateObject("WScript.Shell")
IfWscript.Arguments.Count<2Then
usage="USAGE:theVbsvirtual_directory_namedirectory_location_to_map"
WScript.Echousage
Wscript.Quit
EndIf
vDirName=Wscript.Arguments(0)
vDirPath=Wscript.Arguments(1)
Getthenameofthecurrentdirectory
Setfso=WScript.CreateObject("Scripting.FileSystemObject")
vDirPath=fso.GetFolder(vDirPath).Path
DoesthisIISapplicationalreadyexistinthemetabase?
OnErrorResumeNext
SetobjIIS=GetObject("IIS://localhost/W3SVC/1/Root/"&vDirName)
IfErr.Number=0Then
result=shell.Popup("Avirtualdirectorynamed"&vDirName&"alreadyexists."&vbCrLf&vbCrLf&"Wouldyoulikeitre-mappedforthissample?",0,"RemapVirtualDirectory?",4+32)4=YesNo&32=Question
Ifresult=6Then6=Yes
DeleteVirtualDirectoryvDirName
Else
WScript.Quit
EndIf
EndIf
UsingIISAdministrationobject,turnonscript/executepermissionsanddefinethevirtualdirectoryasanin-processapplication.
SetobjIIS=GetObject("IIS://localhost/W3SVC/1/Root")
SetvDirObj=objIIS.Create("IISWebVirtualDir",vDirName)
vDirObj.Path=vDirPath
vDirObj.AuthNTLM=True
vDirObj.AccessRead=True
vDirObj.AccessWrite=True
vDirObj.AccessScript=True
vDirObj.AccessExecute=True
vDirObj.AuthAnonymous=True
vDirObj.AnonymousUserName=owner
vDirObj.AnonymousPasswordSync=True
vDirObj.AppCreateTrue
vDirObj.SetInfo
IfErr.Number>0Then
shell.PopupErr.Description,0,"Error",1616=Stop
WScript.Quit
EndIf
GetthenameoftheaccountfortheanonymoususerinIIS
owner=vDirObj.AnonymousUserName
ChangenecessaryfolderpermissionsusingCACLS.exe
aclCmd="cmd/cechoy|CACLS"
aclCmd=aclCmd&""""&vDirPath&""""
aclCmd=aclCmd&"/E/G"&owner&":C"
rtc=shell.Run(aclCmd,0,True)
aclCmd="cmd/cechoy|CACLS"
aclCmd=aclCmd&""""&vDirPath&""""
aclCmd=aclCmd&"/E/G""VSDevelopers"":C"
rtc=shell.Run(aclCmd,0,True)
IfErr.Number>0Then
shell.PopupErr.Description,0,"Error",1616=Stop
WScript.Quit
Else
res=vDirName&"hasbeencreatedat"&vbCrLf&vDirPath
shell.Popupres,0,"Alldone",6464=Information
EndIf
SubDeleteVirtualDirectory(NameOfVdir)
Setiis=GetObject("IIS://localhost/W3SVC/1/Root")
iis.Delete"IISWebVirtualDir",vDirName
IfErr.Number0Then
errorString="Unabletodeleteexisitingvirtualdirectory."
IfErr.DescriptionIsNothingThen
errorString=errorString&"ErrorCode:"&Err.Number
Else
errorString=errorString&"Description:"&Err.Description
EndIf
shell.PopuperrorString,0,"Error",1616=Stop
EndIf
EndSub
//********************end
2003年中微软发布最新版本的ASP.netWebMatrix,对于我们喜欢用Asp.net来编程的朋友实在是个好消息,我也实实在在的将Asp.net更深入的研究了一下,以方便我以后更好的运用它,同时我也讲讲使用它的感受。 |
|