Hi perlmongers,

my current problem is the following:

I have a ldif input file from an ldap database, which I want to get the groupnames, guid and members from.

The structure is like this:

<some irrelevant data or the same like downwards> dn: cn=groupname1,dc=domain,dc=com cn: groupname1 gidNumber: 122 memberUid: member1 memberUid: member2 memberUid: member3 memberUid: member4 memberUid: member6 memberUid: member7 userPassword:: Kg== objectClass: top objectClass: posixGroup creatorsName: uid=cyrus,dc=domain,dc=com createTimestamp: 20040408083004Z modifiersName: uid=cyrus,dc=domain,dc=com modifyTimestamp: 20040408083004Z <more irrelevant data or the same like above> dn: cn=groupname2,dc=domain,dc=com cn: groupname2 gidNumber: 113 userPassword:: Kg== objectClass: top objectClass: posixGroup creatorsName: uid=cyrus,dc=domain,dc=com createTimestamp: 20031208140152Z memberUid: member1 memberUid: member2 memberUid: member3 memberUid: member4 memberUid: member6 memberUid: member7 description: some irrelevant description modifiersName: uid=cyrus,dc=domain,dc=com modifyTimestamp: 20040404112251Z <more irrelevant data or the same like above>

Each group of information is separated from the others with an empty line as you can see.

Now I want to regexp across the file and collect from each group of information starting with

dn: cn=<groupname>,dc=domain,dc=com

the following data:
cn: <groupname><br> gidNumber: <guid><br> memberUid: <membername>

The aim is to collect this data to use for another cyrus imap mailserver getting the groups information from an mysql database.

How can I do this?

--

there are no silly questions

killerhippy

In reply to rexexp across a ldap ldif file, collecting cn: guid: memberUID: by khippy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.