Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Parsing of LDAP entry

by mariusz (Initiate)
on Jul 30, 2013 at 20:48 UTC ( #1047120=perlquestion: print w/ replies, xml ) Need Help??
mariusz has asked for the wisdom of the Perl Monks concerning the following question:


I have one problem with Perl, so I would appreciate if you could help to find the best solution for that.

In my company we use SunOne LDAP. I want to connect to cn=changelog and read all entries in this node.

Structure of one entry looks like that:

dn: changeNumber=123,cn=changelog objectClass: top objectClass: changelogentry ...something not important.... changes: BASE64_TEXT

When I try to read ($entry->get_value("changes")) and decode changes, then I received something like this:

replace: A A: new_value - add: NEW_VAR NEW_VAR: ABC - delete: ABC - replace: history history: 1 history: 2 history: 3 -

In my case on the output I want to get (single line):


Is there any simple way to "PARSE" changes value? Unfortunately, type of this value is string..

Comment on Parsing of LDAP entry
Select or Download Code
Replies are listed 'Best First'.
Re: Parsing of LDAP entry (get_value( $var, asref => 1 );
by Anonymous Monk on Jul 30, 2013 at 22:30 UTC

      Thank you for reply.

      Please take a look for my example:

      (...) my $ref = $entry->get_value ( 'changes', asref => 1 ); print Dumper($ref);


      perl $VAR1 = [ 'delete: employeeType employeeType: Intern - add: employeeType employeeType: No Longer Employed - add: description description: On 30-07-2013 05:17 removed from source. - add: nsAccountLock nsAccountLock: true - replace: modifiersname modifiersname: cn=mmariusz,ou=people,ou=testENV - replace: modifytimestamp modifytimestamp: 20130730031746Z - '

      So, this is stil "multiline" result in one variable. Probably I need to create some kind of function/object and make a parser for that:

      function magic() { my $string = shift; # some magic should be placed here :) #sample return return @replaced_attrs,@added_attrs,@delete_attrs; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1047120]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2015-11-25 10:38 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (673 votes), past polls