Click or drag to resize

KeeperSecurity.Vault Namespace

Provides types for loading and storing the Keeper Vault data.
Classes
 ClassDescription
Public classApplicationRecord Represents a Keeper Secret Manager Application Record.
Public classAttachmentFile Represents attachment file.
Public classAttachmentFileThumb Represents a thumbnail of attachment.
Public classAttachmentUploadTask Creates an attachment upload task.
Public classBatchResult Represents Batch Vault Updater Summary
Public classBatchVaultOperations Represents Batch Vault Updater
Public classCustomField Represents a custom field.
Public classExternalRecordShare Represents External / One-Time Share
Public classExternalRecordShareExtensions Miscellaneous External Share Methods
Public classExtraField Represents an extra field.
Public classFieldType Record Types Schema: Field Type definition.
Public classFieldTypeAddress "address" field type
Public classFieldTypeBankAccount "bankAccount" field type
Public classFieldTypeHost "host" field type
Public classFieldTypeKeyPair "keyPair" field type
Public classFieldTypeName "name" field type
Public classFieldTypePasskey "passkey" field type
Public classFieldTypePaymentCard "paymentCard" field type
Public classFieldTypePhone "phone" field type
Public classFieldTypeSecurityQuestion "securityQuestion" field type
Public classFileAttachmentUploadTask Creates a file attachment upload task.
Public classFileRecord Represents a Keeper File Record.
Public classFolderNode Represents folder.
Public classInMemoryKeeperStorage Provides in memory implementation of IKeeperStorage interface.
Public classKeeperImport Keeper Import methods
Public classKeeperRecord Represents generic Keeper Record
Public classNoActiveShareWithUserException Represents an exception that occurs when current user requests other user's public for the first time.
Public classPasswordRecord Represents a Legacy Keeper Record.
Public classRecordField Record Types Schema: Field definition.
Public classRecordHistory Represents a record history
Public classRecordPath Represents a record in folder.
Public classRecordSharePermissions Represent record sharing information
Public classRecordType Record Types Schema: Record Type definition.
Public classRecordTypeField Record Types Schema: Record Field definition.
Public classRecordTypesConstants Record Types Schema: Fields
Public classSharedFolder Represents Shared Folder.
Public classSharedFolderOptions Defines shared folder user and record permissions.
Public classSharedFolderPermission Represents shared folder user permissions.
Public classSharedFolderRecord Represents shared folder record permissions.
Public classSharedFolderRecordOptions Defines shared folder record permissions.
Public classSharedFolderRecordPermissions Represents record permissions in shared folder.
Public classSharedFolderUserOptions Defines shared folder user permissions.
Public classShareWithUsers Represent user list available for sharing
Public classSyncDownExtensions Provides a set of static methods for syncing down vault.
Public classTeam Represents team properties that user is member of.
Public classTeamInfo Represents basic team properties.
Public classTypedFieldT Represents a typed field.
Public classTypedRecord Represents a Typed Record
Public classUserRecordPermissions Represents record permissions for user.
Public classVaultData Represents Keeper vault loaded from the IKeeperStorage and decrypted.
Public classVaultException The exception that is thrown by the Vault module.
Public classVaultOnline Represents Keeper Vault connected to Keeper server.
Public classVaultOnlineSecretManagerConfiguration 
Interfaces
 InterfaceDescription
Public interfaceIAttachment Defines property for file attachment
Public interfaceIAttachmentUploadTask Defines properties of file upload task.
Public interfaceIBatchVaultOperations Declares Batch Vault Updater methods
Public interfaceIEnterpriseTeam Defines properties for Enterprise Team.
Public interfaceIEntityStorageT Defines entity storage methods.
Public interfaceIFieldTypeSerialize Defines access methods for compound record types
Public interfaceIFolder Defines properties for folder.
Public interfaceIFolderRecordLink Defines properties record-folder link.
Public interfaceIKeeperStorage Defines properties for offline Keeper vault storage.
Public interfaceINonSharedData Defines non-shared data properties.
Public interfaceIPredicateStorageT Defines entity link storage methods.
Public interfaceIRecordAccessPath Defines record access path properties.
Public interfaceIRecordMetadata Defines Record Key Metadata properties.
Public interfaceIRecordType Defines properties for Record Types.
Public interfaceIRecordTypeField Defines common properties for Record Field
Public interfaceISecretManager Define methods for Keeper Secret Maneger (KSM)
Public interfaceISecretManagerConfiguration Defines properties of Secrets Manager configuration
Public interfaceISerializeTypedField Defines methods for typed field serialization
Public interfaceISharedFolder Defines properties for shared folder.
Public interfaceISharedFolderAccessPath Defines shared folder access path properties.
Public interfaceISharedFolderKey Defines shared folder key properties.
Public interfaceISharedFolderPermission Defines properties for shared folder user permissions.
Public interfaceISharedFolderRecordOptions Defines shared folder record permissions.
Public interfaceISharedFolderUserOptions Defines shared folder user permissions.
Public interfaceIStorageRecord Defines Password Record properties.
Public interfaceIThumbnailUploadTask Defines properties of thumbnail upload task.
Public interfaceITypedField Defines properties for typed record field
Public interfaceIVault Defines methods for modifying the vault records and folders.
Public interfaceIVaultData Defines properties and methods of decrypted Vault data.
Public interfaceIVaultFileAttachment Defines methods to manipulate file attachments.
Public interfaceIVaultSharedFolder Defines methods to manipulate Shared Folders.
Public interfaceIVaultUi Defines methods for interaction between Vault API and user.
Enumerations
 EnumerationDescription
