任何人都可以告訴我如何使用SharpSVN Library驗證存儲庫的用戶(SVN用戶)。 該存儲庫只應由這些用戶提交。 感謝使用SharpSVN進行SVN存儲庫驗證
25
A
回答
45
使用的SVNClient
的身份驗證屬性:
client.Authentication.Clear(); // Clear a previous authentication
client.Authentication.DefaultCredentials = new System.Net.NetworkCredential("user", "password");
9
你也可以通過添加一個事件處理SslServerTrustHandlers
像這樣覆蓋SSL證書錯誤:
SVN_Conn.Authentication.SslServerTrustHandlers += new EventHandler<SharpSvn.Security.SvnSslServerTrustEventArgs>(SVN_SSL_Override);
static void SVN_SSL_Override(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e)
{
e.AcceptedFailures = e.Failures;
e.Save = true;
}
+4
只是爲了提到它:在訂閱事件後不要調用'client.authentication.clear()',否則它不會觸發。 – SanBen 2012-05-09 12:53:41
14
client.Authentication.ForceCredentials("user", "password");
對於那些你不想吹掉你的默認憑證(如果你在同一臺機器上運行TortoiseSVN)。
2
就我而言,SVN服務器運行啓用集成Windows身份驗證的VisualSVN Server 3.5.3。使用SharpSvn 1.9004.3879.127,SVN客戶端嘗試甚至使用Windows身份驗證時,我有一個用戶名和密碼進行配置的:
client = new SvnClient();
client.Authentication.Clear(); //Prevents saving/loading config to/from disk
client.Authentication.DefaultCredentials = new NetworkCredential("username", "password");
這導致以下錯誤,當應用程序代碼是由沒一個Windows用戶運行'T可以訪問存儲庫:
SvnRepositoryIOException:無法在URL連接到存儲庫' https://mysvnserver/svn/reponame「
我通過only allowing basic
and digest
authentication解決了這個問題:
client = new SvnClient();
client.Configuration.SetOption("servers", "global", "http-auth-types", "basic;digest");
client.Authentication.Clear(); // Prevents saving/loading config to/from disk
client.Authentication.DefaultCredentials = new NetworkCredential("username", "password");
相關問題
- 1. 如何使用SharpSvn來比較Svn存儲庫
- 2. 存儲庫驗證
- 3. SharpSvn轉儲庫tortoise
- 4. 使用jQuery Passport.JS進行身份驗證不存儲cookie
- 5. 使用TFS的外部工具進行身份驗證Git存儲庫
- 6. sharpsvn搜索存儲庫提交
- 7. 使用驗證服務進行驗證
- 8. 使用企業庫驗證塊進行復雜對象驗證
- 9. 使用C#創建SVN存儲庫
- 10. 使用wget「簽出」svn存儲庫
- 11. 使用bash分析svn存儲庫
- 12. 如何使用SharpSvn獲取存儲庫的所有分支?
- 13. 使用webdav進行SVN身份驗證訪問
- 14. 使用LDAP進行驗證
- 15. 使用AWK進行驗證
- 16. 使用JavaScript進行驗證
- 17. 使用AJAX進行驗證
- 18. 使用doctype進行驗證
- 19. 使用sharpsvn API從ASP.Net訪問Visual SVN
- 20. 如何在c#中使用SharpSVN庫設置SVN提交作者
- 21. 更改SVN存儲庫
- 22. Apache2 svn多個存儲庫
- 23. 創建SVN retrocompatible存儲庫
- 24. SVN遠程存儲庫
- 25. svn +存儲庫位置
- 26. 搜索SVN存儲庫
- 27. SVN加載新存儲庫
- 28. SVN存儲庫搜索
- 29. SVN只讀存儲庫
- 30. 已更改svn存儲庫
應該標記爲最佳答案。爲我工作,謝謝! – jocull 2011-05-14 16:50:53
是的,我也爲我工作,謝謝伯特朗:) – picnic4u 2012-12-06 10:36:02
這不適合我,是否有一些先決條件呢? – 2012-12-14 23:49:25