[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-ldap-dev
Subject:    Re: changetype modrdn
From:       Peter Marschall <peter () adpm ! de>
Date:       2007-05-13 15:16:17
Message-ID: 200705131716.17981.peter () adpm ! de
[Download RAW message or body]

Hi,

On Tuesday, 24. April 2007 10:12, Rudy Gevaert wrote:
> Hi,
>
> I'm trying to change the dn of an ldap entry:
>
> my $result = $ldaps->search( base   => "${base}",
>                               filter => "(umMailUid=${old_mailUid})",
>
>
> my $entry = $result->pop_entry;
> $entry->changetype('modrdn');
> $entry->add(newrdn => "umMailUid=${new_mailUid}");
> $result = $entry->update($ldaps);
>
> But I get this error:
> [Ldap] No DN specified

You get this error because you did not specify the value for 
deleteoldrdn, which AFAICT is required for the moddn or modrdn
operations.

Since you did not specify it, I guess you wanted it to be 0.
Inserting 
  $entry->add(deleteoldrdn => 0)
before the line doing the update does the trick.

I have had a look at the code and found a little inconsistency
with the current version.
While  $ldap->update()  works without requiring deleteoldrnd
(it assumes it to be 0 in this case),  $entry->update()
currently fails horribly.

The reason for this is that  $entry->update()  requests the
attributes in list context in order to build a list that
eventually becomes a hash in the called functions.
When the attribute does not exist, an empty list is returned,
making the hash-detection get mis-aligned and thus crete
the error above.

A fix has just been committed to SVN.

Regards
Peter

-- 
Peter Marschall
peter@adpm.de
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic