1

In relation with this post Control VisualSVN Server from C#

I'm trying to manage user rights on specifics folders.

For the management on the repository itself everything is working fine.

But as soon as I try to change the "Object" parameter for a ManagementBaseObject instead of the ManagementObject of the repository it raise an exception.

I know that there is a new way to do the same in newer version of the server (with path in replacement of the referenced object)

//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.

Thanks for any help

Community
  • 1
  • 1
Simon
  • 11
  • 1
  • 3
    "an exception" is not helpful. Tell us WHAT the exception is. Do you mean this is a run-time exception or compile-time error? – tnw Aug 20 '13 at 16:22
  • Check the updated answer: http://stackoverflow.com/a/10030008/761095 – bahrep Jan 08 '16 at 21:41

1 Answers1

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.

Ivan Zhakov
  • 3,981
  • 28
  • 24