Translation C # control Management VisualSVN Server

Source: Internet
Author: User

VISUALSVN server can be managed with the WMI interface (Windows Management instrumentation). VISUALSVN SERVER is installed on the computer, the MOF file under%VISUALSVN_SERVER%\WMI describes the interface. You can control the management of VISUALSVN Server with C # code.

My machine visualsvn installed on D disk, MOF file exists location: D:\Program files\visualsvn server\wmi\visualsvnserver.mof

Some of the following code is for reference:

Using system.management;using System.Management.Instrumentation;

and add a reference to these two components system.management,system.management.instrumentation.

1) Create subversion user ' User1 ', password for ' secret '

ManagementClass userclass = Newmanagementclass ("Root\\visualsvn", "Visualsvn_user", null);//Obtain in-parameters for The Methodmanagementbaseobject inparams =userclass.getmethodparameters ("Create");//ADD the input Parameters.inparams ["Name"] = "user1"; inparams["Password"] = "secret";//Execute the method and obtain the return values. Managementbaseobject outparams =userclass.invokemethod ("Create", inparams, NULL);

2) Create a new repository ' REPO1 '

ManagementClass Repoclass = Newmanagementclass ("Root\\visualsvn", "visualsvn_repository", null);//Obtain In-parameters for the Methodmanagementbaseobject inparams =repoclass.getmethodparameters ("Create");//ADD the input parameters.inparams["Name"] = "REPO1";//Execute the method and obtain the return values. Managementbaseobject outparams =repoclass.invokemethod ("Create", inparams, NULL);

3) Set the SID s-1-5-32-545 (' builtin\users ') Windows user group to the ' Test ' repository read/write permission. The Fyi:accesslevel value is described in MOF: "0-no permissions, 1-read-only, 2-read/write".
managementclass userclass = Newmanagementclass ("Root\\visualsvn", "Visualsvn_ Windowsaccount ", NULL); ManagementClass Authzclass = Newmanagementclass ("Root\\visualsvn", "Visualsvn_securitydescriptor", null); ManagementClass Permclass = Newmanagementclass ("Root\\visualsvn", "visualsvn_permissionentry", null); ManagementObject UserObject = Userclass.createinstance (); Userobject.setpropertyvalue ("SID", "S-1-5-32-545"); ManagementObject permobject = permclass.createinstance ();p ermobject.setpropertyvalue ("account", userObject); Permobject.setpropertyvalue ("AccessLevel", 2); ManagementObject repo = newmanagementobject ("Visualsvn_repository.name= ' Test '"); Managementbaseobject inparams =authzclass.getmethodparameters ("setsecurity"); inparams["Object"] = repo;inParams[" Permissions "] = newobject[] {permobject}; Managementbaseobject outparams =authzclass.invokemethod ("SetSecurity", inparams, null); 
Reference article:

1.http://msdn.microsoft.com/en-us/library/bb404655

2.http://stackoverflow.com/questions/10017282/control-visualsvn-server-from-c-sharp

Http://www.cnblogs.com/zhangqs008/p/3763829.html

Translation C # control Management VisualSVN Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.