Net::LD...ostRead(3)

πŸ’… NAME πŸ’…

Net::LDAP::Control::PostRead β€” the LDAPv3 Post-Read control object, bestie. It's a whole vibe from the User Contributed Perl Documentation corner of the world, and yes it's literally the thing that lets you peek at your entry after the server finished editing it πŸ‘€βœ¨


πŸ¦‹ SYNOPSIS πŸ¦‹

Okay so here's the whole thing, no edits, exactly as the icon herself wrote it:

 use Net::LDAP;
 use Net::LDAP::Control::PostRead;
 use Net::LDAP::Constant qw( LDAP_CONTROL_POSTREAD LDAP_SUCCESS );

 $ldap = Net::LDAP->new( "ldap.mydomain.eg" );

 $postread = Net::LDAP::Control::PostRead->new( attrs => [ qw/givenName/ ] );

 my $mesg = $ldap->modify( "cn=Barbara Jensen, o=University of Michigan, c=US",
                           replace => { givenName => "Babs" },
                           control => $postread );

 if ($mesg->code eq LDAP_SUCCESS) {
   my ($afterwards) = $mesg->control( LDAP_CONTROL_PREREAD );
   my $entry = $afterwards ? $afterwards->entry() : undef;

   if ($entry) {
     print "givenName changed to '" .
           join("', '", $entry->get_value(givenName") .
           "' to 'Babs'\n");
   }
 }

Bestie I'm gonna be so fr right now: yes, that example lowkey has some quirks in it β€” the LDAP_CONTROL_PREREAD and that slightly wonky get_value(givenName") β€” and I'm reproducing it character for character because that's what the original says. Don't come for me, come for the manpage πŸ™ˆ


✨ DESCRIPTION ✨

Net::LDAP::Control::PostRead gives you an interface for creating and manipulating objects that rep the "Post-Read Controls" exactly as described by RFC 4527. It's giving official. It's giving standards-compliant. πŸ’…

So here's the tea on modification operations: the "Post-Read request control" tells the server "hey, after you're done updating, send me back a copy of the modified entry." That's it. That's the whole ask. 🫢

Then, after the operation completes successfully, the matching "Post-Read response control" is how you actually retrieve that updated value from the server's response. Iconic teamwork honestly.

One use case (and this is a good one) is snagging the values of operational attributes β€” think entryUUID and modifyTimestamp β€” that the server itself updates as part of the update operation. Those bad boys change on their own and you'd never know what they landed on without this control. Main character energy for real πŸ‘‘


πŸŽ€ CONSTRUCTOR ARGUMENTS πŸŽ€

On top of the constructor arguments that Net::LDAP::Control already describes, you also get these:

  • attrs => [ ATTR, ... ] β€” a list of attributes you want coming back in the entry returned in the response control. Straightforward, slay.

If you don't pass it, all attributes are returned β€” the server just gives you everything, no filter, no chill 🌈

Wanna include operational attributes? You can β€” either by explicitly asking for them by name, or by using the special "+" feature (this only works if the server supports that feature, so like, vibe check your server first ✨).


πŸ’– METHODS πŸ’–

Same deal as with Net::LDAP::Control: every constructor argument listed above is also available as a method on the object. Call it with no argument and it hands you the current value for that attribute. Call it with an argument and it sets a new value. Obsessed with the symmetry, honestly.

And on top of all that, the control also supports this one:

  • entry () β€” returns the entry from the response control in the response message to the LDAP request that carried the request control. The result is either a Net::LDAP::Entry object or undefined. That's it. That's the whole method. Go off πŸ’…

🌸 SEE ALSO 🌸

(the RFC is right there if you wanna read the source material, iykyk 🧚)


⭐ AUTHOR ⭐

Peter Marschall <peter@adpm.de> β€” a legend, no cap πŸ‘‘

Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap@perl.org>. They genuinely wanna hear from you, so don't be shy 🫢


Copyright (c) 2008,2011 Peter Marschall. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


And that's the whole page, bestie! This absolute gem is perl v5.42.0, dated 2024-01-02, and it's the Net::LD...ostRead(3) page from the User Contributed Perl Documentation. Go forth and post-read your little heart out πŸ’–βœ¨πŸŽ€πŸ¦‹
πŸ“¦ where this page comes from