meerkat
meerkat

Reputation: 69

VisualSVN Server: how to create svn user via script

I have the svn repository that managed by VisualSVN Server. Users are authenticated by login and password (VisualSVN Server Standard edition does not support Active Directory Single Sign-On).

I know how to create svn users via VisualSVN Server GUI, but I need script that can do the same. Can I use powershell cmdlets for this purpose? If not, then what VisualSVN Server config file should I change to add new svn user?

Upvotes: 1

Views: 1931

Answers (3)

meerkat
meerkat

Reputation: 69

Thanks to VisualSVN_User class from
C:\Program Files\VisualSVN Server\WMI\VisualSVNServer.mof
I can write my own cmdlet Add-SvnUser.ps1

[CmdletBinding()]
param(
  [Parameter(Mandatory=$True)]
  [string] $svnHost,

  [Parameter(Mandatory=$True)]
  [string] $user,

  [Parameter(Mandatory=$True)]
  [string] $password
)


$userObj = Get-CimInstance -ComputerName $svnHost `
   -Namespace root\VisualSVN -Class VisualSVN_User | ? {$_.Name -eq $user}

if($userObj -ne $null) {
   Invoke-CimMethod -InputObject $userObj `
      -MethodName "SetPassword" -Arguments @{Password=$password}
} 
else {
   Invoke-CimMethod `
      -ComputerName $svnHost -Namespace root\VisualSVN -Class VisualSVN_User `
      -MethodName Create -Arguments @{Name=$user; Password=$password}
}

Example of usage PS C:\> .\Add-SvnUser.ps1 -svnHost svn.com -user first -pass first

Upvotes: 0

alroc
alroc

Reputation: 28174

To create users, you must have access to the VisualSVN Server MMC snap-in. I don't know if you can install that on a remote PC or not - the documentation doesn't exactly say.

Once you have that access, see page 8 of the manual

Upvotes: 0

Stewart
Stewart

Reputation: 5012

I've only seen VisualSVN authenticate users through an active directory or LDAP. But I don't see why you couldn't point VisualSVN to authenticate through the localmachine. In that case you wouldn't actually do this through VisualSVN, you'd do it through the OS of that machine. On a Linux machine, you'd add a user, then add that user to the svn group. On Windows you probably just need to add the user.

Then in the VisualSVN command window, you'd right click on "Repositories" (top level artifact) and select "Properties", then click "Add". Ensure "Object Types" has "Users" selected, select your machine from "Locations", and enter the username. All repositories will inherit this permission by default giving that person access to everything.

To automate it further, create a user-group on your machine, grant access to that group, then just add a user, and assign the user to the group in your script. Then you'd just need to give the group permissions and you'd never need to touch VisualSVN.

Upvotes: 1

Related Questions