I have a key-value pair array that contains an LDAP distinguished name, and I want to retrieve the DNS domain name of the host. (Only the DC's not the fqdn)
Assume that the LDAP parsing is done correctly, and the DC entries when combined constitute the DNS domain name of the host.
Given the code below, is it possible to convert
DC = my
DC = domain
DC = com
into
my.domain.com
I could use a for...each with a stringbuilder but it doesn't feel elegant. Is there a better way?
My code is below:
var kvList = ParseDistinguishedName(ldapName);
StringBuilder sb = new StringBuilder();
var names = (from k in kvList
where k.Key == "DC"
select k.Value);