[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 2 package Net::LDAP::Extension::SetPassword; 3 4 require Net::LDAP::Extension; 5 6 $VERSION = "0.03"; 7 @ISA = qw(Net::LDAP::Extension); 8 9 use Convert::ASN1; 10 my $passwdModReq = Convert::ASN1->new; 11 $passwdModReq->prepare(q<SEQUENCE { 12 user [0] STRING OPTIONAL, 13 oldpasswd [1] STRING OPTIONAL, 14 newpasswd [2] STRING OPTIONAL 15 }>); 16 17 my $passwdModRes = Convert::ASN1->new; 18 $passwdModRes->prepare(q<SEQUENCE { 19 genPasswd [0] STRING OPTIONAL 20 }>); 21 22 sub Net::LDAP::set_password { 23 my $ldap = shift; 24 my %opt = @_; 25 26 my $res = $ldap->extension( 27 name => '1.3.6.1.4.1.4203.1.11.1', 28 value => $passwdModReq->encode(\%opt), 29 ($opt{control} ? (control => $opt{control}) : ()) 30 ); 31 32 bless $res; # Naughty :-) 33 } 34 35 sub gen_password { 36 my $self = shift; 37 38 my $out = $passwdModRes->decode($self->response); 39 40 $out->{genPasswd}; 41 } 42 43 1; 44 45 __END__ 46 47 =head1 NAME 48 49 Net::LDAP::Extension::SetPassword - LDAPv3 Modify Password extension object 50 51 =head1 SYNOPSIS 52 53 use Net::LDAP; 54 use Net::LDAP::Extension::SetPassword; 55 56 $ldap = Net::LDAP->new( "ldap.mydomain.eg" ); 57 58 $ldap->bind('cn=Joe User,cn=People,dc=mydomain,dc=eg", 59 password => 'oldPassword'); 60 61 $mesg = $ldap->set_password( oldpasswd => 'oldPassword' ); 62 63 die "error: ", $mesg->code(), ": ", $mesg->error() if ($mesg->code()); 64 65 print "changed your password to", $mesg->gen_password() , "\n"; 66 67 68 =head1 DESCRIPTION 69 70 C<Net::LDAP::Extension::SetPassword> implements the C<Modify Password> 71 extended LDAPv3 operation as described in RFC 3062. 72 73 It implements no object by itself but extends the L<Net::LDAP> object 74 by another method: 75 76 =head1 METHODS 77 78 =over 4 79 80 =item set_password ( OPTIONS ) 81 82 Set the password for a user. 83 84 OPTIONS is a list of key/value pairs. The following keys are recognized: 85 86 =over 4 87 88 =item user 89 90 If present, this option contains the octet string representation of the 91 user associated with the request. Depending on how users are identified 92 in the directory this string may or may not be a DN according to RFC 2253. 93 94 If this option is not present, the request acts up upon the password 95 of the user currently associated with the LDAP session. 96 97 =item oldpasswd 98 99 This option, if present, must contain the current password of the user 100 for whom this operation is performed. 101 102 It depends on the server's implementation in which cirumstances this 103 option is allowed to be missing. 104 105 =item newpasswd 106 107 If present, this option contains the desired password for the user for 108 whom the operation is performed. 109 110 Depending on the server's implementation this option may be required by 111 the LDAP server. 112 113 =back 114 115 116 =item gen_password ( ) 117 118 Return the password generated in the previous C<set_password()> call. 119 120 This method is a method of the L<Net::LDAP::Message> response object 121 returned in reply to C<set_password()> in case the C<set_password()> 122 call succeeded. 123 124 By this method the caller can query for the value of the password in 125 case he did not call C<set_password()> with the C<newpasswd> option. 126 127 =back 128 129 =head1 SEE ALSO 130 131 L<Net::LDAP>, 132 L<Net::LDAP::Extension> 133 134 =head1 AUTHOR 135 136 Graham Barr E<lt>gbarr@pobox.comE<gt>, 137 documentation by Peter Marschall E<lt>peter@adpm.deE<gt>. 138 139 Please report any bugs, or post any suggestions, to the perl-ldap 140 mailing list E<lt>perl-ldap@perl.orgE<gt> 141 142 =head1 COPYRIGHT 143 144 Copyright (c) 2002-2004 Graham Barr. All rights reserved. This program is 145 free software; you can redistribute it and/or modify it under the same 146 terms as Perl itself. 147 148 =cut 149
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |