Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8210657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:08:48+00:00 2026-06-07T10:08:48+00:00

I can’t seem to find documentation on authentication into mongodb from the C driver.

  • 0

I can’t seem to find documentation on authentication into mongodb from the C driver. The C driver API has no information on it as far as I can tell. However, this link makes me think that it’s possible. A link or a code snippet would be great. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:08:49+00:00Added an answer on June 7, 2026 at 10:08 am

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you tell me what is the difference between abstraction and information hiding in
Can someone tell me where can I find the latest Python bindings for Apache
Can any one tell, how to get the result of LINQ query contains group
Can anybody tell what is the best(easy) way to sort the following string 'index'
Can someone tell me how does the imdb app manage to play trailers on
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can any one tell me clearly why ? Reading is simple in ArrayList,( we
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
can anyone tell me if it is possible to convert a dojo charting object
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.