From: Edgington, J. <je...@um...> - 2002-07-01 10:27:56
|
This is part of a perl module that we wrote... if you're interested in the whole thing, let me know. # Begin-Doc # Name: _MakeUnicode # Type: method # Description: simple ascii to unicode/2bytechar conversion # Syntax: $unicode =3D $ads->_MakeUnicode($string); # Access: internal # End-Doc sub _MakeUnicode { my $self =3D shift; my ($string, $plainstring, $chr); $string =3D shift; # print "string $string\n"; $plainstring =3D "\"$string\"";=09 #--- # simple string=3D>unicode conversion # my @tmp =3D (); foreach $chr ( split('', $plainstring) ) { push(@tmp, $chr); push(@tmp, chr(0)); } $unistring =3D join("",@tmp); # #--- return $unistring; print "$unistring\n"; } # Name: SetPassword # Type: method # Description: Resets the ADS Password for a userid # Syntax: $setpw =3D $ex->SetPassword( # userid =3D> "miner", # password =3D> "engineer"); # Returns: undef is successful otherwise the error # End-Doc sub SetPassword { my $self =3D shift; my (%info) =3D @_; my ($userid,$password,$upn,$dn,$res); $userid =3D $info{userid} || return "need a userid\n"; $password =3D $info{password} || return "need new password\n"; $dn =3D $self->_GetDN($userid); if ( ! $dn ) { $self->debug && print "userid not found\n"; $ErrorMsg =3D "Userid '$userid' not found. Password not set.\n"; return $ErrorMsg; } $self->debug && print "dn is $dn\n"; $self->debug && print "userid is $userid\n"; $self->debug && print "password is $password\n"; #--- # simple string=3D>unicode conversion #--- $pw =3D $self->_MakeUnicode($password);=09 $res =3D $self->{ldap}->modify (=09 dn =3D> $dn, changes =3D> [ replace =3D> [=20 "unicodePwd" =3D> $pw, ] ] ); if ($res->code) { $ErrorMsg =3D "password set failed: " . $res->error; return $ErrorMsg; } return undef; } -----Original Message----- From: Graham Barr [mailto:gb...@po...]=20 Sent: Monday, July 01, 2002 4:17 AM To: LDAP Mailing List Cc: Emilio Recio Subject: [Fwd] ADS Password Change ----- Forwarded message from Emilio Recio <elm...@je...> ----- Date: Thu, 27 Jun 2002 14:44:20 -0400 To: gb...@po... From: Emilio Recio <elm...@je...> Subject: ADS Password Change We are trying to change the ADS password via Net::LDAPS and we keep=20 getting that constraint error, even after using the 'encoding' scheme=20 you recommended (after binding using Net::LDAPS as administrator): my $tmpVar =3D pack "v*", unpack "C*", qq("secret"); $ldap-modify ("cn=3DJhonny = Blaze,cn=3DUsers,dc=3Dsw,dc=3Djefferson,dc=3Dedu", changes =3D> [ delete =3D> [ 'unicodePwd' =3D> [] ], add =3D> [ 'unicodePwd' =3D> $tmpVar ] ] ); Can you shed some light on this situation? I would greatly appreciate it. -Elmo ----- End forwarded message ----- ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf |