Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

better code to change a password in AD ?
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','Cu@
Y4PC!');
die $msg->error if $msg->code;

Report this thread to moderator Post Follow-up to this message
Old Post
Marc Chantreux
04-12-05 09:02 PM


Re: better code to change a password in AD ?
Hi,

On Tuesday 12 April 2005 18:09, Marc Chantreux wrote:
> 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") )
> 	}
>     );
>
> }

I may be mistaken, but I think Encode is only available with Perl 5.8.
In addition to that I think that your function only works with passwords in
the Latin1 (aka ISO-8859-1) character set.

The solution in the FAQ works for earlier versions of Perl and and passwords
in other character sets too (provided the Unicode::Map8 character map is
created propely).

Peter
--
Peter Marschall
eMail: peter@adpm.de

Report this thread to moderator Post Follow-up to this message
Old Post
Peter Marschall
04-19-05 09:05 PM


Re: better code to change a password in AD ?
le 19/04/2005,
Peter Marschall nous écrivait :
> I may be mistaken, but I think Encode is only available with Perl 5.8.

right !

> In addition to that I think that your function only works with passwords i
n
> the Latin1 (aka ISO-8859-1) character set.

I may be mistaken, but I think it works for every encoding.

thanks and regards
mc

Report this thread to moderator Post Follow-up to this message
Old Post
Marc Chantreux
04-25-05 09:03 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

LDAP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:05 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.