2013-05-20 60 views
0

我正在嘗試使用Cassandraemon連接到C#.NET中的Cassandra實例。我找不到任何允許您指定憑據的示例。我的Cassandra實例在AWS的服務器上運行,我需要傳遞用戶名/密碼才能連接。我有以下代碼:如何將憑證傳遞給Cassandraemon中的CassandraContext?

var builder = new CassandraConnectionConfigBuilder 
{ 
    Hosts = new[] { "cassandra.myinstance.com" }, 
    ConsistencyLevel = ConsistencyLevel.QUORUM, 
    Timeout = TimeSpan.FromSeconds(100), 
    Keyspace = "mykeyspace" 
}; 

var config = new CassandraConnectionConfig(builder); 
using (var context = new CassandraContext(config)) 
{ 
    Dictionary<string, string> credentials = new Dictionary<string, string>(); 
    credentials.Add("username", "password"); 
    context.Login(credentials); 
} 

當我運行此,我上context.Login(credentials)線的Apache.Cassandra.AuthenticationException錯誤。我的憑證字典錯了嗎?密鑰不是用戶名和密碼而不是值?

回答

0

我錯誤地使用了證書字典。該字典需要提供正確值的「用戶名」和「密碼」鍵。以下是正確的代碼:

Dictionary<string, string> credentials = new Dictionary<string, string>(); 
credentials.Add("username", "yourusernamehere"); 
credentials.Add("password", "yourpasswordhere"); 
context.Login(credentials); 
相關問題