For Programmers: Free Programming Magazines  


Home > Archive > LDAP > August 2005 > Setting AD password using LDAP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Setting AD password using LDAP
bagray

2005-08-04, 12:43 pm

I am trying to reset an AD password via LDAP. The documentation reads:
The syntax of the unicodePwd attribute is octet-string; however, the directory service expects that the octet-string will contain a UNICODE string (as the name of the attribute indicates). This means that any values for this attribute passed in LDAP must be UNICODE strings that are BER-encoded (Basic Encoding Rules) as an octet-string. In addition, the UNICODE string must begin and end in quotes that are not part of the desired password.

my code:

use Net::LDAP;
use Unicode::String qw(utf8);
use Convert::BER;

my $host = 'somehost';
my $admin = 'someadmin';
my $pword = 'password';

my $user = 'CN=someuser,CN=Users,DC=Somewhere,DC=co
m';
my $newpw = utf8('"newpword"');

my $ber = new Convert::BER;

$ber->encode(UTF8String => $newpw) or die;

$ldap = Net::LDAP->new($host);
$ldap->start_tls();
$rc = $ldap->bind($admin, password => $pword);
print "bind error " . $rc->error . "\n" if $rc->code;


$m = $ldap->modify( $user, replace => {unicodePwd => $ber});
print $m->error ."\n" if $m->code;
$ldap->unbind();


errors with:
0000207E: AtrErr: DSID-031905F5, #1:
0: 0000207E: DSID-031905F5, problem 1006 (ATT_OR_VALUE_EXISTS), data 0, Att 9005a (unicodePwd)

I can set other attributes (non BER encoded UNICODE) so I am sure it is my encoding. Any thoughts would be great.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com