首先,我甚至不知道“用户名”在这里是否正确。
上下文是我使用VisualSVN服务器来pipe理/pipe理我的SVN存储库上的访问权限与Windows身份validation,它创build的authz-windows文件包含45个字符长的string,而不是“人类可读”的用户或组名称。
我需要手动编辑这个文件,那么如何找出魔术string与特定的用户或组相关联?
authz-windows文件映射Active Directory用户和组SID( objectSid LDAP字段)。
但请注意,AD中此字段的值以hex存储,因此您可以使用以前的一些答案来确定分配的用户标识。
(在StackOverflow上的PowerShell示例 。)
2016年更新:
升级到最新的VisualSVN服务器版本。 从VisualSVN Server 3.4开始,服务器带有一些PowerShell cmdlet。 其中一些像Get-SvnAccessRule可以输出分配给Active Directory / Windows用户和组帐户的访问规则列表。
以下是在CSV文件AccessReport.csv中生成访问规则报告的示例:
Get-SvnAccessRule | Select Repository, Path, AccountName, Access | Export-Csv -NoTypeInformation AccessReport.csv
有关VisualSVN Server PowerShell cmdlet的完整信息,请阅读文章KB88:VisualSVN Server PowerShell Cmdlet参考 。
过时的回答:
我同意宿醉的答案,并希望你会发现下面的VBScript有帮助。 它会创build一个定义的权限列表,并正确地将SID转换为有意义且可读的DOMAIN \ Username 。
' ' 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 ' Return user name associated with account Function GetAccountName(account) If account.Path_.Class = "VisualSVN_WindowsAccount" Then GetAccountName = SidToUserName(account.SID) Else GetAccountName = account.Name End If 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 name = GetAccountName(perm.Account) level = AccessLevelToText(perm.AccessLevel) Wscript.Echo name & "," & GetPath(assoc) & "," & level Next Next