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();
}
}
}