This folder contains sample applications demonstrating various features of the Keeper .NET SDK.
- .NET Core 8.0 SDK or later
- A Keeper Security account
From the repository root:
dotnet build Sample/Sample.csprojNavigate to the build output directory:
cd Sample/bin/Debug/net8.0
dotnet Sample.dllOr run directly from the project directory:
dotnet run --project Sample/Sample.csprojThe Sample project contains comprehensive examples organized by feature category. All examples can be uncommented and executed from Program.cs.
Basic authentication and vault synchronization example:
- Authentication: Master password, 2FA, and device approval using
AuthSync - Input Management: Using
SimpleInputManagerfor console input - Configuration Storage: Using
JsonConfigurationStoragefor persisting settings - Vault Sync: Download and decrypt vault using
VaultOnline - Methods:
GetVault()- Authenticates and returns synced vaultShowFolders()- Demonstrates basic vault access
View the code: AuthenticateAndGetVault.cs
- Login.cs - Complete authentication flow with
AuthSync - Logout.cs - Logout from authenticated session
- Whoami.cs - Display current user information
- AddRecord.cs - Create new records with various types (login, bankCard, serverCredentials, etc.)
- UpdateRecord.cs - Update existing record title and type
- DeleteRecord.cs - Delete records from vault
- ListRecord.cs - List all records in the vault
- GetRecord.cs - Retrieve detailed information about a specific record
- RecordHistory.cs - Access record revision history
- UploadAttachment.cs - Upload files and thumbnails to records
- DownloadAttachment.cs - Download attachments by ID, name, or title
- RemoveAttachment.cs - Delete attachments from records
- CreateFolder.cs - Create new folders and shared folders with permissions
- ListFolder.cs - List all folders in the vault
- MoveFolder.cs - Move folders to different parent folders
- RemoveFolder.cs - Delete folders from the vault
- ListSharedFolder.cs - List all shared folders
- SharedFolderPermissions.cs - Manage record permissions within shared folders
- ShareFolderToUser.cs - Share folders with users and teams
- OneTimeShare.cs - Create one-time share links for records
- OneTimeShareList.cs - List active one-time shares
- RemoveOneTimeShare.cs - Remove one-time share links
- ShareRecordToUSer.cs - Share individual records with users
- RevokeShareRecordToUser.cs - Remove user access from specific records
- RevokeAllSharesToUser.cs - Remove user from all shared records
- TransferOwnership.cs - Transfer record ownership to another user
- RecordTypeInfo.cs - Get information about record types (all or specific)
- AddRecordType.cs - Create custom record types
- UpdateRecordType.cs - Update existing record type definitions
- DeleteRecordType.cs - Delete custom record types
- ImportExample.cs - Import records from JSON format
- ExportToJsonExample.cs - Export records to JSON format
- ExportToFileExample.cs - Export records to file
- DownloadMembershipToFileObject.cs - Download folder/record membership to object
- DownloadMembershipToJson.cs - Download membership to JSON
- DownloadMembershipToFile.cs - Download membership to file
- DownloadMembershipMerge.cs - Merge membership data with existing file
- LoadRecordTypeExample.cs - Load record type definitions from JSON
- AppListExample.cs - List all Secret Manager applications
- AppCreateExample.cs - Create new Secret Manager applications
- AppViewExample.cs - View application details
- AppDeleteExample.cs - Delete applications
- AppShareExample.cs - Share folders/records with applications
- AppUnShareExample.cs - Remove application access
- AddClientExample.cs - Add clients to applications
- RemoveClientExample.cs - Remove clients from applications
- SecretManagerShareExample.cs - Share folders/records to applications
- SecretManagerUnshareExample.cs - Unshare from applications
Requires enterprise admin access. Uses KeeperSecurity.Plugins.PAM (GatewayUtils, RouterUtils, PamPlugin):
- ListGatewaysExample.cs - List registered gateways with online/offline status
- CreateGatewayExample.cs - Create a gateway on a KSM application (returns one-time token or initialized config)
- EditGatewayExample.cs - Rename a gateway and/or move it to another enterprise node
- SetGatewayMaxInstancesExample.cs - Set maximum concurrent gateway instances
- RemoveGatewayExample.cs - Remove a gateway controller
Requires enterprise admin access for list/info/edit. Script examples need vault access (owner for add/edit/remove). Uses RotationUtils, RouterUtils, PamRotationGraphEdit, and vault FieldScript APIs:
- ListRotationsExample.cs - List pamUser rotation schedules
- RotationInfoExample.cs - Show rotation readiness and settings for a PAM record
- EditRotationExample.cs - Configure rotation for a pamUser (config, resource, schedule, complexity)
- ListRotationScriptsExample.cs - List post-rotation scripts on pamUser / pamDirectory records
- AddRotationScriptExample.cs - Upload and attach a post-rotation script
- EditRotationScriptExample.cs - Update script command and/or linked credentials
- RemoveRotationScriptExample.cs - Remove a post-rotation script
- BreachWatchList.cs - List all breach records
- BreachWatchScan.cs - Scan records for breaches
- BreatchWatchPassword.cs - Scan passwords for breaches
- BreachWatchIgnore.cs - Ignore or check ignored breach records
Comprehensive enterprise administration examples (requires enterprise admin role):
Enterprise Data:
- EnterpriseDownExample.cs - Load and access enterprise data
- EnterpriseAuditReportExample.cs - Get available audit events
User Management:
- EnterpriseUserExamples/EnterpriseUserViewExample.cs - View user details
- EnterpriseUserExamples/EnterpriseAddUserExample.cs - Invite users to enterprise
- EnterpriseUserExamples/EnterpriseEditUserExamples.cs - Edit user properties, add/remove from teams
- EnterpriseUserExamples/EnterpriseDeleteUserExample.cs - Delete users
- EnterpriseUserExamples/EnterpriseUserLockUnlockExample.cs - Lock/unlock user accounts
Node Management:
- EnterpriseNodeExamples/EnterpriseNodeView.cs - View node details
- EnterpriseNodeExamples/EnterpriseNodeAdd.cs - Create new nodes
- EnterpriseNodeExamples/EnterpriseNodeEdit.cs - Update node properties
- EnterpriseNodeExamples/EnterpriseNodeDelete.cs - Delete nodes
Role Management:
- EnterpriseRoleExamples/EnterpriseRoleView.cs - View role details
- EnterpriseRoleExamples/EnterpriseRoleAdd.cs - Create new roles
- EnterpriseRoleExamples/EnterpriseRoleUpdate.cs - Update role properties
- EnterpriseRoleExamples/EnterpriseRoleDelete.cs - Delete roles
- EnterpriseRoleExamples/EnterpriseRoleAdmin.cs - Manage role administrators
- EnterpriseRoleExamples/EnterpriseRoleMembership.cs - Manage role membership
- EnterpriseRoleExamples/EnterpriseRoleTeamManagement.cs - Add/remove teams from roles
- EnterpriseRoleExamples/RoleManagedNode.cs - Manage node assignments, privileges, and enforcements
Team Management:
- EnterpriseTeamExamples/EnterpriseTeamViewExample.cs - View team details
- EnterpriseTeamExamples/EnterpriseTeamAddExample.cs - Create new teams
- EnterpriseTeamExamples/EnterpriseTeamUpdateExample.cs - Update team properties
- EnterpriseTeamExamples/EnterpriseTeamDeleteExample.cs - Delete teams
- EnterpriseTeamExamples/EnterpriseTeamMembershipExample.cs - Add/remove users from teams
- EnterpriseTeamExamples/EnterpriseListTeams.cs - List all enterprise teams
- TrashList.cs - List all records in trash
- TrashRestore.cs - Restore records from trash
The Program.cs file contains commented-out examples for all the above features. To run a specific example:
- Uncomment the desired example call in
Program.cs - Update any placeholder values (like
<recordUid_here>,<userEmail_here>, etc.) - Run the project
This structure allows you to easily test and learn individual SDK features.
All examples in this project follow a consistent pattern:
- Examples are organized in folders by feature category
- Each example is a static class with static methods
- Examples can be called from
Program.csby uncommenting the relevant lines - Replace placeholder values (e.g.,
<recordUid_here>,<userEmail_here>) with actual values
Example usage:
// In Program.cs, uncomment and modify:
await RecordsExamples.AddRecordExample.AddRecord(
name: "My New Record",
type: "login",
folderUid: null
);All examples use JsonConfigurationStorage which stores configuration data in the current directory as a JSON file (config.json). This includes:
- Last login username
- Device token (to avoid repeated device approvals)
- Server settings
For production use, consider implementing IConfigurationStorage to store this data securely according to your application's requirements.
Most examples require authentication first. The AuthenticateAndGetVault.cs class provides a helper method:
var vault = await AuthenticateAndGetVault.GetVault();Alternatively, use the LoginExamples for more control over the authentication process.
The examples use SimpleInputManager (implements IInputManager) for console input. For GUI applications:
- Implement
IInputManagerwith dialog boxes for password/2FA prompts - Use the same authentication flow (
AuthSync) with your custom input manager - See the WPFSample project for a GUI example
In production applications, add proper error handling around:
- Authentication failures
- Network connectivity issues
- Invalid vault operations
- Permission errors for enterprise operations
- Missing or invalid record/folder UIDs
- For CLI functionality: See the Commander CLI project for a full-featured command-line interface
- For PowerShell: See the PowerCommander module
- For GUI applications: See the WPFSample project
- For API documentation: Visit the Keeper SDK Documentation