从 Visual SVN 检索访问权限报告的 VB 脚本 [英] VB script to retrieve Access Rights Reporting from Visual SVN

查看:40
本文介绍了从 Visual SVN 检索访问权限报告的 VB 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在进行 SID 转换时,我发现在测试机器上安装了 VirsualSVN 的可行脚本,但该脚本在服务器上不起作用.我将文件保存为 test.vbs 放在桌面上,并使用以下命令执行代码并生成文本文件的输出:cscript test.vbs > c:\output.txt

While I'm working on SID conversion, I found the workable script with the VirsualSVN installed on the test machine, but the script was not working on the server. I saved file as test.vbs put on the desktop and use the following command to execute the code and produce the output as the text file: cscript test.vbs > c:\output.txt

在测试机器上,我安装了 VisualSVN 版本 2.5.8 并且 根存储库位于 C:\Repositories

On the test machine, I installed VisualSVN version 2.5.8 and root repositories is on C:\Repositories

在服务器上,安装了 VisualSVN 版本 1.6.3根存储库位于 E:\Repositories

While on the server, installed VisualSVN version 1.6.3 and root repositories is on E:\Repositories

从下面的脚本来看,我缺乏编码,不知道应该在哪里修改脚本以使其在服务器上运行?我正在寻求您的专家帮助.

From the script below, I'm lack in coding and no idea where should I modify the script to make it work on the server? I'm seeking your expert help on this.

'
' 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

推荐答案

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

0x8004100e means that the namespace (/root/VisualSVN) doesn't exist. Perhaps the version installed on the server is too old and doesn't create this namespace in WMI.

这篇关于从 Visual SVN 检索访问权限报告的 VB 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