Hi all,
I'm trying to automate some actions on VisualSVN in C# using WMI (Windows Management Instrumentation). I found a way of how to create a repository automatically, user and add permissions to a user on a particular repository - it's working fine. Here're the link sources I use:
java - how to create a new user for visual svn server using svnkit javaapi? - Server Fault
https://groups.google.com/forum/?fromgroups=#!topic/visualsvn/0NTgU8XzbUo
The problem is exactly as described in the second link in the end. I would like to add permissions to multiple users on a single repository.
When I execute this code to add permissions multiple times with different users, it will rewrite the previously added permissions. Here's the code:
public void AddPermissions(string userName, String repoName) {
ManagementObject repo = new ManagementObject("VisualSVN_Repository.Name='" + repoName + "'");
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 = userClass.CreateInstance();
userObject.SetPropertyValue("Name", userName);
ManagementObject permObject = permClass.CreateInstance();
permObject.SetPropertyValue("Account", userObject);
permObject.SetPropertyValue("AccessLevel", 2);
ManagementBaseObject inParams =
authzClass.GetMethodParameters("SetSecurity");
inParams["Object"] = repo;
inParams["Permissions"] = new object[] { permObject };
ManagementBaseObject outParams =
authzClass.InvokeMethod("SetSecurity", inParams, null);
}
I call this method twice, once with the user "user1" and reponame "newRepo" - it adds the permissions correctly.
The second time I call it with the user "user2" and the same reponame "newRepo". This adds the permissions to the user2, but REMOVES the previously added permissions for user1.
Could somebody help me with this please? anda: I'm sorry, I'm not very good with C# but I need this, it's not possible to code in Java as far as I know.
I'm trying to automate some actions on VisualSVN in C# using WMI (Windows Management Instrumentation). I found a way of how to create a repository automatically, user and add permissions to a user on a particular repository - it's working fine. Here're the link sources I use:
java - how to create a new user for visual svn server using svnkit javaapi? - Server Fault
https://groups.google.com/forum/?fromgroups=#!topic/visualsvn/0NTgU8XzbUo
The problem is exactly as described in the second link in the end. I would like to add permissions to multiple users on a single repository.
When I execute this code to add permissions multiple times with different users, it will rewrite the previously added permissions. Here's the code:
public void AddPermissions(string userName, String repoName) {
ManagementObject repo = new ManagementObject("VisualSVN_Repository.Name='" + repoName + "'");
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 = userClass.CreateInstance();
userObject.SetPropertyValue("Name", userName);
ManagementObject permObject = permClass.CreateInstance();
permObject.SetPropertyValue("Account", userObject);
permObject.SetPropertyValue("AccessLevel", 2);
ManagementBaseObject inParams =
authzClass.GetMethodParameters("SetSecurity");
inParams["Object"] = repo;
inParams["Permissions"] = new object[] { permObject };
ManagementBaseObject outParams =
authzClass.InvokeMethod("SetSecurity", inParams, null);
}
I call this method twice, once with the user "user1" and reponame "newRepo" - it adds the permissions correctly.
The second time I call it with the user "user2" and the same reponame "newRepo". This adds the permissions to the user2, but REMOVES the previously added permissions for user1.
Could somebody help me with this please? anda: I'm sorry, I'm not very good with C# but I need this, it's not possible to code in Java as far as I know.