0

So I intend to connect to mongoDB which is on a remote server behind LDAP. The mongoDB by itself has no username/password setup, but the server on which mongoDB is running is behind LDAP.

My question is how do I setup the server tunneling username/password configuration to connect to MongoDB

I am using the mongoDB module from cpan.

lets assume -
LDAP credentials are
username - ldapuser
password - ldappassword

I do know how to setup if the mongoDB has a username and password

my $connection = MongoDB::Connection->new(host => 'mongodb://perlnewbi3.remoteserver.com:27107', username => 'dbuser', password => 'dbpass', db_name => 'testdb');
my $database = $connection->testdb;

As always any help will be much appreciated

Amey
  • 8,470
  • 9
  • 44
  • 63
  • I also get an error which is somehow related "can't get db response, not connected at xxxxxxxxx/xxx/x/lib/MongoDB/Cursor.pm line 260" – Amey Sep 29 '11 at 23:05

1 Answers1

0

This whole thing is really a question of permissions rather than a question of how to use MongoDB.

There are two basic methods:

  1. Ensure that the Perl app in running in the correct user context so that it can see port 27017 on remoteserver.com.
  2. Create a secured tunnel on the local machine, typically with something like SSH. Then update your connection in PERL to point to the correct port on the local machine. (mongodb://localhost:27017)

Option #1 is probably the ideal solution, however, Option #2 is probably simplest option to setup.

Gates VP
  • 44,957
  • 11
  • 105
  • 108
  • I intend to run these scripts off Jenkins/Hudson, which are running as a Jenkins user on the Jenkins machine, so option 1 basically gets eliminated for me. As the jenkins user is not setup on LDAP. I can only access the MongoDB server using my personal credentials to go pass LDAP. Your second option seems somehow possible, but could you please elaborate in detail how I can achieve it. – Amey Sep 30 '11 at 02:56