Changeset 189


Ignore:
Timestamp:
05/26/09 16:28:27 (15 years ago)
Author:
nanardon
Message:
  • add set_password() to AD
Location:
LATMOS-Accounts
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad.pm

    r181 r189  
    1111use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED );  
    1212use Net::LDAP::Util     qw( escape_filter_value ); 
     13use Unicode::Map8; 
     14use Unicode::String qw(utf16); 
    1315 
    1416our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 
     
    109111    } 
    110112 
    111     $ldap or return; # connot connect to any ldap :\ 
     113    $ldap or do { 
     114        warn "Cannot to ldap server"; 
     115        return; # connot connect to any ldap :\ 
     116    }; 
    112117 
    113118    my $login = $self->{_login}; 
     
    145150        sort { $a->priority <=> $b->priority || $a->weight <=> $b->weight } 
    146151        grep { $_->type eq 'SRV' } $query->answer) { 
    147         push(@urllist, $self->_ldap_url($rr->target, $rr->port)); 
     152        push(@urllist, $self->_ldap_url($rr->target)); # $rr->port)); don't use port 
    148153    } 
    149154 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/User.pm

    r188 r189  
    77use base qw(LATMOS::Accounts::Bases::Ad::objects); 
    88use Net::LDAP; 
     9use Net::LDAPS; 
    910use Net::LDAP::Entry; 
    1011use Net::LDAP::Control::Paged; 
     
    7071        userAccountControl 
    7172        locked 
     73        dSHeuristics 
    7274        ), 
    7375        ($mode !~ /w/ 
     
    121123    $field eq 'directReports' and do { 
    122124        my $res = $self->SUPER::get_field($field); 
    123         return [ map { $self->base->get_value('cn') } @{ ref $res ? $res : [ $res ] } ]; 
     125        return; 
     126        #return [ map { $self->base->get_value('cn') } @{ ref $res ? $res : [ $res ] } ]; 
    124127    }; 
    125128    $field eq 'manager' and do { 
    126         my $entry = $self->SUPER::get_field($field) or return; 
    127         return $entry->get_value('cn'); 
     129        #my $entry = $self->SUPER::get_field($field) or return; 
     130        #return $entry->get_value('cn'); 
    128131    }; 
    129132    $self->SUPER::get_field($field); 
     
    170173} 
    171174 
     175sub set_password { 
     176    my ($self, $clear_pass) = @_; 
     177    my $charmap = Unicode::Map8->new('latin1')  or  die; 
     178    my $newUniPW = $charmap->tou('"'.$clear_pass.'"')->byteswap()->utf16(); 
     179    my $mesg = $self->base->ldap->modify( 
     180        $self->get_c_field('dn'), 
     181        changes => [ 
     182        #replace => [ userPassword => $clear_pass ], 
     183        replace => [ unicodePwd => $newUniPW ], 
     184 
     185        ] 
     186    ); 
     187    if ($mesg->code && $mesg->code != 82) { 
     188        warn $mesg->error; 
     189        return; 
     190    } else { return 1 } 
     191} 
     192 
    1721931; 
    173194 
Note: See TracChangeset for help on using the changeset viewer.