I have an .net app where I have my connection info and bucket credentials in my app.config
I am trying to get hold of the ClusterManager, using the credentials from my config file
I can do the following to get a bucket without entering credentials.
ClusterHelper.Initialize("couchbaseClients/couchbase");
var cluster = ClusterHelper.Get();
var bucket = cluster.OpenBucket("mybucket");
I can use the credentials for this bucket to get the ClusterManager (my bucket name is the same as my bucket username)
ClusterHelper.Initialize("couchbaseClients/couchbase");
var cluster = ClusterHelper.Get();
var manager = cluster.CreateManager("mybucket", "mybucketpwd");
But I can’t find a way to get the manager without programatically providing the password to createmanager, even though the CreateManager method does have a parameterless call.
ClusterHelper.Initialize("couchbaseClients/couchbase");
var cluster = ClusterHelper.Get();
var manager = cluster.CreateManager();
Is there a way of achieving this? I dont have a problem providing the bucket name (or username) as a parameter, since it’s a constant in my code. I guess I could traverse the config xml and get the password I need, but it seems like a clumsy solution.
I’m using Couchbase 5.0.0 and CouchbaseNetClient 2.5.2
and my config section looks like this
You should try switching to the new authentication method, instead of the old bucket password method. To do that, drop “password” from your bucket. Then add and tags within the section:
Thanks for that, I wasn’t aware of this change to the config - we’ve only just upgraded from 4.5.1 to 5.0.0 and hadn’t paid attention to changes in the client’s authentication method. We had 3 buckets each with their own user and pwd, but I don’t see why we shouldn’t just have one user for all buckets.
I’m just trying to test this out, but am currently having a little trouble adding in the and elements to my config - having added them just like your config snippet, and using ClusterHelper.Initialize(“couchbaseClients/couchbase”) I’m getting a System.Configuration.ConfigurationErrorsException - “Property ‘username’ is not a ConfigurationElement.” I can’t see why this is a problem, I’ve tried with 2.5.2 and 2.5.3 , the source in Git for the CouchbaseClientSection seems to define the config element for username just as I’d expect. Oh well, I’ve probably done something dumb here, hope I’ll figure it out eventually.
The username and password fields are properties of the root configuration section, not sub-nodes. This example config works for me connecting to a 5.0 Couchbase cluster using .NET client 2.5.3:
class Program
{
static void Main()
{
using (var cluster = new Cluster("couchbase"))
{
var manager = cluster.CreateManager();
var result = manager.ListBuckets();
}
}
}