Thanks Peter, I broke down and used .Decode on the DistinguishedName with UseNewLines parameter, then used regular expressions to get out the values. I'll have a look at the encoded data and see if I can get the data there better. Many thanks!
Best wishes James -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Peter Ritchie Sent: vrijdag 23 juni 2006 15:18 To: [email protected] Subject: Re: [ADVANCED-DOTNET] X500DistinguishedName - retrieve components It's a bit complex, and you have know to which component (by Oid string) you want to retrieve a value for (i.e. you can enumerate then all, one by one, or tell if one doesn't exist). For example, if you have a given X500DistinguishedName object "dname", you can get the organization name from the object as follows: AsnEncodedData asnEncodedData = new AsnEncodedData(new Oid("2.5.4.10"), dname.RawData); String organizationName = asnEncodedData.Format(false); // false == ! multiline If that component isn't in the raw data, Format() seems to send back a hex version of all the raw byte data, sometimes delimited with spaces, sometimes not. The docs for the Platform SDK function CertStrToName contain a list of ASN.1 object identifier notation strings. The OIDs normally associated with the X500DistinguishedName object are included in that list. On Fri, 23 Jun 2006 09:53:30 +0100, James Berry <[EMAIL PROTECTED]> wrote: >Given an X500DistinguishedName object, it seems there must be a good >way (other than regular expressions) to retrieve the individual >components - ie, CN, O, C etc > >Can anyone help? =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
