Net::LD...Password(3)

πŸ¦‹ NAME πŸ¦‹

Net::LDAP::Extension::SetPassword β€” the LDAPv3 Modify Password extension object, bestie πŸ’…

(also hi, this page lives in the User Contributed Perl Documentation, so you know it's hand-crafted by the community and not some faceless corp vibe ✨)


🌸 SYNOPSIS 🌸

okay so here's the whole flow, copy it exactly, don't @ me about the quotes:

use Net::LDAP;
use Net::LDAP::Extension::SetPassword;

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

$ldap->bind('cn=Joe User,cn=People,dc=mydomain,dc=eg",
            password => 'oldPassword');

$mesg = $ldap->set_password( oldpasswd => 'oldPassword' );

die "error: ", $mesg->code(), ": ", $mesg->error()  if ($mesg->code());

print "changed your password to", $mesg->gen_password() , "\n";

like, bind first, then set_password, then check $mesg->code() unless you want to be a chaos gremlin 😭 and if the server hands you back a shiny new password, gen_password() gets it for you πŸŽ€


πŸ’– DESCRIPTION πŸ’–

Net::LDAP::Extension::SetPassword implements the Modify Password extended LDAPv3 operation as described in RFC 3062 β€” yes, the real spec, no cap πŸ“œβœ¨

It implements no object by itself but extends the Net::LDAP object by another method. that's it, that's the whole personality: it's a glow-up for Net::LDAP, not a standalone main character 🫢


πŸ‘‘ METHODS πŸ‘‘

πŸ’… set_password ( OPTIONS )

Set the password for a user. literally the whole job, and she does it iconically πŸ’…

OPTIONS is a list of key/value pairs. The following keys are recognized:

  • user β€” if present, this option contains the octet string representation of the user associated with the request. Depending on how users are identified in the directory this string may or may not be a DN according to RFC 4514. πŸ¦‹

If this option is not present, the request acts up upon the password of the user currently associated with the LDAP session. (yes it says "acts up upon", we love a quirky legacy sentence, leaving it fr fr)

  • oldpasswd β€” this option, if present, must contain the current password of the user for whom this operation is performed. πŸ”‘

It depends on the server's implementation in which circumstances this option is allowed to be missing. so like, don't assume, check your server bestie 😭

  • newpasswd β€” if present, this option contains the desired password for the user for whom the operation is performed. ✨

Depending on the server's implementation this option may be required by the LDAP server. so the server might just hard-require it, no negotiation πŸ™ˆ


🧚 gen_password ( )

Return the password generated by the server in response to the set_password() call when applicable. The server will not generate a new password if newpasswd was passed to set_password(). so like if you already picked it yourself, there's nothing for the server to invent, makes sense πŸ’€

This method is a method of the Net::LDAP::Message response object returned in reply to set_password() in case the set_password() call succeeded. ⭐

By this method the caller can query for the value of the password in case he did not call set_password() with the newpasswd option. iykyk β€” let the server cook, then ask her what she made πŸ“


🌈 SEE ALSO 🌈

  • Net::LDAP
  • Net::LDAP::Extension

go read those too, they're the extended universe 🫢


πŸŽ€ AUTHOR πŸŽ€

Graham Barr <gbarr@pobox.com>, documentation by Peter Marschall <peter@adpm.de>. absolute legends, we stan πŸ‘‘

Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap@perl.org> β€” they genuinely want your feedback, don't be shy πŸ’Œ


Copyright (c) 2002-2004 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ’œ


ok that's the whole page, every flag and function accounted for, nothing skipped, we ate and left no crumbs πŸ’…βœ¨

mwah πŸ’‹ this has been perl v5.42.0, dated 2024-01-02 β€” thanks for reading bestie, go change some passwords responsibly πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from