Hi,
I'm just learning perl-ldap now and must say I find this package to be awesome!.
Anyhow, I got two problems. Both are related to the fact that I got an old ldap
directory that needs some careful maintenance. Right now, I want to remove a
couple of objectclasses and remove the attributes that go with them.
So here's my first question: How can I check usong the schema class that an
attribute is not in use by another objectclass the entry contains?
Next, I'm trying to write a simple delete-objectclass function, I get the error :
Can't call method "modify" on an undefined value at
/usr/lib/perl5/site_perl/5.6.1/Net/LDAP/Entry.pm line 212.
when I execute it. Heres the function:
sub ldap_remove_objectclass ($$) {
my ($objectclass,$searchdn,$ldap) = @_;
my (@delete);
my $mesg = $ldap->search (base => "$searchdn",
filter => "objectClass=$objectclass" );
my $schema = $ldap->schema();
my @attributes = $schema->attributes($objectclass);
foreach my $attr (@attributes) {
print "Attribute: ". $attr;
}
my $max = $mesg->count();
for ($i=0;$i < $max;$i++) {
my @entryatt;
my $entry = $mesg->entry($i);
print "Doing entry " . $entry->dn(). " \n";
$entry->delete($objectclass);
foreach my $attr (@attributes) {
if ($entry->exists($attr)) {
print "Deleting $attr with value: " . $entry->get_value($attr) .
" \n";
# $entryatt = (@entryatt,$attr);
@delete = (@delete,$attr=>'');
$entry->replace(@delete);
}
$entry->update();
}
}
I've set the version to 3 in the bind, but this doesn't help. Does anyone know
what I'm doing wrong?
Yours,
Tarjei Huse
Mob: 920 63 413
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
|