Rfc2253 1.0.0

.NET Core 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package Rfc2253 --version 1.0.0
NuGet\Install-Package Rfc2253 -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rfc2253" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rfc2253 --version 1.0.0
#r "nuget: Rfc2253, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Rfc2253 as a Cake Addin
#addin nuget:?package=Rfc2253&version=1.0.0

// Install Rfc2253 as a Cake Tool
#tool nuget:?package=Rfc2253&version=1.0.0

RFC 2253 Distinguished Name Parser

A .NET Core 2.0 package to parse LDAP (or X.509) Distinguished Names and optionally normalize them so that two (or more) Distinguished Names can be compared to one another for equivalency.

Closely follows RFC 2253 (https://www.ietf.org/rfc/rfc2253.txt) for parsing. Parses both LDAPv2 and LDAPv3, but normalizes output for LDAPv3.

Package is released under the MIT license.

You may review the source and contribute to the project at GitHub: https://github.com/Ski-Dive-Dev/RFC2253

Instructions for Use

  1. Supply a Distinguished Name to be parsed to the DistinguishedName.Create(string distinguishedName) method
  2. Call the Normalized() method on the returned object to normalize the internal structures to be strictly compliant to RFC 2253
  3. Do the same two calls for another Distinguished Name
  4. To compare the two Distinguished Names for equivalency, compare the DistinguishedName objects' ToString() results to one another

Currently, RDNs must be in the same order in both Distinguished Names being compared, and OIDs do not match against Attribute Names -- these features will be added in a future version.

Sample NUnit Test Cases

[TestCase(@"CN=Steve Kille,O=Isode Limited,C=GB", 
    ExpectedResult = @"cn=Steve Kille,o=Isode Limited,c=GB")]
[TestCase(@"OU=Sales+CN=J. Smith,O=Widget Inc.,C=US", 
    ExpectedResult = @"ou=Sales+cn=J. Smith,o=Widget Inc.,c=US")]
[TestCase(@"CN=L. Eagle,O=Sue\, Grabbit and Runn,C=GB",
    ExpectedResult = @"cn=L. Eagle,o=Sue\, Grabbit and Runn,c=GB")]
[TestCase(@"CN =Before\0DAfter,O= Test,C  =  GB", ExpectedResult = @"cn=Before\0DAfter,o=Test,c=GB")]
    ExpectedResult = @",o=Test,c=GB")]
[TestCase(@"SN=Lu\C4\8Di\C4\87", ExpectedResult = @"sn=Lu\C4\8Di\C4\87")]
[TestCase(@"OID. \+ Bytes, O=OID Prefix,C=GB", 
    ExpectedResult = @" \+ Bytes,o=OID Prefix,c=GB")]
[TestCase(@"", ExpectedResult = @"")]
[TestCase(@"CN=""Quoted Last, Quoted First"", O=Space After Comma ; C = Semi's too!", 
    ExpectedResult = @"cn=Quoted Last\, Quoted First,o=Space After Comma,c=Semi's too!")]
[TestCase(@"CN=", ExpectedResult = @"cn=")]
[TestCase(@"CN=,sn=Smith", ExpectedResult = @"cn=,sn=Smith")]
[TestCase(@"Good\20Dog", ExpectedResult = @"Good Dog")]
[TestCase(@"Smith\2cJohn", ExpectedResult = @"Smith\,John")]
[TestCase(@"Smith\2CJohn", ExpectedResult = @"Smith\,John")]
[TestCase(@"My\FFChar", ExpectedResult = @"My\FFChar")]
[TestCase(@"My\0DChar", ExpectedResult = @"My\0DChar")]
[TestCase(@"My\0dChar", ExpectedResult = @"My\0DChar")]
[TestCase(@"This\+That", ExpectedResult = @"This\+That")]
[TestCase(@"Literal Back\\Slash", ExpectedResult = @"Literal Back\\Slash")]
[TestCase(@"Not\&Valid", ExpectedResult = @"Not\&Valid")]
[TestCase(@"", ExpectedResult = @"")]
[TestCase("\"All good boys deserve fudge.\"", ExpectedResult = "All good boys deserve fudge.")]
[TestCase("\"All good boys + girls deserve fudge.\"", ExpectedResult = "All good boys \\+ girls deserve fudge.")]
[TestCase("\"Boys, girls + adults deserve fudge.\"", ExpectedResult = "Boys\\, girls \\+ adults deserve fudge.")]
[TestCase("\"Don't expect to fix \\3cthis\\3e; but this.\"",
    ExpectedResult = "Don't expect to fix \\3cthis\\3e\\; but this.")]
[TestCase("\"  Leading Spaces\"", ExpectedResult = "\\20 Leading Spaces")]
[TestCase("\"Trailing Spaces  \"", ExpectedResult = "Trailing Spaces \\20")]
[TestCase("\"  Leading and Trailing Spaces  \"", ExpectedResult = "\\20 Leading and Trailing Spaces \\20")]
[TestCase("\"Only opening quote", ExpectedResult = "\"Only opening quote")]
[TestCase("Only closing quote\"", ExpectedResult = "Only closing quote\"")]
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Rfc2253:

Package Downloads

SK Smart-ID external authentication for ASP.NET Core applications.


SK ID-card external authentication for ASP.NET Core applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 15,333 2/1/2021
1.1.1 275 1/23/2021
1.1.0 275 1/23/2021
1.0.0 6,448 6/6/2018

Released under the MIT License.