# .NET Developer Setup

### .Net SDK

The Keeper .NET SDK provides comprehensive programmatic access to Keeper Password Manager's vault and administrative features. Built for modern .NET applications, it enables seamless integration of enterprise password management, privileged access management, and secrets management capabilities.

#### Key Features

* Secure vault access and synchronization
* Complete record lifecycle management
* Enterprise user and team administration
* Automated password rotation
* Folder and shared folder management
* File attachment operations
* BreachWatch integration
* Cross-platform support (Windows, macOS, Linux)

### Installation

#### Via NuGet Package Manager

```bash
dotnet add package Keeper.Sdk
```

#### Via .csproj Reference

```xml
<PackageReference Include="Keeper.Sdk" Version="1.1.2" />
```

### SDK Components

#### Core SDK Library

The main SDK library for programmatic access:

* **Source Code**: [KeeperSdk on GitHub](https://github.com/Keeper-Security/keeper-sdk-dotnet/tree/master/KeeperSdk)
* **Getting Started :** [KeeperSdk README](https://github.com/Keeper-Security/keeper-sdk-dotnet/blob/master/KeeperSdk/README.md)
* **Documentation**: [KeeperSdk Documentation](https://docs.keeper.io/en/keeperpam/commander-sdk/keeper-commander-sdks/sdk-command-reference#command-categories)
* **NuGet Package**: [Keeper.Sdk](https://www.nuget.org/packages/KeeperSdk/)

#### DotNet Commander CLI

Full-featured command-line application for vault management:

* **Source Code**: [Commander on GitHub](https://github.com/Keeper-Security/keeper-sdk-dotnet/tree/master/Commander)
* **Getting Started**: [Commander README](https://github.com/Keeper-Security/keeper-sdk-dotnet/blob/master/Commander/README.md)
* **Documentation**: [KeeperSdk Documentation](https://docs.keeper.io/en/keeperpam/commander-sdk/keeper-commander-sdks/sdk-command-reference#command-categories)
* **Features**: Interactive shell, batch operations, enterprise administration

#### PowerCommander Module

PowerShell module for automation and scripting:

* **Installation**: `Install-Module -Name PowerCommander`
* **Source Code**: [PowerCommander on GitHub](https://github.com/Keeper-Security/keeper-sdk-dotnet/tree/master/PowerCommander)
* **Getting Started**: [PowerCommander README](https://github.com/Keeper-Security/keeper-sdk-dotnet/blob/master/PowerCommander/README.md)
* **Documentation**: [KeeperSdk Documentation](https://docs.keeper.io/en/keeperpam/commander-sdk/keeper-commander-sdks/sdk-command-reference#command-categories)

### Developer Requirements

#### Target Frameworks

* **.NET 8.0** - Latest .NET version with improved performance
* **.NET Standard 2.0** - Broad compatibility with .NET Framework and .NET Core

#### Supported Platforms

* ✅ **Windows** (10+, Server 2019+)
* ✅ **macOS** (11.0+)
* ✅ **Linux** (Ubuntu 20.04+, RHEL 8+)

#### Development Prerequisites

* [.NET 8.0 SDK](https://dotnet.microsoft.com/download) or later
* Visual Studio 2022, VS Code, or JetBrains Rider (recommended)
* A Keeper Security account ([sign up here](https://keepersecurity.com))

#### Source Integrations

* For source integration into your .Net code, please utilize the KeeperSDK Library source code:\
  <https://github.com/Keeper-Security/keeper-sdk-dotnet/tree/release/KeeperSdk>

### API Documentation

Comprehensive API reference documentation:

&#x20;**Full API Reference**: [Keeper SDK API Documentation](https://keeper-security.github.io/gitbook-keeper-sdk/CSharp/html/R_Project_Documentation.htm)

#### Key Namespaces

| Namespace                                                                                                                             | Description                                     |
| ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| [KeeperSecurity.Authentication](https://keeper-security.github.io/gitbook-keeper-sdk/CSharp/html/N_KeeperSecurity_Authentication.htm) | Authentication, 2FA, device approval, SSO       |
| [KeeperSecurity.Vault](https://keeper-security.github.io/gitbook-keeper-sdk/CSharp/html/N_KeeperSecurity_Vault.htm)                   | Vault operations, records, folders, attachments |
| [KeeperSecurity.Enterprise](https://keeper-security.github.io/gitbook-keeper-sdk/CSharp/html/N_KeeperSecurity_Enterprise.htm)         | Enterprise administration, users, teams, roles  |
| [KeeperSecurity.Configuration](https://keeper-security.github.io/gitbook-keeper-sdk/CSharp/html/N_KeeperSecurity_Configuration.htm)   | Configuration storage and management            |

### Core Capabilities

#### Authentication

* **AuthSync** - Synchronous authentication flow
* **Master Password** - Standard Keeper authentication
* **Two-Factor (2FA)** - TOTP, SMS, push notifications
* **Device Approval** - Email and admin approval flows
* **SSO Integration** - Enterprise single sign-on
* **Biometric** - WebAuthn/FIDO2 support

#### Vault Operations

* **Records** - Create, read, update, delete records
* **Typed Records** - Support for all Keeper record types and custom record types
* **Attachments** - Upload and download file attachments
* **Folders** - Organise records in folder hierarchy
* **Shared Folders** - Team collaboration and permissions
* **Search** - Find records by title, URL, or custom fields

#### Enterprise Management

* **User Management** - Create, modify, delete enterprise users
* **Team Management** - Organise users into teams
* **Role-Based Access** - Manage roles and permissions
* **Audit Logs** - Retrieve and analyse audit trail
* **Device Management** - Approve and manage devices
* **Managed Companies** - MSP multi-tenant operations

#### Security Features

* **End-to-End Encryption** - Zero-knowledge architecture
* **Device Token Management** - Secure persistent sessions
* **BreachWatch** - Monitor compromised credentials
* **Password Reports** - Generate security compliance reports

Getting Started Resources

#### Documentation

* 📖 [Main Repository](https://github.com/Keeper-Security/keeper-sdk-dotnet)
* 📖 [SDK Documentation](https://github.com/Keeper-Security/keeper-sdk-dotnet/blob/master/KeeperSdk/README.md)
* 📖 [Commander CLI Guide](https://github.com/Keeper-Security/keeper-sdk-dotnet/blob/master/Commander/README.md)
* 📖 [PowerCommander Guide](https://github.com/Keeper-Security/keeper-sdk-dotnet/blob/master/PowerCommander/README.md)
* 📖 [Sample Applications](https://github.com/Keeper-Security/keeper-sdk-dotnet/blob/master/Sample/README.md)

### Support

#### Get Help

* &#x20;**Email**: <commander@keepersecurity.com>
* &#x20;**GitHub Issues**: [Report bugs or request features](https://github.com/Keeper-Security/keeper-sdk-dotnet/issues)
* &#x20; **Website**: [keepersecurity.com](https://keepersecurity.com)

#### Enterprise Support

For enterprise support, custom integrations, or technical assistance, contact our team at <commander@keepersecurity.com>.

### Examples

For help with implementation of SDK features, please see the Sample Application:\
<https://github.com/Keeper-Security/keeper-sdk-dotnet/tree/master/Sample>

The .Net Commander CLI Sample App contains several basic operations such as logging in, authentication with two-factor, loading and decrypting the vault and updating passwords.\
<https://github.com/Keeper-Security/keeper-sdk-dotnet/tree/release/Commander>

We use `InputManager` class to deal with console inputs in below examples. The implementation can be found at <https://github.com/Keeper-Security/keeper-sdk-dotnet/blob/master/Cli/InputManager.cs>

#### Basic Authentication and Vault Access

```csharp
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 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
Console.WriteLine($"Your vault has {vault.RecordCount} records.");
```

#### Creating a New Record

```csharp
// 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}");
```

#### Change Password

```csharp
// Find and update a password
var record = vault.KeeperRecords
    .FirstOrDefault(x => x.Title == "Database");

if (record is PasswordRecord passwordRecord)
{
    passwordRecord.Password = "NewSecurePassword123!";
    await vault.UpdateRecord(passwordRecord);
    Console.WriteLine("Password rotated successfully");
}
```

#### Working with Attachments

```csharp
using System.IO;
using KeeperSecurity.Commands;

// Upload attachment
using (var stream = File.OpenRead("config.json"))
{
    var uploadTask = new FileAttachmentUploadTask("config.json")
    {
        Title = "Configuration File",
        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);
    }
}
```

#### Shared Folder Management

```csharp
// Get shared folder
var sharedFolder = vault.SharedFolders
    .FirstOrDefault(x => x.Name == "Team Credentials");

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

#### Enterprise User Management

```csharp
using KeeperSecurity.Enterprise;

if (auth.AuthContext.IsEnterpriseAdmin)
{
    // Load enterprise data
    var enterprise = new EnterpriseData();
    var loader = new EnterpriseLoader(auth, new[] { enterprise });
    await loader.Load();
    
    // Create team
    var team = await enterprise.CreateTeam(new EnterpriseTeam
    {
        Name = "Engineering",
        RestrictEdit = false,
        RestrictSharing = true
    });
    
    // Add users to team
    await enterprise.AddUsersToTeams(
        new[] { "user@company.com" },
        new[] { team.Uid },
        Console.WriteLine
    );
}
```
