Re: Parse x.500 DN and change order displayed
Re: Parse x.500 DN and change order displayed
am 31.03.2008 23:31:46 von Dummy
On Mon, 31 Mar 2008 04:09:07 GMT, Uri Guttman
wrote:
>>>>>> "S" == SecureIT writes:
>
> S> I am trying to change this
> S> "cn=Bob Smith+serialNumber=CR013120080827,o=ICM,c=US"
>
> S> to this:
>
> S> "serialNumber=CR013120080827+cn=Bob Smith,o=ICM,c=US"
>
> S> There are about 2000 entries like this and I need to have them all
> S> displayed with serialNumber first, and cn last then the rest of the
> S> DN, the names and serialNumbers are all unique to each entry.
>
>are all the entries separated by +? how many are there (you show only 2)?
>
>if it is always + then you can just split the lines, grab out the cn one
>(use grep) and also filter out the rest. then order them as you
>want. call join '+' to rebuild the line. it can also be done with a hash
>but that is about the same amount of code.
>
>uri
Am I missing something? Why can't (or shouldn't) he do this?
$entry =~ s/(cn[^+]+)\+([^,]+)(.*)$/$2+$1$3/;
Is it less efficient in some way?
Re: Parse x.500 DN and change order displayed
am 01.04.2008 00:26:29 von Uri Guttman
>>>>> "d" == dummy writes:
d> On Mon, 31 Mar 2008 04:09:07 GMT, Uri Guttman
d> wrote:
>>>>>>> "S" == SecureIT writes:
>>
S> I am trying to change this
S> "cn=Bob Smith+serialNumber=CR013120080827,o=ICM,c=US"
>>
S> to this:
>>
S> "serialNumber=CR013120080827+cn=Bob Smith,o=ICM,c=US"
>>
S> There are about 2000 entries like this and I need to have them all
S> displayed with serialNumber first, and cn last then the rest of the
S> DN, the names and serialNumbers are all unique to each entry.
>>
>> are all the entries separated by +? how many are there (you show only 2)?
>>
>> if it is always + then you can just split the lines, grab out the cn one
>> (use grep) and also filter out the rest. then order them as you
>> want. call join '+' to rebuild the line. it can also be done with a hash
>> but that is about the same amount of code.
>>
>> uri
d> Am I missing something? Why can't (or shouldn't) he do this?
d> $entry =~ s/(cn[^+]+)\+([^,]+)(.*)$/$2+$1$3/;
d> Is it less efficient in some way?
that assumes the serial number is in slot 1 ($2) and i wouldn't make
that assumption. the other regex answers match the serial part and not
the cn part like you do. i was thinking about a more flexible solution
which would allow any reordering of many parts and no regex could do
that. hence my idea about split and joining in the desired order.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
Re: Parse x.500 DN and change order displayed
am 01.04.2008 00:48:21 von Dummy
On Mon, 31 Mar 2008 22:26:29 GMT, Uri Guttman
wrote:
>>>>>> "d" == dummy writes:
>
> d> On Mon, 31 Mar 2008 04:09:07 GMT, Uri Guttman
> d> wrote:
>
> >>>>>>> "S" == SecureIT writes:
> >>
> S> I am trying to change this
> S> "cn=Bob Smith+serialNumber=CR013120080827,o=ICM,c=US"
> >>
> S> to this:
> >>
> S> "serialNumber=CR013120080827+cn=Bob Smith,o=ICM,c=US"
> >>
> S> There are about 2000 entries like this and I need to have them all
> S> displayed with serialNumber first, and cn last then the rest of the
> S> DN, the names and serialNumbers are all unique to each entry.
> >>
> >> are all the entries separated by +? how many are there (you show only 2)?
> >>
> >> if it is always + then you can just split the lines, grab out the cn one
> >> (use grep) and also filter out the rest. then order them as you
> >> want. call join '+' to rebuild the line. it can also be done with a hash
> >> but that is about the same amount of code.
> >>
> >> uri
>
> d> Am I missing something? Why can't (or shouldn't) he do this?
> d> $entry =~ s/(cn[^+]+)\+([^,]+)(.*)$/$2+$1$3/;
>
> d> Is it less efficient in some way?
>
>that assumes the serial number is in slot 1 ($2) and i wouldn't make
>that assumption. the other regex answers match the serial part and not
>the cn part like you do. i was thinking about a more flexible solution
>which would allow any reordering of many parts and no regex could do
>that. hence my idea about split and joining in the desired order.
>
>uri
Thanks. Naive on my part. But it got me pointed at the subject of
X.500 DN, which I think I could use.