Hi all,

The sample code that is in the FAQ to update a password in an Active
directory  needs modules that are not in the standard perl distribution.
I wrote one exemple which doesn't need those modules. Peraps you can add
it in the FAQ ?

Regards,
mc

package Net::LDAP::AD;
use strict;
use warnings;
use Encode;
use base qw(
    Net::LDAP
);


sub passwd { 

    my ( $ldap , $user , $password );

    # $ldap   : a Net::LDAPS  object 
    # SSL is *required* by Active Directory to change the password
    # $user   : DN of the user
    # $password : plaintext for the new password

    $ldap->modify(
        $user , replace => {
            unicodePwd => Encode::encode('UTF-16LE',qq("$password") )
        }
    );
    
}

package main;


my $msg;

my $ldap = Net::LDAP->new(
    'ldaps://your.directory'
) or die "$@";

$msg = $ldap->bind(
    'cn=someone who can,dc=your,dc=directory'
    , password => 'tryToGuess;-)'
);
die $msg->error if $msg->code;
$ldap->passwd('cn=someone who need a new password,dc=your,dc=directory','[EMAIL 
PROTECTED]');
die $msg->error if $msg->code;

Reply via email to