C# runtime library for Keeper Password Manager.
$ dotnet add package Keeper.SdkEnterprise-grade Password Management SDK for .NET applications
The Keeper .NET SDK is a comprehensive library that provides programmatic access to Keeper Password Manager's vault and administrative features. Built for .NET 8.0 and .NET Standard 2.0, it enables seamless integration of enterprise password management into your applications.
Note: All code examples in this README use the current SDK API (v16+). The authentication flow uses
AuthSync,JsonConfigurationStorage, andSimpleInputManagerfor console applications. For working examples, see the Sample Applications section.
dotnet add package KeeperSdk
Install-Package KeeperSdk
<PackageReference Include="KeeperSdk" Version="16.*" />
using System;
using System.Linq;
using System.Threading.Tasks;
using Cli;
using KeeperSecurity.Authentication;
using KeeperSecurity.Authentication.Sync;
using KeeperSecurity.Configuration;
using KeeperSecurity.Vault;
// Initialize configuration storage
var configStorage = new JsonConfigurationStorage("config.json");
var configuration = configStorage.Get();
// Use SimpleInputManager for console input
var inputManager = new SimpleInputManager();
// Login to Keeper using AuthSync
var auth = new AuthSync(configStorage);
await Utils.LoginToKeeper(auth, inputManager, "your-email@company.com");
// Create vault instance and sync
var vault = new VaultOnline(auth);
await vault.SyncDown();
// Access records
foreach (var record in vault.KeeperRecords)
{
Console.WriteLine($"Record: {record.Title}");
if (record is PasswordRecord passwordRecord)
{
Console.WriteLine($" Login: {passwordRecord.Login}");
Console.WriteLine($" URL: {passwordRecord.Link}");
}
}
using System.Linq;
using KeeperSecurity.Vault;
// Create a typed login record
var loginRecord = new TypedRecordFacade<LoginRecordType>();
loginRecord.Fields.Login = "admin@myapp.com";
loginRecord.Fields.Password = "SecurePassword123!";
loginRecord.Fields.Url = "https://myapp.com";
var typedRecord = loginRecord.TypedRecord;
typedRecord.Title = "My Application";
typedRecord.Notes = "Production credentials";
var createdRecord = await vault.CreateRecord(typedRecord);
Console.WriteLine($"Record created with UID: {createdRecord.Uid}");
KeeperSecurity.Authentication)IInputManagerKeeperSecurity.Vault)KeeperSecurity.Enterprise)KeeperSecurity.Configuration)using System;
using System.Linq;
// Find record by title
var record = vault.KeeperRecords
.FirstOrDefault(x => x.Title == "Database");
if (record != null)
{
if (record is PasswordRecord passwordRecord)
{
// Update legacy password record
passwordRecord.Password = "NewSecurePassword123!";
await vault.UpdateRecord(passwordRecord);
Console.WriteLine("Password rotated successfully");
}
else if (record is TypedRecord typedRecord)
{
// Update typed record password field
var passwordField = typedRecord.FindTypedField(new RecordTypeField("password", "Password"));
if (passwordField != null)
{
passwordField.ObjectValue = "NewSecurePassword123!";
await vault.UpdateRecord(typedRecord);
Console.WriteLine("Password rotated successfully");
}
}
}
using System.IO;
using System.Linq;
using KeeperSecurity.Commands;
// Upload attachment from file
using (var stream = File.OpenRead("config.json"))
{
var uploadTask = new FileAttachmentUploadTask("config.json")
{
Title = "Configuration File",
MimeType = "application/json"
};
await vault.UploadAttachment(record, uploadTask);
}
// Or upload from memory stream
using (var stream = new MemoryStream(fileContent))
{
var uploadTask = new AttachmentUploadTask(stream)
{
Title = "Configuration File",
Name = "config.json",
MimeType = "application/json"
};
await vault.UploadAttachment(record, uploadTask);
}
// Download attachment
var attachment = vault.RecordAttachments(record).FirstOrDefault();
if (attachment != null)
{
using (var stream = File.Create(attachment.Title))
{
await vault.DownloadAttachment(record, attachment.Id, stream);
}
}
// Delete attachment
if (attachment != null)
{
await vault.DeleteAttachment(record, attachment.Id);
}
using System;
using System.Linq;
using KeeperSecurity.Vault;
// Get shared folder
var sharedFolder = vault.SharedFolders
.FirstOrDefault(x => x.Name == "Team Credentials");
if (sharedFolder != null)
{
// Add user to shared folder with permissions
await vault.PutUserToSharedFolder(
sharedFolder.Uid,
"user@company.com",
UserType.User,
new SharedFolderUserOptions
{
ManageRecords = true,
ManageUsers = false
}
);
// Move record to shared folder
await vault.MoveRecords(
new[] { new RecordPath { RecordUid = recordUid } },
sharedFolder.Uid,
link: true // true to link, false to move
);
}
using System;
using System.Linq;
using KeeperSecurity.Enterprise;
// Check if user has enterprise admin privileges
if (auth.AuthContext.IsEnterpriseAdmin)
{
// Load enterprise data
var enterprise = new EnterpriseData();
var enterpriseLoader = new EnterpriseLoader(auth, new[] { enterprise });
await enterpriseLoader.Load();
// List users
foreach (var user in enterprise.Users)
{
Console.WriteLine($"User: {user.Email} - Status: {user.Status}");
}
// Find or create team
var team = enterprise.Teams
.FirstOrDefault(x => x.Name == "Engineering");
if (team == null)
{
team = await enterprise.CreateTeam(new EnterpriseTeam
{
Name = "Engineering",
RestrictEdit = false,
RestrictSharing = true,
RestrictView = false
});
}
// Add users to team
await enterprise.AddUsersToTeams(
new[] { "user1@company.com", "user2@company.com" },
new[] { team.Uid },
Console.WriteLine // Progress callback
);
}
| Sample | Description | Path |
|---|---|---|
| Basic Auth | Simple authentication and vault sync | BasicAuthExample.cs |
| Full Featured | Comprehensive SDK feature demonstration | Program.cs |
| Commander CLI | Command-line application | Commander/ |
| WPF Desktop | Windows desktop application | WPFSample/ |
# Clone repository
git clone https://github.com/Keeper-Security/keeper-sdk-dotnet.git
cd keeper-sdk-dotnet/Sample
# Run basic example
dotnet run
# Run unit tests
cd Tests
dotnet test
# Run with coverage
dotnet test /p:CollectCoverage=true
# Clone the repository
git clone https://github.com/Keeper-Security/keeper-sdk-dotnet.git
cd keeper-sdk-dotnet
# Restore dependencies
dotnet restore
# Build the project
dotnet build
# Run tests
dotnet test
This project is licensed under the MIT License - see the LICENSE file for details.