|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
缺乏可以共同遵循的行业标准,ASP还处在发展初期,大家对它的理解不同,如产品和服务标准,收费标准等,不利于行业的健康发展。创立|站点
本讲将利用到ADSI,即举动目次服务接口.能够到15Seconds.com找到一些相干的材料.
1.创立用户
上面这段代码在自力服务器white上创立用户user1,初始口令user1,用到了ADSI.
DimUsername,UserPass
DimoDomain,oUser
Username="user1"
UserPass="user1"
SetoDomain=GetObject("WinNT://white")
SetoUser=oDomain.Create("user",UserName)
If(err.number=0)Then
oUser.SetInfo
oUser.SetPasswordUserPass
oUser.SetInfo
Else
WScript.Echo"创立用户"&UserName&"堕落!"
EndIf
SetoUser=Nothing
SetoDomain=Nothing
2.创立目次
利用FileSystemObject创立目次:
DimFsObject
DimtmpFolder
SetFsObject=WScript.CreateObject("Scripting.FileSystemObject")
tmpFolder="D:userdateuser1"
IfNotFsObject.FolderExists(tmpFolder)Then
FsObject.CreateFolder(tmpFolder)
IfErr.Number0Then
WScript.Echo"创立目次"&tmpFolder&"失利!"
EndIf
EndIf
注重在创立目次前,先反省了目次是不是存在,假如存在,则不必创立了.
3.创立站点
上面这个子程序卖力创立一个WWW站点,各个参数的意义为:站点IP地点,站点根目次,站点申明,主机名,端标语,盘算机名(一搬为LOCALHOST),是不是当即启动,匿名会见时所利用的帐号,匿名会见时所用帐号的口令,LOG文件的目次.
函数前往所建站点在IIS中的序号(在IIS中,一切站点顺次编号,第一个为1).
一个挪用示例:siteid=ASTCreateWebSite("10.1.3.122","d:userdatauser1","www_user1","","80","LocalHost",True,"IUSR_user1","8iui%#","D:Logfiles")
FunctionASTCreateWebSite(IPAddress,RootDirectory,ServerComment,HostName,PortNum,Computer,Start,AnonymousUserName,AnonymousUserPass,LogFileDirectory)
Dimw3svc,WebServer,NewWebServer,NewDir
DimBindings,BindingString,NewBindings,Index,SiteObj,bDone
OnErrorResumeNext
Err.Clear
Setw3svc=GetObject("IIS://"&Computer&"/w3svc")
IfErr.Number0Then
WScript.Echo"没法翻开:"&"IIS://"&Computer&"/w3svc"&VbCrlf&"程序将加入."
WScript.Quit(1)
EndIf
BindingString=IpAddress&":"&PortNum&":"&HostName
ForEachWebServerinw3svc
IfWebServer.Class="IIsWebServer"Then
Bindings=WebServer.ServerBindings
IfBindingString=Bindings(0)Then
WScript.Echo"IP地点抵触:"&IpAddress&",请检测IP地点!."&VbCrlf&"作废创立本站点。"
ExitFunction
EndIf
EndIf
Next
Index=1
bDone=False
While(NotbDone)
Err.Clear
SetSiteObj=GetObject("IIS://"&Computer&"/w3svc/"&Index)
If(Err.Number=0)Then
Index=Index+1
Else
Err.Clear
SetNewWebServer=w3svc.Create("IIsWebServer",Index)
If(Err.Number0)Then
Index=Index+1
Else
Err.Clear
SetSiteObj=GetObject("IIS://"&Computer&"/w3svc/"&Index)
If(Err.Number=0)Then
bDone=True
Else
Index=Index+1
EndIf
EndIf
EndIf
If(Index>10000)Then
WScript.Echo"看起来不克不及创立站点,正在创立的站点的序号为:"&Index&"."&VbCrlf&"作废创立本站点。"
ExitFunction
EndIf
Wend
NewBindings=Array(0)
NewBindings(0)=BindingString
NewWebServer.ServerBindings=NewBindings
NewWebServer.ServerComment=ServerComment
NewWebServer.AnonymousUserName=AnonymousUserName
NewWebServer.AnonymousUserPass=AnonymousUserPass
NewWebServer.KeyType="IIsWebServer"
NewWebServer.FrontPageWeb=True
NewWebServer.EnableDefaultDoc=True
NewWebServer.DefaultDoc="Default.htm,Default.asp,Index.htm,Index.asp"
NewWebServer.LogFileDirectory=LogFileDirectory
NewWebServer.SetInfo
SetNewDir=NewWebServer.Create("IIsWebVirtualDir","ROOT")
NewDir.Path=RootDirectory
NewDir.AccessRead=true
NewDir.AppFriendlyName="使用程序"&ServerComment
NewDir.AppCreateTrue
NewDir.AccessScript=True
Err.Clear
NewDir.SetInfo
If(Err.Number=0)Then
Else
WScript.Echo"主目次创立时堕落."
EndIf
IfStart=TrueThen
Err.Clear
SetNewWebServer=GetObject("IIS://"&Computer&"/w3svc/"&Index)
NewWebServer.Start
IfErr.Number0Then
WScript.Echo"启动站点时堕落!"
Err.Clear
Else
EndIf
EndIf
ASTCreateWebSite=Index
EndFunction
上面函数创立FTP站点:
FunctionASTCreateFtpSite(IPAddress,RootDirectory,ServerComment,HostName,PortNum,Computer,Start,LogFileDirectory)
DimMSFTPSVC,FtpServer,NewFtpServer,NewDir
DimBindings,BindingString,NewBindings,Index,SiteObj,bDone
OnErrorResumeNext
Err.Clear
SetMSFTPSVC=GetObject("IIS://"&Computer&"/MSFTPSVC")
IfErr.Number0Then
WScript.Echo"没法翻开:"&"IIS://"&Computer&"/MSFTPSVC"&VbCrlf&"程序将加入."
WScript.Quit(1)
EndIf
BindingString=IpAddress&":"&PortNum&":"&HostName
ForEachFtpServerinMSFTPSVC
IfFtpServer.Class="IIsFtpServer"Then
Bindings=FtpServer.ServerBindings
IfBindingString=Bindings(0)Then
WScript.Echo"IP地点抵触:"&IpAddress&",请检测IP地点!."&VbCrlf&"作废创立本站点。"
ExitFunction
EndIf
EndIf
Next
Index=1
bDone=False
While(NotbDone)
Err.Clear
SetSiteObj=GetObject("IIS://"&Computer&"/MSFTPSVC/"&Index)
If(Err.Number=0)Then
Index=Index+1
Else
Err.Clear
SetNewFtpServer=MSFTPSVC.Create("IIsFtpServer",Index)
If(Err.Number0)Then
Index=Index+1
Else
Err.Clear
SetSiteObj=GetObject("IIS://"&Computer&"/MSFTPSVC/"&Index)
If(Err.Number=0)Then
bDone=True
Else
Index=Index+1
EndIf
EndIf
EndIf
If(Index>10000)Then
WScript.Echo"看起来不克不及创立站点,正在创立的站点的序号为:"&Index&"."&VbCrlf&"作废创立本站点。"
ExitFunction
EndIf
Wend
NewBindings=Array(0)
NewBindings(0)=BindingString
NewFtpServer.ServerBindings=NewBindings
NewFtpServer.ServerComment=ServerComment
NewFtpServer.AllowAnonymous=False
NewFtpServer.AccessWrite=True
NewFtpServer.AccessRead=True
NewFtpServer.DontLog=False
NewFtpServer.LogFileDirectory=LogFileDirectory
NewFtpServer.SetInfo
SetNewDir=NewFtpServer.Create("IIsFtpVirtualDir","ROOT")
NewDir.Path=RootDirectory
NewDir.AccessRead=true
Err.Clear
NewDir.SetInfo
If(Err.Number=0)Then
Else
WScript.Echo"主目次创立时堕落."
EndIf
IfStart=TrueThen
Err.Clear
SetNewFtpServer=GetObject("IIS://"&Computer&"/MSFTPSVC/"&Index)
NewFtpServer.Start
IfErr.Number0Then
WScript.Echo"启动站点时堕落!"
Err.Clear
Else
EndIf
EndIf
ASTCreateFtpSite=Index
EndFunction
结论:和PHP一样,ASP简单而易于维护,很适合小型网站应用,通过DCOM和MTS技术,ASP甚至还可以完成小规模的企业应用,但ASP的致命缺点就是不支持跨平台的系统,在大型项目开发和维护上非常困难。 |
|