ASP能否做到管理IIS控制,如域名解析,DNS分析等!

GoTibet 2004-11-25 11:04:16
做一个互动平台,这样在域名审请,解析,IP指定等IIS功能,不知ASP能否做到,如能,能否提供思路,谢谢,
...全文
317 点赞 收藏 32
写回复
32 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
GoTibet 2005-01-11
结贴了,分都分不过来,呵呵,
回复
micher_yan 2004-12-11
IIS不管域名解析,域名解析需要控制dns才可以实现
回复
yonghengdizhen 2004-12-11
可以实现,安全问题上,可以考虑采用ssl
回复
manonroad 2004-12-11
我也在尝试做一个类似的东西。不知道楼主有没有搞定?
回复
lingyun2111 2004-12-01
试试 king2003(鱼) 的做法,成功告诉我一声^_^
回复
king2003 2004-12-01
楼主上面的代码我也没能试过,不过应该可以的,希望你成功之后告诉我谢.
回复
zhouyouok 2004-11-30
好像以前有人问过类似的问题,不过没有解决,不过我相信肯定有解决的办法。
回复
tojworks 2004-11-30
要用组件!
回复
dsclub 2004-11-30
活动目录的可以!

不错的帖子!
回复
elongnet618 2004-11-30
做一个组件
回复
cdsun 2004-11-30
mark
回复
tigerhu76 2004-11-30
mark
回复
phoubes 2004-11-30
采用组件的方式,纯asp代码做不到的,我是说操作主机头哦
回复
king2003 2004-11-30
不过权限要求比较高好像得是Administrator的
回复
king2003 2004-11-30
1.创建用户
下面这段代码在独立服务器white上创建用户user1,初始口令user1,用到了ADSI.
Dim Username,UserPass
Dim oDomain,oUser
Username = "user1"
UserPass = "user1"
Set oDomain = GetObject("WinNT://white")
Set oUser = oDomain.Create ("user", UserName)
If (err.number = 0) Then
oUser.SetInfo
oUser.SetPassword UserPass
oUser.SetInfo
Else
WScript.Echo "创建用户" & UserName & "出错!"
End If
Set oUser = Nothing
Set oDomain = Nothing

2.创建目录
使用FileSystemObject创建目录:
Dim FsObject
Dim tmpFolder
Set FsObject = WScript.CreateObject("Scripting.FileSystemObject")
tmpFolder = "D:\userdate\user1"
If Not FsObject.FolderExists(tmpFolder) Then
FsObject.CreateFolder(tmpFolder)
If Err.Number<>0 Then
WScript.Echo "创建目录" & tmpFolder & "失败!"
End If
End If
注意在创建目录前,先检查了目录是否存在,如果存在,则不用创建了.

3.创建站点
下面这个子程序负责创建一个WWW站点,各个参数的意义为:站点IP地址,站点根目录,站点说明,主机名,端口号,计算机名(一搬为LOCALHOST),是否立即启动,匿名访问时所使用的帐号,匿名访问时所用帐号的口令,LOG文件的目录.
函数返回所建站点在IIS中的序号(在IIS中,所有站点依次编号,第一个为1).
一个调用示例:siteid = ASTCreateWebSite("10.1.3.122","d:\userdata\user1","www_user1","","80","LocalHost",True,"IUSR_user1","8iui%#","D:\Logfiles")

Function ASTCreateWebSite(IPAddress, RootDirectory, ServerComment, HostName, PortNum, Computer, Start,AnonymousUserName,AnonymousUserPass,LogFileDirectory)
Dim w3svc, WebServer, NewWebServer, NewDir
Dim Bindings, BindingString, NewBindings, Index, SiteObj, bDone
On Error Resume Next
Err.Clear
Set w3svc = GetObject("IIS://" & Computer & "/w3svc")
If Err.Number <> 0 Then
WScript.Echo "无法打开: "&"IIS://" & Computer & "/w3svc" & VbCrlf & "程序将退出."
WScript.Quit (1)
End If

BindingString = IpAddress & ":" & PortNum & ":" & HostName
For Each WebServer in w3svc
If WebServer.Class = "IIsWebServer" Then
Bindings = WebServer.ServerBindings
If BindingString = Bindings(0) Then
WScript.Echo "IP地址冲突:" & IpAddress & ",请检测IP地址!." & VbCrlf & "取消创建本站点。"
Exit Function
End If
End If
Next

Index = 1
bDone = False

