This question already has an answer here:
How do I use authentication with mongodb via the official c# driver? I can't find any API methods to authenticate, other than internal members.
Authentication credentials should be specified in your connection string, using the following connection string format:
mongodb://[username:password@]hostname[:port][/[database][?options]]
See full details here in the MongoDB C# Driver Tutorial
来源:https://stackoverflow.com/questions/10101506/mongodb-authentication