我使用MongoDb v3.0.3并希望使用powershell在具有管理员权限的数据库中创建用户。我加入了C#驱动程序,但我不能走得太远:
$pathToMongoDbCSharpDriver = "F:\Work\...\mongocsharpdriver.1.9.2\lib\net35"
Add-Type -Path "$pathToMongoDbCSharpDriver\MongoDB.Bson.dll"
Add-Type -Path "$pathToMongoDbCSharpDriver\MongoDB.Driver.dll"
$client = New-Object -TypeName MongoDB.Driver.MongoClient -ArgumentList "mongodb://localhost:30000"
$server = $client.GetServer()
$databaseName = "Dev"
$collectionName = "Settings"
$database = $server.GetDatabase($databaseName)
$collection = $database.GetCollection($collectionName)
$credentials = New-Object -TypeName MongoDB.Driver.MongoCredential("Admin", "password", $true);
$user = New-Object -TypeName MongoDB.Driver.MongoUser($credentials, $false)
$凭证失败,因为参数1它不是MongoIdentity,我无法找到有关如何创建其中一个的任何信息。我们将非常感激地提供任何帮助