【问题标题】:SVN Repository Authentication with SharpSVN - Credentials not working使用 SharpSVN 的 SVN 存储库身份验证 - 凭证不起作用
【发布时间】:2012-12-02 23:36:37
【问题描述】:

我在 C# 中有以下代码:

1.  public static void Main(string[] args) {
2.  Uri repository = new Uri("https://svnserver:port/svn/Src/trunk");
3.  using (SvnClient client = new SvnClient()) {                
4.    client.Authentication.Clear();
5.    client.Authentication.DefaultCredentials = new System.Net.NetworkCredential("user", "pass");
6.
7.    System.Collections.ObjectModel.Collection<SvnLogEventArgs> logEntries;
8.    SvnLogArgs logArgs = new SvnLogArgs();
9.    logArgs.Limit = 1;
10.   client.GetLog(repository, logArgs, out logEntries);
11.   }
12. }

如果我删除第 4 行和第 5 行,则此代码可以正常工作。我假设它以某种方式使用了我从 TortoiseSVN 本地保存的凭据。但是,我想在服务器环境中运行它,我需要专门传入用户名/密码。但是,一旦我尝试输入登录凭据,我就会在第 10 行收到以下错误:

SharpSvn.SvnRepositoryIOException was unhandled
Message: Unable to connect to a repository at URL

我在这里做错了什么?我已验证我尝试使用的用户名/密码有效。

【问题讨论】:

    标签: c# sharpsvn


    【解决方案1】:

    我找到了答案...在第 5 行之后添加:

    client.Authentication.SslServerTrustHandlers += delegate(object sender, SvnSslServerTrustEventArgs e) {
                        e.AcceptedFailures = e.Failures;
                        e.Save = true; // Save acceptance to authentication store
                    };
    

    【讨论】:

    • 我收到此错误:“没有更多凭据或我们尝试了太多次。身份验证失败”
    猜你喜欢
    • 2011-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-09
    • 1970-01-01
    • 1970-01-01
    • 2013-05-31
    • 1970-01-01
    相关资源
    最近更新 更多