2013-05-20 3 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

자격 증명 사전을 잘못 사용하고있었습니다. 사전에는 올바른 값이 제공된 "username"및 "password"에 대한 키가 필요했습니다. 다음은 올바른 코드입니다.

Dictionary<string, string> credentials = new Dictionary<string, string>(); 
credentials.Add("username", "yourusernamehere"); 
credentials.Add("password", "yourpasswordhere"); 
context.Login(credentials); 
관련 문제