WSH实用讲座---第四讲 配置目录权限
浏览:57日期:2022-11-28
即配置目录的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 = 1const ntpRead = 2const ntpWrite = 4const ntpExecute = 8const ntpDelete = 16const ntpPermissions= 32const ntpOwnership = 64const ntpFileRights = 1const ntpDirRights = 2ntpChange = ntpRead + ntpWrite + ntpExecute + ntpDeletentpFull = ntpChange + ntpPermissions + ntpOwnershipRem -----------------------------------------------Rem 开始设置Rem -----------------------------------------------WScript.Echo "开始设置."Set ntp = CreateObject("NTAccess.Permissions")set acl = ntp.File("d:test", true )' add No Access entries firstacl.Add "Users" , ntpNoAccess, ntpFileRightsacl.Add "Users" , ntpNoAccess, ntpDirRights' now delete any ACE's we want to removeacl.Delete "Everyone", ntpFileRightsacl.Delete "Everyone", ntpDirRights' now add any other new ACE'sacl.Add "Administrators", ntpFull, ntpFileRightsacl.Add "Administrators", ntpFull, ntpDirRightsacl.Add "white", ntpChange, ntpFileRightsacl.Add "white", ntpChange, ntpDirRights' finally remember to call saveacl.saveWScript.Echo "已经完成设置!"使用cacls的一个例子如下:Set WshShell = Wscript.CreateObject("Wscript.Shell")userdir = "d:userdate"username = "white"argu = userdir & " /t /e /p " & username & ":f"WshShell.Run ("c:winntsystem32cacls " & argu)
上一条:WSH实用讲座---第三讲 创建邮箱下一条:ASP个人上手指南
相关文章:
热门推荐

- IE6中a标签同时使用inline-block与text-indent时出现的BUG
- 1.Golang 如何判断数组某个元素是否存在(isset)
- 2.intellijidea导入eclipse工程详细步骤
- 3.IE6的双倍,3px,注释引起的文字错位等几个BUG解决方法
- 4.PHP设计模式之策略模式原理与用法实例分析
- 5.JS判断浏览器是否安装flash插件的简单方法
- 6.怎么解决360双核浏览器兼容模式的页面显示问题?解决的方法介绍
- 7.Golang 使用map需要注意的几个点
- 8.构建Golang应用最小Docker镜像的实现
- 9.WSH实用讲座---第四讲 配置目录权限
- 10.用ASP.NET开发Web服务的五则技巧
