Improved DN parsing

This commit is contained in:
Michael Grafnetter 2020-03-04 23:13:21 +01:00
parent 770a99ad0e
commit 8d2651b33d
2 changed files with 11 additions and 1 deletions

View File

@ -289,5 +289,12 @@
var dn = new DistinguishedName("OU=Employees,OU=Marketing,DC=adatum,DC=com");
Assert.AreEqual("DC=adatum,DC=com", dn.RootNamingContext.ToString());
}
[TestMethod]
public void DistinguishedName_RootNamingContext_Vector3()
{
var dn = new DistinguishedName("DC=LON-CL1,cn=MicrosoftDNS,DC=DomainDnsZones,DC=adatum,DC=com");
Assert.AreEqual("DC=DomainDnsZones,DC=adatum,DC=com", dn.RootNamingContext.ToString());
}
}
}

View File

@ -96,7 +96,10 @@
{
get
{
var dcComponents = this.components.Where(component => component.Name.Equals(CommonDirectoryAttributes.DomainComponent, StringComparison.InvariantCultureIgnoreCase));
var dcComponents = this.components
.Reverse<DistinguishedNameComponent>()
.TakeWhile(component => component.Name.Equals(CommonDirectoryAttributes.DomainComponent, StringComparison.InvariantCultureIgnoreCase))
.Reverse();
var result = new DistinguishedName();
result.components.AddRange(dcComponents);
return result;