From: Graham B. <gb...@po...> - 2002-09-13 07:35:11
|
The entry need to know the LDAP server on which todo the updates, Try changing $entry->update() to be $entry->update($ldap); Graham. On Fri, Sep 13, 2002 at 09:23:17AM +0200, Tarjei Huse wrote: > Hi, is this a stupid misstake that I should understand since noone has replied to > this, or would someone be so kind as to point me to another list where I might > get help? > > I don't want to be rude or anything, but the problem leaves me completly in the > dark, and I've tried most other ways to find out where the problem is. If someone > has some working code that deletes a single objectclass from an entry, that would > help. > cheers, > Tarjei > > > > 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/ > > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by: OSDN - Tired of that same old > > cell phone? Get a new here for FREE! > > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 > > > > > Mob: 920 63 413 > > > ------------------------------------------------- > This mail sent through IMP: http://horde.org/imp/ > > > ----- End forwarded message ----- > > > Mob: 920 63 413 > > > ------------------------------------------------- > This mail sent through IMP: http://horde.org/imp/ > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf |