+ if ((node->db != NULL) && (node->user != NULL) && (node->passwd != NULL))
+ {
+ status = mongo_cmd_authenticate (node->conn,
+ node->db, node->user, node->passwd);
+ if (status != MONGO_OK)
+ {
+ ERROR ("write_mongodb plugin: Authenticating to [%s]%i for database "
+ "\"%s\" as user \"%s\" failed.",
+ (node->host != NULL) ? node->host : "localhost",
+ (node->port != 0) ? node->port : MONGO_DEFAULT_PORT,
+ node->db, node->user);
+ mongo_destroy (node->conn);
+ pthread_mutex_unlock (&node->lock);
+ return (-1);
+ }
+ }
+