2013-05-20 28 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); 
相关问题