【发布时间】:2013-04-01 17:39:06
【问题描述】:
在进行 SID 转换时,我发现在测试机器上安装了 VirsualSVN 的可行脚本,但该脚本在服务器上不工作。我将文件保存为 test.vbs 放在桌面上并使用以下命令执行代码并将输出生成为文本文件:cscript test.vbs > c:\output.txt
在测试机器上,我安装了 VisualSVN 版本 2.5.8 并且 root repositories 在 C:\Repositories
在服务器上,安装 VisualSVN 版本 1.6.3 和 根存储库位于 E:\Repositories
从下面的脚本中,我缺乏编码,不知道应该在哪里修改脚本以使其在服务器上工作?我正在寻求您的专家帮助。
'
' Print permissions in the form: user_name,path,level
'
strComputer = "."
Set wmi = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\VisualSVN")
Set win = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
' Return text representation for the Access Level
Function AccessLevelToText(level)
If level = 0 Then
AccessLevelToText = "No Access"
ElseIf level = 1 Then
AccessLevelToText = "Read Only"
ElseIf level = 2 Then
AccessLevelToText = "Read/Write"
Else
AccessLevelToText = "Unknown"
End If
End Function
' Return repository path for the object
Function GetPath(obj)
cname = assoc.Path_.Class
If cname = "VisualSVN_Service" Then
GetPath = "Repositories Root"
ElseIf cname = "VisualSVN_Repository" Then
GetPath = assoc.Name
ElseIf cname = "VisualSVN_RepositoryEntry" Then
GetPath = assoc.RepositoryName & ": " & assoc.Path
Else
GetPath = "Unknown"
End If
End Function
' Convert SID to user name
Function SidToUserName(sid)
Set account = win.Get("Win32_SID.SID='" & sid & "'")
user = account.AccountName
domain = account.ReferencedDomainName
SidToUserName = domain & "\" & user
End Function
' Iterate over all security descriptions
Set objs = wmi.ExecQuery("SELECT * FROM VisualSVN_SecurityDescriptor")
For Each obj In objs
Set assoc = wmi.Get(obj.AssociatedObject)
For Each perm in obj.Permissions
sid = perm.Account.SID
level = AccessLevelToText(perm.AccessLevel)
Wscript.Echo SidToUserName(sid) & "," & GetPath(assoc) & "," & level
Next
Next
来自http://www.svnforum.org/threads/38790-Access-Rights-Reporting-in-Subversion-or-Viusal-SVN的代码参考
【问题讨论】:
-
那么,这个“不起作用”到底是怎么回事?你得到的和你期望的有什么不同?你有错误吗?哪个?
-
在测试机器上,当我运行命令时: cscript test.vbs 它会产生 user_name,path,level 格式的结果,但是在服务器上我收到此错误:test.vbs
: 0x8004100E -
如果有帮助,您可以接受和/或投票赞成答案。谢谢!
标签: vbscript visualsvn user-permissions