【问题标题】:VB script to retrieve Access Rights Reporting from Visual SVN从 Visual SVN 检索访问权限报告的 VB 脚本
【发布时间】: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


【解决方案1】:

0x8004100e 表示命名空间 (/root/VisualSVN) 不存在。可能是服务器上安装的版本太旧,没有在 WMI 中创建这个命名空间。

【讨论】:

  • 这是我的想法,但想确保在升级版本之前@AnsgarWiechers 感谢您的及时回复,然后我现在需要找到转换基于 Windows 的权限文件的方法( authz-windows), 可读用户名的 SID 格式
  • @bahrep 感谢脚本,我已将其保存以供升级 VisualSVN 版本后使用。
【解决方案2】:

按照@Ansgar 的回答。

VisualSVN Server 2.0 之前的版本无法通过 WMI 进行管理。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    • 2021-04-10
    • 2012-01-13
    相关资源
    最近更新 更多