MONGOC_URI_SE...ISM_PROPERTIES(3)

πŸ’… MONGOC_URI_SE...ISM_PROPERTIES(3) ✨

okay so bestie, welcome to libmongoc β€” yes the man page title is literally cut off (MONGOC_URI_SE...ISM_PROPERTIES(3), iconic abbreviation energy), but the whole point of this one is that long-ish function mongoc_uri_set_mechanism_properties. it's giving "short name, big job" and honestly? we respect it 🫢


🌸 SYNOPSIS 🌸

like, here's the shape of it, no cap:

bool
mongoc_uri_set_mechanism_properties (mongoc_uri_t *uri,
                                     const bson_t *properties);

πŸŽ€ PARAMETERS πŸŽ€

  • uri β€” a mongoc_uri_t. your URI. your main character.
  • properties β€” a bson_t. this is the BSON blob holding the new stuff.

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•: this function replaces all the options in the URI's "authMechanismProperties" β€” and it does it after the URI has already been parsed from a string. it's not adding, it's not merging, it's full-on replacing the whole set. periodt πŸ’…


⭐ RETURNS ⭐

it hands back false if the option can't be set β€” for example, if properties is not valid BSON data. so like, do a vibe check on your BSON first, bestie 😭


🌈 EXAMPLE 🌈

here's the whole thing in action, copy it exactly, i'm not even kidding:

mongoc_uri_t *uri;
bson_t props = BSON_INITIALIZER;

uri = mongoc_uri_new (
   "mongodb://user%40DOMAIN.COM:password@localhost/?authMechanism=GSSAPI"
   "&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true");

/* replace all options: replace service name "other" with "my_service", unset
 * "CANONICALIZE_HOST_NAME" and accept its default.
 */
BSON_APPEND_UTF8 (&props, "SERVICE_NAME", "my_service");
mongoc_uri_set_mechanism_properties (uri, &props);

bson_destroy (&props);

so what's happening here? the comment in the code says it all, but lemme hype it up anyway πŸŽ‰ β€” we swap the service name "other" for "my_service", we unset "CANONICALIZE_HOST_NAME" and just accept its default. because that's literally what "replaces all the options" means. it ate and left no crumbs πŸ‘‘


πŸ’œ AUTHOR πŸ’œ

MongoDB, Inc β€” the icons behind all this 🫑


2009-present, MongoDB, Inc.


and that's the whole page, bestie πŸ’– hope your mechanism properties are always valid BSON and your return value is always true. stay slay ✨

β€” signed off with love from libmongoc version 2.5.6, dated Oct 09, 2026 πŸŽ€πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from