1

与这篇文章有关从 C# 控制 VisualSVN 服务器

我正在尝试管理特定文件夹的用户权限。

对于存储库本身的管理,一切正常。

但是,一旦我尝试更改 aManagementBaseObject而不是ManagementObject存储库的“对象”参数,它就会引发异常。

我知道在较新版本的服务器中有一种新方法可以做同样的事情(用路径替换引用的对象)

//ManagementBase object related to the folder is not null and is already retrieved at this step
ManagementClass userClass = new ManagementClass("root\\VisualSVN", "VisualSVN_User", null);
ManagementClass authzClass = new ManagementClass("root\\VisualSVN", "VisualSVN_SecurityDescriptor", null);
ManagementClass permClass = new ManagementClass("root\\VisualSVN", "VisualSVN_PermissionEntry", null);

ManagementObject userObject = VisualSVN_User.instances[str].Mo;
ManagementObject permObject = permClass.CreateInstance();
permObject.SetPropertyValue("Account", userObject);
permObject.SetPropertyValue("AccessLevel", 2);

ManagementBaseObject inParams = authzClass.GetMethodParameters("SetSecurity");

inParams["Object"] = entry; 
inParams["Permissions"] = new object[] { permObject };

ManagementBaseObject outParams = authzClass.InvokeMethod("SetSecurity", inParams, null); //raise exception.

谢谢你的帮助

4

1 回答 1

1

Argument Object in VisualSVN_SecurityDescriptor.SetSecurity() method should be reference to WMI object (object path), not WMI object itself. Try ManagementPath .NET class should help.

于 2013-08-21T18:47:19.917 回答