MONGOC_URI_GE...ISM_PROPERTIES(3)
π MONGOC_URI_GET_MECHANISM_PROPERTIES π
okay bestie, so this is a page from libmongoc (that's the MongoDB C driver, iykyk) and it's all about one lil function: mongoc_uri_get_mechanism_properties. it's giving "short and sweet but read the fine print," fr fr.
β¨ SYNOPSIS β¨
bool
mongoc_uri_get_mechanism_properties (const mongoc_uri_t *uri,
bson_t *properties /* OUT */);
π PARAMETERS π
uri: amongoc_uri_t. that's the main character here.properties: an uninitializedbson_t. yes, uninitialized. don't be out here pre-initializing it, that's not the vibe.
πΈ DESCRIPTION πΈ
so what does it actually do? it fetches the "authMechanismProperties" options that were set on this mongoc_uri_t. simple as that, no cap.
now for the part you cannot skip (lowkey the most important bit):
the out-parameterpropertiesshould be an uninitialized, stack-allocatedbson_t. it gets statically initialized withbson_init_static()so it points at the internal data ofuri. that means: do not modify its contents π, and it becomes invalid afteruriis destroyed. it's a borrowed pointer situation, bestie β not a copy. treat it like you're borrowing your friend's hoodie, not keeping it.
β RETURNS β
if no "authMechanismProperties" have been set on uri, the function returns false and properties remains uninitialized. so likeβ¦ check the return value before you go touching properties, obviously. π
π₯ EXAMPLE π₯
here's the whole thing in action, chef's kiss:
mongoc_uri_t *uri;
bson_t props;
uri = mongoc_uri_new (
"mongodb://user%40DOMAIN.COM:password@localhost/?authMechanism=GSSAPI"
"&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true");
if (mongoc_uri_get_mechanism_properties (uri, &props)) {
char *json = bson_as_canonical_extended_json (&props, NULL);
printf ("%s\n", json);
bson_free (json);
} else {
printf ("No authMechanismProperties.\n");
}
and this code produces the output β look at it go:
{ "SERVICE_NAME" : "other", "CANONICALIZE_HOST_NAME" : "true" }
ate. no crumbs. π
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
okay that's the whole page, you're officially educated π§β¨ β this was libmongoc 2.5.6, dated Oct 09, 2026, and honestly? iconic. go forth and get those mechanism properties, bestie π«Άπ
π¦ where this page comes from
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms