stijnsanders / TMongoWire

Delphi MongoDB driver
MIT License
102 stars 37 forks source link

Connect mongolab.com #23

Closed johnidm closed 9 years ago

johnidm commented 9 years ago

Dear @stijnsanders, I want to connect in database registered in mongolab.com.

I tried FMongoWire.Open('ds043971.mongolab.com', 43971);, but return error 'MongoWire.Query: not authorized for query on delphi.items'

After, I tried FMongoWire.Open('mongodb://delphi:delphi@ds043971.mongolab.com:43971/delphi', 43971) return error 'The requested name is valid, but no data of the requested type was found'

Information of connection

To connect using the shell: mongo ds043971.mongolab.com:43971/delphi -u -p To connect using a driver via the standard URI (what's this?): mongodb://:@ds043971.mongolab.com:43971/delphi

dbuser is delphi dbpassword is delphi

I change db "mwx1" to "delphi" in MongoLab

It is possible to connect the MongoLab with TMongoWire?

Thanks.

stijnsanders commented 9 years ago

Please have a look at MongoWireAuthenticate from the mongoAuth.pas unit

johnidm commented 9 years ago

Okay, thanks.

stijnsanders commented 9 years ago

this works for me:

uses
  mongoWire, mongoAuth;
var
  db:TMongoWire;
begin
  db.Open(Format('ds%.6d.mongolab.com',[MyMongoLabNr]),MyMongoLabNr);
  MongoWireAuthenticate(db,'test1','user1','user1');
johnidm commented 9 years ago

@stijnsanders for me not work, return error MongoWire.Get: not authorized for query on persons.names.$cmd

Look:

var
  db:TMongoWire;

begin
  db:= TMongoWire.Create('persons');

  db.Open(Format('ds%.6d.mongolab.com',[45011]), 45011);

  MongoWireAuthenticate(db,'names','user','user');
end;

db is persons collection is names user and password is user lab is 45011

mongolab01 mongolab02

stijnsanders commented 9 years ago

You're right, authentication has changed in version 2.6: http://docs.mongodb.org/manual/core/authentication/

stijnsanders commented 9 years ago

Do you happen to know which one of these mongolab is using? https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst

stijnsanders commented 9 years ago

Please see my recent commit: apparently the collection prefix to '$cmd' is no longer needed.

johnidm commented 9 years ago

Okay, @stijnsanders.

I will see.

Thanks for help.

johnidm commented 9 years ago

@stijnsanders worked.

Look www.johnidouglas.com.br/using-tmongowire-to-connect-database-in-mongolab-com/

Thanks for help.