欢迎光临
我们一直在努力

wsh实用讲座—第四讲 配置目录权限_asp教程

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

即配置目录的ACL,至于该如何配置权限,才能让你的服务器是安全的,那得根据你自己的客观实际了,而且,这也是商业秘
密。我这里只是说明用脚本实现的方法。

  有两种方法可以完成这个任务(也许还有其他的方法),一种是采用第三方组件(我经常使用的是NTAccess.Permission,这
是个要MONEY的东东,但是我把系统时间改成1997年4月25日,这样,它就不认为我过期了,等执行完脚本,我再改回1999年4月25
日,呵呵。另外一个是SA的FILEMANAGER,功能强大,但体积也大);另一种是在WSH里调用NT的命令行cacls.exe,它的用法为
(摘自NT的帮助文件):

Cacls

显示或修改文件访问控制表(ACL)。

cacls filename [/t] [/e] [/c] [/g user:perm] [/r user […]] [
/p user:perm […]] [/d user […]]

参数

filename

显示文件或指定文件的访问控制表 ACL 。

/t

在当前目录及所有子目录下改变指定文件的 ACL 。

/e

编辑 ACL,但不替换。

/c

继续更改 ACL,并忽略错误。

/g user:perm

将访问权授予指定用户。Perm 可以是:
r  读取
c  更改(写)
f  完全控制

/r user

撤消指定用户的访问权。

/p user:perm

还原指定用户的访问权。Perm 可以是:

n  无
r   读取
c  更改(写)
f  完全控制

/d user

拒绝指定用户的访问。

可以在一个命令中指定多个文件或用户。

  使用NTAccess.Permission的一个例子如下:

Rem —————————-
Rem 定义常量
Rem —————————-
const ntpNoAccess = 1
const ntpRead = 2
const ntpWrite = 4
const ntpExecute = 8
const ntpDelete = 16
const ntpPermissions= 32
const ntpOwnership = 64

const ntpFileRights = 1
const ntpDirRights = 2

ntpChange = ntpRead + ntpWrite + ntpExecute + ntpDelete
ntpFull = ntpChange + ntpPermissions + ntpOwnership

Rem ———————————————–
Rem 开始设置
Rem ———————————————–
WScript.Echo "开始设置."
Set ntp = CreateObject("NTAccess.Permissions")

set acl = ntp.File("d:\test", true )

add No Access entries first
acl.Add "Users" , ntpNoAccess, ntpFileRights
acl.Add "Users" , ntpNoAccess, ntpDirRights

now delete any ACEs we want to remove
acl.Delete "Everyone", ntpFileRights
acl.Delete "Everyone", ntpDirRights

now add any other new ACEs
acl.Add "Administrators", ntpFull, ntpFileRights
acl.Add "Administrators", ntpFull, ntpDirRights

acl.Add "white", ntpChange, ntpFileRights
acl.Add "white", ntpChange, ntpDirRights

finally remember to call save
acl.save
WScript.Echo "已经完成设置!"

  使用cacls的一个例子如下:

Set WshShell = Wscript.CreateObject("Wscript.Shell")
userdir = "d:\userdate"
username = "white"
argu = userdir & " /t /e /p " & username & ":f"
WshShell.Run ("c:\winnt\system32\cacls " & argu)

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » wsh实用讲座—第四讲 配置目录权限_asp教程
分享到: 更多 (0)