Public enumerationFolderType Specifies folder types.
Public enumerationKeyType Specifies key used for entity encryption.
Public enumerationRecordChange 
Public enumerationRecordFieldMultiple Specifies if Record Field allows multiple values.
Public enumerationRecordMatch Represents record existing match strategy
Public enumerationRecordTypeScope Specifies Record Type Scope
Public enumerationSeverity Specifies log message severity
Public enumerationUserType Specifies shared folder user type.
Example
C#
using System;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using KeeperSecurity.Authentication;
using KeeperSecurity.Vault;

internal static class Program
{
   private static async Task Main()
   {
       IAuthentication auth = await ConnectToKeeperAs("username@company.com");
       var vault = new VaultOnline(auth);
       Console.WriteLine("\nRetrieving records...");
       await vault.SyncDown();

       Console.WriteLine($"Hello {auth.Username}!");
       Console.WriteLine($"Your vault has {vault.RecordCount} records.");

       // Find record with title "Google"
       var search = vault.KeeperRecords.FirstOrDefault(x => string.Compare(x.Title, "Google", StringComparison.InvariantCultureIgnoreCase) == 0);
       // Create a record if it does not exist.
       if (search == null)
       {
           var typed = new TypedRecord("login")
           {
               Title = "Google",
               Notes = "Stores google credentials"
           };
           var loginRecord = new TypedRecordFacade<LoginRecordType>(typed);
           loginRecord.Fields.Login = "/Account Name/";
           loginRecord.Fields.Password = "/Account Password/";
           loginRecord.Fields.Url = "https://google.com";

           search = await vault.CreateRecord(typed);
       }

       // Update record
       if (search is TypedRecord tr)
       {
           var recordField = new RecordTypeField("secret", "Security Token");
           if (!tr.FindTypedField(recordField, out var rf))
           {
               rf = recordField.CreateTypedField();
               tr.Custom.Add(rf);
           }
           var tokenValue = rf.ObjectValue == null ? "1" : rf.ObjectValue.ToString() + "1";
       }
       else if (search is PasswordRecord pr)
       {
           pr.SetCustomField("Security Token", "11111111");
       }
       search = await vault.UpdateRecord(search);

       // find file attachment
       var attachment = vault.RecordAttachments(search)
           .FirstOrDefault(x => string.Equals(x.Title, "google", StringComparison.InvariantCultureIgnoreCase));
       if (attachment == null)
       {
           // Upload local file "google.txt"
           var uploadTask = new FileAttachmentUploadTask("google.txt")
           {
               Title = "Google",
           };
           await vault.UploadAttachment(search, uploadTask);
       }
       else
       {
           // Download attachment into local file "google.txt"
           await using var stream = File.OpenWrite("google.txt");
           await vault.DownloadAttachment(search, attachment.Id, stream);

           // Delete attachment. Remove it from the record 
           await vault.DeleteAttachment(search, attachment.Id);
       }

       // Find shared folder with name "Google".
       var sharedFolder = vault.SharedFolders
           .FirstOrDefault(x => string.Compare(x.Name, "Google", StringComparison.InvariantCultureIgnoreCase) == 0);
       if (sharedFolder == null)
       {
           // Create shared folder.
           var folder = await vault.CreateFolder("Google", null, new SharedFolderOptions
           {
               ManageRecords = true,
               ManageUsers = false,
               CanEdit = false,
               CanShare = false,
           });
           vault.TryGetSharedFolder(folder.FolderUid, out sharedFolder);
       }

       // Add user to shared folder.
       await vault.PutUserToSharedFolder(sharedFolder.Uid, "user@google.com", UserType.User, new SharedFolderUserOptions
       {
           ManageRecords = false,
           ManageUsers = false,
       });

       // Add record to shared folder.
       await vault.MoveRecords(new[] { new RecordPath { RecordUid = search.Uid } }, sharedFolder.Uid, true);
   }
}
See Also