Here's the function to call.
MONGO_EXPORT int mongo_cmd_authenticate (
mongo * conn,
const char * db,
const char * user,
const char * pass
)
Authenticate a user.
Parameters:
conn a mongo object.
db the database to authenticate against.
user the user name to authenticate.
pass the user's password.
Returns:
MONGO_OK on sucess and MONGO_ERROR on failure.
Here's an excerpt from the test code as an example - mongo-c-driver/test/auth_test.c
if ( mongo_connect( conn , TEST_SERVER, 27017 ) ) {
printf( "failed to connect\n" );
exit( 1 );
}
ASSERT( mongo_cmd_authenticate( conn, db, "user", "password" ) == MONGO_OK );
...
Hope that this helps. Here are some links for futher information.
References:
MongoDB C Language Center - http://www.mongodb.org/display/DOCS/C+Language+Center
MongoDB C Driver Documentation - http://api.mongodb.org/c/current/
MongoDB C Driver API Docs - http://api.mongodb.org/c/current/api/index.html
mongo.h File Referenc - http://api.mongodb.org/c/current/api/mongo_8h.html
mongo_cmd_authenticate -http://api.mongodb.org/c/current/api/mongo_8h.html#a715aaa6b82e23486e6caad2b544f2ebf
MongoDB C Driver source code - https://github.com/mongodb/mongo-c-driver
test/auth_test.c - https://github.com/mongodb/mongo-c-driver/blob/master/test/auth_test.c
I'm using the C Driver to write an app to use with mongolab.com I'm able to communicate with my local server which doesn't require authentication, but not with MongoLab which does. I figure I need to use mongo_cmd_authenticate() but don't have any context for it. Any recommendations?--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb