DSInternals.Replication
6.4.0
Prefix Reserved
dotnet add package DSInternals.Replication --version 6.4.0
NuGet\Install-Package DSInternals.Replication -Version 6.4.0
<PackageReference Include="DSInternals.Replication" Version="6.4.0" />
<PackageVersion Include="DSInternals.Replication" Version="6.4.0" />
<PackageReference Include="DSInternals.Replication" />
paket add DSInternals.Replication --version 6.4.0
#r "nuget: DSInternals.Replication, 6.4.0"
#:package DSInternals.Replication@6.4.0
#addin nuget:?package=DSInternals.Replication&version=6.4.0
#tool nuget:?package=DSInternals.Replication&version=6.4.0
DSInternals Replication Library
Introduction
The DSInternals.Replication package implements a client for the Active Directory Replication Service Remote Protocol (MS-DRSR). This is commonly known as DCSync and allows you to remotely extract password hashes and other sensitive data from domain controllers.
Key Features
- Full Account Replication: Retrieve complete account objects including password hashes
- Incremental Replication: Sync only changed objects since the last replication
- DPAPI Backup Key Retrieval: Extract domain DPAPI backup keys for credential decryption
- KDS Root Key Access: Retrieve Key Distribution Service root keys for gMSA and dMSA password computation
- Schema Replication: Replicate the Active Directory schema
Platform Compatibility
Applications using this library may encounter the BadImageFormatException or FileNotFoundException exceptions
when trying to load the DSInternals.Replication.Interop.dll assembly.
This is because the assembly contains platform-specific code.
To resolve this issue, ensure that your project is configured to target the appropriate platform (x64, x86, or arm64).
Modern SDK-style projects should contain these settings:
<PropertyGroup>
<TargetFrameworks>net10.0-windows;net48</TargetFrameworks>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DSInternals.Replication" Version="6.3.0" />
</ItemGroup>
Legacy .NET Framework projects using packages.config should contain the following settings:
<Import Project="packages\DSInternals.Replication.6.3.0\build\net48\DSInternals.Replication.props" Condition="Exists('packages\DSInternals.Replication.6.3.0\build\net48\DSInternals.Replication.props')" />
<PropertyGroup>
<Prefer32Bit>false</Prefer32Bit>
<PreferNativeArm64>true</PreferNativeArm64>
</PropertyGroup>
Usage Examples
Connecting to a Domain Controller
using DSInternals.Replication;
using System.Net;
string domainController = "dc01.contoso.com";
// Connect using current credentials
using var client = new DirectoryReplicationClient(domainController);
Console.WriteLine($"Connected to: {client.DomainNamingContext}");
Console.WriteLine($"NetBIOS Domain: {client.NetBIOSDomainName}");
Replicating a Single Account (DCSync)
using DSInternals.Replication;
using DSInternals.Common.Data;
string domainController = "dc01.contoso.com";
using var client = new DirectoryReplicationClient(domainController);
// Replicate a specific account by distinguished name
string userDn = "CN=Administrator,CN=Users,DC=contoso,DC=com";
DSAccount account = client.GetAccount(userDn);
Console.WriteLine($"Account: {account.SamAccountName}");
Console.WriteLine($"SID: {account.Sid}");
if (account.NTHash != null)
{
string ntHash = BitConverter.ToString(account.NTHash).Replace("-", "");
Console.WriteLine($"NT Hash: {ntHash}");
}
Replicating All Domain Accounts
using DSInternals.Replication;
using DSInternals.Common.Data;
string domainController = "dc01.contoso.com";
using var client = new DirectoryReplicationClient(domainController);
// Enumerate all accounts in the domain
foreach (DSAccount account in client.GetAccounts())
{
Console.WriteLine($"Account: {account.SamAccountName}");
if (account.NTHash != null)
{
string ntHash = BitConverter.ToString(account.NTHash).Replace("-", "");
Console.WriteLine($" NT Hash: {ntHash}");
}
}
Connecting with Alternate Credentials
using DSInternals.Replication;
using System.Net;
string domainController = "dc01.contoso.com";
// Create credentials
var credential = new NetworkCredential(
userName: "admin",
password: "P@ssw0rd",
domain: "CONTOSO"
);
using var client = new DirectoryReplicationClient(domainController, credential);
// Now perform replication operations...
Extracting DPAPI Backup Keys
using DSInternals.Replication;
string domainController = "dc01.contoso.com";
using var client = new DirectoryReplicationClient(domainController);
// Get the domain DPAPI backup key
var backupKey = client.GetDPAPIBackupKey();
Console.WriteLine($"Key ID: {backupKey.KeyId}");
// Use the key to decrypt DPAPI-protected data
Security Considerations
This library performs operations that require elevated privileges:
- Replicating Directory Changes permission (for basic replication)
- Replicating Directory Changes All permission (for password hash replication)
- These permissions are typically held by Domain Admins and Domain Controllers
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- DSInternals.Common (>= 6.4.0)
-
net8.0-windows7.0
- DSInternals.Common (>= 6.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on DSInternals.Replication:
| Repository | Stars |
|---|---|
|
lithnet/ad-password-protection
Active Directory password filter featuring breached password checking and custom complexity rules
|
| Version | Downloads | Last Updated |
|---|---|---|
| 6.4.0 | 301 | 3/28/2026 |
| 6.3.0 | 749 | 2/8/2026 |
| 6.1.0 | 2,385 | 8/17/2025 |
| 6.0.1 | 220 | 8/14/2025 |
| 6.0.0 | 244 | 8/14/2025 |
| 5.3.0 | 569 | 4/11/2025 |
| 5.2.0 | 352 | 4/9/2025 |
| 5.0.0 | 324 | 3/3/2025 |
| 4.14.0 | 2,177 | 4/13/2024 |
| 4.13.0 | 1,317 | 12/20/2023 |
| 4.12.0 | 320 | 10/6/2023 |
| 4.10.0 | 284 | 10/1/2023 |
| 4.8.0 | 1,865 | 12/6/2022 |
| 4.7.0 | 1,722 | 10/30/2021 |
| 4.5.0 | 665 | 10/13/2021 |
| 4.3.0 | 37,415 | 4/2/2020 |
| 4.2.0 | 870 | 3/18/2020 |
| 4.0.0 | 926 | 12/4/2019 |
| 3.2.0 | 9,417 | 1/3/2019 |
| 3.1.0 | 1,180 | 12/29/2018 |
- Updated assembly dependencies.