Ignore:
Timestamp:
05/27/09 03:45:05 (15 years ago)
Author:
nanardon
Message:
  • fix attributes assigment in AD
Location:
LATMOS-Accounts/lib/LATMOS/Accounts
Files:
2 edited

Legend:

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

    r199 r203  
    5353        homeDirectory loginShell 
    5454        uidNumber gidNumber gecos 
    55         userPassword 
    5655        shadowLastChange shadowMin shadowMax 
    5756        shadowWarning shadowInactive shadowExpire 
     
    6160        ipPhone otherTelephone department 
    6261        title modbile homePhone 
    63         memberOf 
    6462        accountExpires 
    6563        streetAddress postalCode postOfficeBox l 
     
    7169        userAccountControl 
    7270        locked 
     71        memberOf 
    7372        ), 
    7473        ($mode !~ /w/ 
     
    9089    $entry->replace('sAMAccountName', $id); 
    9190    $entry->replace(objectClass => [ qw(top person organizationalPerson user)],); 
    92     $entry->replace(userAccountControl => 66112); 
     91    # Must be 544 for creation... 
     92    $entry->replace(userAccountControl => 544); #66112); 
    9393    # This attributes cannot be set via LDAP: 
    9494    #$entry->replace(sAMAccountType => 0x30000000); 
    9595    $entry->replace(accountExpires => '9223372036854775807'); # TODO hardcoded, burk 
    9696    $entry->replace(userPrincipalName => "$id\@" . $base->ad_domain); 
     97    my %delayed; 
    9798    foreach (keys %data) { 
     99        /^(manager|memberOf)$/ and do { 
     100            $delayed{$_} = $data{$_}; 
     101            next; 
     102        }; 
    98103        $class->_populate_entry($entry, $_, $data{$_}); 
    99104    } 
    100105    my $msg = $base->ldap->add($entry); 
    101     warn $msg->error if ($msg->code); 
    102     return $msg->code ? 0 : 1; 
     106    if ($msg->code) { 
     107        warn $msg->error; 
     108        return 0; 
     109    } 
     110    my $res = $base->get_object('user', $id)->set_fields(%delayed); 
     111    return defined($res) ? 1 : 0; 
    103112} 
    104113 
     
    146155            foreach (keys %users) { 
    147156                $users{$_}{e} && $users{$_}{n} and next; 
    148                 my $user = $self->base->get_object('group', $_) or next; 
     157                my $group = $self->base->get_object('group', $_) or next; 
     158                # memberOf field is read only 
     159                # so we modify the peer entry into peer object 
    149160                if ($users{$_}{e}) { 
    150                     $self->{entry}->del(memberOf => $user->get_field('dn')); 
     161                    $group->{entry}->delete(member => $self->get_field('dn')); 
    151162                } elsif ($users{$_}{n}) { 
    152                     $self->{entry}->add(memberOf => $user->get_field('dn')); 
     163                    $group->{entry}->add(member => $self->get_field('dn')); 
    153164                } # else {} # can't happen 
    154                 my $mesg = $self->{entry}->update($self->base->ldap); 
     165                my $mesg = $group->{entry}->update($self->base->ldap); 
     166                if ($mesg->code) { 
     167                    warn $mesg->error; 
     168                    return; 
     169                } 
    155170            } 
    156171            next; 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Utils.pm

    r175 r203  
    1515sub to_ascii { 
    1616    my ($text) = @_; 
     17    return $text unless(defined($text)); 
    1718    utf8::decode($text) unless(utf8::is_utf8($text)); 
    1819    $text =~ tr/uàâÀÂÄÀçéÚêëÉÈÊËïîÏÎöÎÖÔÌûÛÜ/uaaaAAAceeeeEEEEiiIIooOOuuUU/; 
Note: See TracChangeset for help on using the changeset viewer.