|
|
@ -59,8 +59,8 @@ sub create { |
|
|
|
my $result = $conn->add($dn, attr => [ |
|
|
|
my $result = $conn->add($dn, attr => [ |
|
|
|
objectClass => ['inetOrgPerson'], |
|
|
|
objectClass => ['inetOrgPerson'], |
|
|
|
uid => $uid, |
|
|
|
uid => $uid, |
|
|
|
sn => 'just', |
|
|
|
cn => 'just', |
|
|
|
cn => 'created', |
|
|
|
sn => 'created', |
|
|
|
]); |
|
|
|
]); |
|
|
|
$conn->unbind; |
|
|
|
$conn->unbind; |
|
|
|
return $result->error if ($result->code); |
|
|
|
return $result->error if ($result->code); |
|
|
@ -90,9 +90,11 @@ sub get { |
|
|
|
my $data = {}; |
|
|
|
my $data = {}; |
|
|
|
foreach my $attr ($entry->attributes) { |
|
|
|
foreach my $attr ($entry->attributes) { |
|
|
|
$data->{$attr} = $entry->get_value($attr); |
|
|
|
$data->{$attr} = $entry->get_value($attr); |
|
|
|
|
|
|
|
utf8::decode($data->{$attr}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
delete $data->{userPassword}; |
|
|
|
delete $data->{userPassword}; |
|
|
|
|
|
|
|
delete $data->{objectClass}; |
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -109,11 +111,13 @@ sub update { |
|
|
|
unless ($data); |
|
|
|
unless ($data); |
|
|
|
|
|
|
|
|
|
|
|
my $dn = sprintf "uid=%s,%s", $uid, $self->{userbase}; |
|
|
|
my $dn = sprintf "uid=%s,%s", $uid, $self->{userbase}; |
|
|
|
|
|
|
|
my %upd = (); |
|
|
|
while (my ($key, $value) = each(%$attrs)) { |
|
|
|
while (my ($key, $value) = each(%$attrs)) { |
|
|
|
next if ($value and exists $data->{$key}); |
|
|
|
next unless ($value and exists $data->{$key}); |
|
|
|
delete $attrs->{$key}; |
|
|
|
next if ($key eq 'uid'); # rename protection |
|
|
|
|
|
|
|
$upd{$key} = $value; |
|
|
|
} |
|
|
|
} |
|
|
|
my $result = $conn->modify($dn, replace => $attrs); |
|
|
|
my $result = $conn->modify($dn, replace => \%upd); |
|
|
|
$conn->unbind; |
|
|
|
$conn->unbind; |
|
|
|
|
|
|
|
|
|
|
|
return $result->error if ($result->code); |
|
|
|
return $result->error if ($result->code); |
|
|
|