Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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..

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2017-01-20 11:16 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (174 votes). Check out past polls.