While (Not bDone)
Err.Clear
Set SiteObj = GetObject("IIS://"&Computer&"/w3svc/" & Index)
If (Err.Number = 0) Then
Index = Index + 1
Else
Err.Clear
Set NewWebServer = w3svc.Create("IIsWebServer", Index)
If (Err.Number <> 0) Then
Index = Index + 1
Else
Err.Clear
Set SiteObj = GetObject("IIS://"&Computer&"/w3svc/" & Index)
If (Err.Number = 0) Then
bDone = True
Else
Index = Index + 1
End If
End If
End If

If (Index > 10000) Then
WScript.Echo "看起来不能创建站点,正在创建的站点的序号为: "&Index&"." & VbCrlf & "取消创建本站点。"
Exit Function
End If
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

Set NewDir = NewWebServer.Create("IIsWebVirtualDir", "ROOT")
NewDir.Path = RootDirectory
NewDir.AccessRead = true
NewDir.AppFriendlyName = "应用程序" & ServerComment
NewDir.AppCreate True
NewDir.AccessScript = True
Err.Clear
NewDir.SetInfo
If (Err.Number = 0) Then
Else
WScript.Echo "主目录创建时出错."
End If

If Start = True Then
Err.Clear
Set NewWebServer = GetObject("IIS://" & Computer & "/w3svc/" & Index)
NewWebServer.Start
If Err.Number <> 0 Then
WScript.Echo "启动站点时出错!"
Err.Clear
Else
End If
End If
ASTCreateWebSite = Index
End Function

下面函数创建FTP站点:
Function ASTCreateFtpSite(IPAddress, RootDirectory, ServerComment, HostName, PortNum, Computer, Start,LogFileDirectory)
Dim MSFTPSVC, FtpServer, NewFtpServer, NewDir
Dim Bindings, BindingString, NewBindings, Index, SiteObj, bDone
On Error Resume Next
Err.Clear
Set MSFTPSVC = GetObject("IIS://" & Computer & "/MSFTPSVC")
If Err.Number <> 0 Then
WScript.Echo "无法打开: "&"IIS://" & Computer & "/MSFTPSVC" & VbCrlf & "程序将退出."
WScript.Quit (1)
End If

BindingString = IpAddress & ":" & PortNum & ":" & HostName
For Each FtpServer in MSFTPSVC
If FtpServer.Class="IIsFtpServer" Then
Bindings = FtpServer.ServerBindings
If BindingString = Bindings(0) Then
WScript.Echo "IP地址冲突:" & IpAddress & ",请检测IP地址!." & VbCrlf & "取消创建本站点。"
Exit Function
End If
End If
Next

Index = 1
bDone = False

While (Not bDone)
Err.Clear
Set SiteObj = GetObject("IIS://"&Computer&"/MSFTPSVC/" & Index)
If (Err.Number = 0) Then
Index = Index + 1
Else
Err.Clear
Set NewFtpServer = MSFTPSVC.Create("IIsFtpServer", Index)
If (Err.Number <> 0) Then
Index = Index + 1
Else
Err.Clear
Set SiteObj = GetObject("IIS://"&Computer&"/MSFTPSVC/" & Index)
If (Err.Number = 0) Then
bDone = True
Else
Index = Index + 1
End If
End If
End If

If (Index > 10000) Then
WScript.Echo "看起来不能创建站点,正在创建的站点的序号为: "&Index&"." & VbCrlf & "取消创建本站点。"
Exit Function
End If
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

Set NewDir = NewFtpServer.Create("IIsFtpVirtualDir", "ROOT")
NewDir.Path = RootDirectory
NewDir.AccessRead = true
Err.Clear
NewDir.SetInfo
If (Err.Number = 0) Then
Else
WScript.Echo "主目录创建时出错."
End If

If Start = True Then
Err.Clear
Set NewFtpServer = GetObject("IIS://" & Computer & "/MSFTPSVC/" & Index)
NewFtpServer.Start
If Err.Number <> 0 Then
WScript.Echo "启动站点时出错!"
Err.Clear
Else
End If
End If
ASTCreateFtpSite = Index
End Function

回复
king2003 2004-11-30
还可以使用ADSI
回复
liuyangxuan 2004-11-30
楼上正解,用WMI!
回复
Jaron 2004-11-30
use WMI:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dns/dns/dns_wmi_provider_samples_managing_dns_resource_records.asp
回复
linfeng801111 2004-11-30
DDDDDDDDDDDDDD
回复
GoTibet 2004-11-29
没有顶,我再顶,谢谢
回复
加载更多回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-11-25 11:04
社区公告
暂无公告