Get credentials from SharpSvn in C #

I am writing C # code to do multiple commits for SVN in a single pass, just like the svnmucc tool. So far I've used SharpSvn to do all the SVN communication I need, so I think I can take advantage of that to accomplish the following:

How can I get the credentials (username, password) that SharpSvn is using?

I would like to do something like this:

using (SvnClient svnClient = new SvnClient())
{
    SomeFictitiousCredentialsClass credentials = svnClient.Authentication.FictitiousGetCachedCredentialsMethod();

    // Call my code that performs svnmucc-like work here, passing username and password
    // obtained from 'credentials' variable.
}

      

+2


source to share


2 answers


Sharpsvn does not have an api that provides you with credentials from Subversion. It basically implements the libsvn_client api and there is no access to this data at this level.

SharpSvn receives a callback from the subversion libraries when they need credentials; in most cases after the built-in password store cannot be authenticated.



If your svnmucc code also uses Apis Subversion, you can simply plug in the predefined subversion validation handlers.

SharpSvn itself does not yet have svnmucc support. (There was some talk of someone who loved adding this to SharpSvn, but I have no news of this lately)

+1


source


While the other answer is still valid for all current versions of SharpSvn, SvnMucc support has just landed in development code for SharpSvn. So soon it will be possible to perform SvnMucc operations like. NET.

using SharpSvn;

SvnCommitResult cr;
using (SvnMultiCommandClient mucc = new SvnMultiCommandClient("http://my-repos/svn/"))
{
    mucc.CreateDirectory("trunk");
    mucc.CreateDirectory("branches");
    mucc.CreateDirectory("tags");
    mucc.CreateDirectory("trunk/src");
    mucc.SetProperty("", "svn:auto-props", "*.cs = svn:eol-style=native");
    mucc.SetProperty("", "svn:global-ignores", "bin obj");

    mucc.Commit(out cr); // Commit r1
}
using (SvnClient client = new SvnClient())
{
   client.CheckOut("http://my-repos/svn/", @"C:\wc");
}

      



There is a slightly different syntax if you want to perform an operation from an existing SvnClient, but this is a general idea.

0


source







All Articles