欢迎光临
我们一直在努力

用ADSI编程实现IIS中建立虚拟目录-ASP教程,脚本编码

建站超值云服务器,限时71元/月

conn.asp不再贴出。

这里从数据库中读出目录名

<!–#include file="conn.asp"–>

<%

response.end //这是做调试时用的

on error resume next

set rs=server.createobject("adodb.recordset")

rs.activeconnection = myconnection

sql="select * from 你的表名 where 你指定的条件"

rs.open sql,,1,2

if rs.eof then response.end //如果无符合条件记录,则停止

rs.movefirst

dim namestr //定义虚拟目录名变量

do while not rs.eof

if instr(1,namestr,server.htmlencode(trim(rs("suname"))))<>0 then rs.movenext

name=name&server.htmlencode(trim(rs("suname")))

%>

<%

scomputer ="localhost"

sphydir = "x: est" & server.htmlencode(trim(rs("suname"))) //这里定义虚拟目录指向的物理路径

svirdir = server.htmlencode(trim(rs("suname"))) //这里定义虚拟目录名

set websvc = getobject("iis://" & scomputer & "/w3svc/1") //获得你当前站点对象。若有多个站点,那么改动后面1为2,3…即可指向其它的

set vroot = websvc.getobject("iiswebvirtualdir", "root") //获得当前站点虚拟root

set classdefinition = getobject(vroot.schema) //获得虚拟目录的类定义

asmusthaves = classdefinition.mandatoryproperties

asmayhaves = classdefinition.optionalproperties

i=1

%>

<table border=1>

<tr><th>class must have property</th>

<th>root virtual directory current value</th></tr>

<%

on error resume next

for each thing in asmusthaves

response.write "<tr><td>("& cstr(i) & ") " &_

thing & "</td><td>" & vroot.get(thing) &_

"</td></tr>"

i = i + 1

next

%>

</table>

<table border=1>

<tr><th>class may have property</th>

<th>当前站点</th></tr>

<%

i=1

for each thing in asmayhaves

response.write "<tr><td>("& cstr(i) & ") " &_

thing & "</td><td>" & vroot.get(thing) &_

"</td></tr>"

i = i + 1

next

on error goto 0

//建立虚拟目录

response.write svirdir & "

"

set vdir = vroot.create("iiswebvirtualdir",svirdir)

//设置虚拟目录的两个属性,这里设置可读属性和将虚拟目录的路径指向物理路径

vdir.accessread = true

vdir.path = sphydir

vdir.setinfo //将信息写入库,指的iis站点相关的库,不是你的用户数据表

%>

<%

rs.movenext

loop

rs.close

response.write "创建虚拟目录完成!"

%>

另外,还有利用adsi进行站点设置比如建站点,删除站点,配置站点ip,主机头,默认文档的等等,这里不做下载,有兴趣的朋友可以到微软站点下载 adsisdk 的开发文档深入。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用ADSI编程实现IIS中建立虚拟目录-ASP教程,脚本编码
分享到: 更多 (0)

相关推荐

  • 暂无文章