Rfc2253 1.1.0
See the version list below for details.
dotnet add package Rfc2253 --version 1.1.0
NuGet\Install-Package Rfc2253 -Version 1.1.0
<PackageReference Include="Rfc2253" Version="1.1.0" />
paket add Rfc2253 --version 1.1.0
#r "nuget: Rfc2253, 1.1.0"
// Install Rfc2253 as a Cake Addin #addin nuget:?package=Rfc2253&version=1.1.0 // Install Rfc2253 as a Cake Tool #tool nuget:?package=Rfc2253&version=1.1.0
RFC 2253 Distinguished Name Parser
Note: This project was originally released targeting .NET Core 2.0. RFC 2253 Distinguished Name Parser Version 1.1.0 now targets .NET Standard 1.3 to make it compatible with a larger number of projects. Refer to .NET Standard for more details.
This project is a .NET Standard solution 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 for parsing. Parses both LDAPv2 and LDAPv3, but normalizes output for LDAPv3.
See the project at RFC 2253 Distinguished Name Parser.
Instructions for Use
- Supply a Distinguished Name to be parsed to the
DistinguishedName.Create(string distinguishedName)
method - Call the
Normalized()
method on the returned object to normalize the internal structures to be strictly compliant to RFC 2253 - Do the same two calls for another Distinguished Name
- 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 may be added in a future version.
Version 1.1.0 fixes a bug in the ToString()
method (commas were missing), which may be a breaking change for some implementers.
Version 1.1.0 also fixes another bug in the ToString()
method with regards to multi-valued attibutes, and now also sorts multi-valued attributes so that two distinguished names will now match if they have the same, but dis-ordered multi-valued attributes.
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")]
[TestCase(@"1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB",
ExpectedResult = @"1.3.6.1.4.1.1466.0=#04024869,o=Test,c=GB")]
[TestCase(@"SN=Lu\C4\8Di\C4\87", ExpectedResult = @"sn=Lu\C4\8Di\C4\87")]
[TestCase(@"OID.1.3.6.1.4.1.1466.0=Bytes \+ Bytes, O=OID Prefix,C=GB",
ExpectedResult = @"1.3.6.1.4.1.1466.0=Bytes \+ 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 Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Rfc2253:
Package | Downloads |
---|---|
AspNetCore.Authentication.SK.SmartID
SK Smart-ID external authentication for ASP.NET Core applications. |
|
AspNetCore.Authentication.SK.IdCard
SK ID-card external authentication for ASP.NET Core applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Released under the MIT License.