Skip to content
Browse files

Merge pull request #2 from rporres/master

ModifyDN fixes
  • Loading branch information...
2 parents e3421af + 0072673 commit fa363a69adbc3304032ec6e30b8529fd89cefbdd @karpet committed Oct 25, 2012
Showing with 13 additions and 4 deletions.
  1. +12 −3 lib/Net/LDAP/Server/Test.pm
  2. +1 −1 t/07-error-codes.t
View
15 lib/Net/LDAP/Server/Test.pm
@@ -7,7 +7,7 @@ use IO::Select;
use IO::Socket;
use Data::Dump ();
-our $VERSION = '0.15_01';
+our $VERSION = '0.15_02';
=head1 NAME
@@ -59,7 +59,7 @@ Only one user-level method is implemented: new().
LDAP_TYPE_OR_VALUE_EXISTS
LDAP_NO_SUCH_ATTRIBUTE
);
- use Net::LDAP::Util qw(ldap_explode_dn);
+ use Net::LDAP::Util qw(ldap_explode_dn canonical_dn);
use Net::LDAP::Entry;
use Net::LDAP::Filter;
use Net::LDAP::FilterMatch;
@@ -515,12 +515,21 @@ Only one user-level method is implemented: new().
#warn "modifyDN: " . Data::Dump::dump \@_;
#warn "modifyDN: " . Data::Dump::dump($reqData);
#warn "existing: " . Data::Dump::dump( \%Data );
+ #warn "existing DNs: " . Data::Dump::dump([keys %Data]);
my $oldkey = $reqData->{entry};
my $newkey = $reqData->{newrdn};
- if ( exists $reqData->{newSuperior} ) {
+ if ( defined $reqData->{newSuperior} ) {
$newkey .= ',' . $reqData->{newSuperior};
}
+ else {
+ # As we only have the new relative DN, we still
+ # need the base for it. We'll take it from $oldkey
+ my $exploded_dn = ldap_explode_dn($oldkey, casefold => 'none');
+ shift @$exploded_dn;
+ $newkey .= ',' . canonical_dn($exploded_dn, casefold => 'none');
+ }
+
if ( !exists $Data{$oldkey} ) {
return RESULT_NO_SUCH_OBJECT;
}
View
2 t/07-error-codes.t
@@ -124,7 +124,7 @@ is( $mesg->code, LDAP_NO_SUCH_ATTRIBUTE, 'mod fails' );
# Moddn ok
$mesg = $ldap->moddn( 'msisdn=34699123456,app=test',
- newrdn => 'msisdn=34699000111' );
+ newrdn => 'msisdn=34699000111', deleteoldrdn => 1 );
is( $mesg->code, LDAP_SUCCESS, 'moddn ok' );
# Moddn on a non-existing entry should return 32

0 comments on commit fa363a6

Please sign in to comment.
Something went wrong with that request. Please try again.