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 classCustomField
Represents a custom field.
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 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 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 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 classRecordTypePasswordField
Public classRecordTypesConstants
Record Types Schema: Fields
Public classSecretManagerShare
Public classSecretsManagerApplication
Public classSecretsManagerDevice
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
Represents 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.
Interfaces
  InterfaceDescription
Public interfaceIAttachment
Defines property for file attachment
Public interfaceIAttachmentUploadTask
Defines properties of file upload task.
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 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 enumerationRecordFieldMultiple
Specifies if Record Field allows multiple values.
Public enumerationRecordTypeScope
Specifies Record Type Scope
Public enumerationSecretManagerSecretType
Public enumerationUserType
Specifies shared folder user type.
Examples
using System.Linq;
using System.Threading;
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.Records.FirstOrDefault(x => string.Compare(x.Title, "Google", StringComparison.InvariantCultureIgnoreCase) == 0);
        // Create a record if it does not exist.
        if (search == null)
        {
            search = new PasswordRecord
            {
                Title = "Google",
                Login = "/Account Name/",
                Password = "/Account Password/",
                Link = "https://google.com",
                Notes = "Stores google credentials"
            };
            search = await vault.CreateRecord(search);
        }

        // Update record.
        search.SetCustomField("Security Token", "11111111");
        search = await vault.UpdateRecord(search);

        // find file attachment.
        var attachment = search.Attachments
            .FirstOrDefault(x => string.Compare(x.Title, "google", StringComparison.InvariantCultureIgnoreCase) == 0);
        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 
            search.Attachments.Remove(attachment);
            await vault.UpdateRecord(search);
        }

        // 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