use strict;
use warnings;
+use Encode (qw(encode decode));
+
use LiCoM::Config (qw(get_config));
use LiCoM::Connection (qw($Ldap));
use Net::LDAP;
my $entry = shift;
my $obj = {};
- $obj->{'name'} = $entry->get_value ('cn', asref => 0);
- $obj->{'description'} = $entry->get_value ('description', asref => 0);
- $obj->{'members'} = [map { m/cn=([^,]+)/i; $1; } ($entry->get_value ('member', asref => 0))];
+ $obj->{'name'} = decode ('utf-8', $entry->get_value ('cn', asref => 0));
+ $obj->{'description'} = decode ('utf-8', $entry->get_value ('description', asref => 0));
+ $obj->{'members'} = [map { m/cn=([^,]+)/i; decode ('utf-8', $1); } ($entry->get_value ('member', asref => 0))];
$obj->{'ldap'} = $entry;
return (bless ($obj, $pkg));
my $entry = Net::LDAP::Entry->new ();
- $entry->add (objectClass => [qw(top groupOfNames)]);
- $entry->add (ou => $ou);
- $entry->add (cn => $name);
- $entry->add (member => [map { _cn_to_dn ($_) } (@members)]);
- $entry->add (description => $desc) if ($desc);
- $entry->dn ($dn);
+ $entry->add (objectClass => [map { encode ('UTF-8', $_) } (qw(top groupOfNames))]);
+ $entry->add (ou => encode ('UTF-8', $ou));
+ $entry->add (cn => encode ('UTF-8', $name));
+ $entry->add (member => [map { encode ('UTF-8', _cn_to_dn ($_)) } (@members)]);
+ $entry->add (description => encode ('UTF-8', $desc)) if ($desc);
+ $entry->dn (encode ('UTF-8', $dn));
$entry->changetype ('add');
my $mesg = $entry->update ($Ldap);
my $entry = $obj->{'ldap'};
$obj->{'name'} = shift;
+ # FIXME
$entry->changetype ('modify');
$entry->replace (cn => $obj->{'name'});
$entry->update ($Ldap);
$obj->{'description'} = shift;
$entry->changetype ('modify');
- $entry->replace (description => [$obj->{'description'}]);
+ $entry->replace (description => [encode ('UTF-8', $obj->{'description'})]);
$entry->update ($Ldap);
}
my $entry = $obj->{'ldap'};
my @tmp = map { _cn_to_dn ($_); } (@{$obj->{'members'}});
+ $_ = encode ('UTF-8', $_) for (@tmp);
+
$entry->changetype ('modify');
$entry->replace (member => \@tmp);
$entry->update ($Ldap);