Closed sitcon40670 closed 11 years ago
The Collection name may have to be a multi-part name, try MongoWireAuthenticate(mdb,'db.accounts', or 'system.accounts', if that doesn't work I should take some time to investigate what the mongo shell does
Hello,
unfortunately using dbname.collectionname throws a malformed command exception.
any ideas?
I'll see when I can put up a server with authentication and find out what the client is doing different than TMongoWire
Hello,
any news on that issue?
Haven't taken the time yet to set up a local mongodb install with authentication, though I just now see mongolab.com has a free offering. I'll try to fit in some time to take a look at it soon.
I've tried this, and it works (replaced my personal data by 'MyMongoLab...' below) I've created mongolab account, and a mongolab db 'test1' (somewhere in the Amazon Ireland datacenter) By using 'test1.db1' (note: just 'test1' in the MongoWireAuthenticate call) I see the 'db1' collection in the mongolab admin website.
procedure TForm1.Button9Click(Sender: TObject);
var
m:TMongoWire;
d:IBSONDocument;
begin
m:=TMongoWire.Create;
try
m.Open('ds0MyMongoLabNr.mongolab.com',MyMongoLabNr);
MongoWireAuthenticate(m,'test1','MyMongoLabUserName','MyMongoLabPwd');
//test insert
m.Insert('test1.db1',BSON(['test','x']));
//test get
d:=m.Get('test1.db1',BSON);
Button9.Caption:=VarToStr(d['test']);
finally
m.Free;
end;
end;
Trying to connect to MongoLab works fine.
Following authentification fails: (accounts is a collection within a database).
MongoWireAuthenticate(mdb,'accounts',usernameonMongoLab,pwd);
also tried a user from the database --> fails as well.
Mongoshell can connect fine with % mongo acct.mongolab.com:33037/database -u -p
Any idea on how to set this up in TMongoWire?