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