From: Harri C. <har...@di...> - 2002-04-17 07:46:53
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello there, can anybody help me? I am working on a perl script to read LDIF ( rc2849 ) with the help of Net::LDAP::LDIF. The entries created I want to be written with the help of Net::LDAP or Net::LDAP::Entry into the slapd of openldap v2.1. All works well with $ldap->add($entry) and $ldap->delete($entry) but whatever I try, I can`t make modify or moddn work. Could anybody look through my code and tell me what I am doing wrong? sub ldif2master { use Net::LDAP; use Net::LDAP::LDIF; my ( $ldifdata ) = @_; my ( $ldap, $ldif, $entry, $changetype, $message, $msg, $modrdn ); $ldap = Net::LDAP->new("$Parameter::MASTER_HOST", port => "$Parameter::MASTER_PORT", version => $Parameter::VERSION ) or die "\n\n\tldif2master: Either Host not". " allive or\n\taddress might be wrong.". " Maybe use the wrong Protokoll-Version". " message: $@\n\n"; $ldap->bind ( "$Parameter::MANAGER_DN", password => "$Parameter::MANAGER_PASSWD" ) or die "$@"; $ldif = Net::LDAP::LDIF->new("./LOG/$ldifdata", "r", onerror=>'undef'); while( not $ldif->eof() ) { $entry = $ldif->read_entry(); if ( $ldif->error() ) { print "ERROR MSG: ",$ldif->error(),"\n"; print "ERROR LINES:\n",$ldif->error_lines(),"\n"; print "\nERROR, LDIF-FEHLER\n\n"; } else { my $changetype = $entry->changetype; if ( $changetype eq "add" ) { $message = $ldap->add($entry); } if ( $changetype eq "delete" ) { $message = $ldap->delete($entry); } # everything works to this point: if ( $changetype eq "modify" ) { $message = $ldap->modify($entry); } if ( $changetype eq "moddn" ) { $message = $ldap->moddn($entry); } if ( $changetype eq "modrdn" ) { $message = $ldap->moddn($entry); } # this won`t work if ( $message->code ) { #do something } } } $ldif->done(); $ldap->unbind; } modify will generate no mistake at all but no Modifikation takes place. for moddn I also tried the code below but either the module does not find a DN or it misses NewRDN. my @entrylines = split("\n",$ldif->current_lines()); if ( $changetype eq "moddn" ) { foreach my $line ( @entrylines ) { if ($line =~ /^dn\s*\:\s*(.*)$/i) { #$modrdn = $line; $modrdn = sprintf("'%s'",$1); #$dn = $1; #print "\n$modrdn\n"; next; } if ($line =~ /^newrdn\s*\:\s*(.*)$/i) { $modrdn .= sprintf(", newrdn => '%s'",$1); print "\n$modrdn\n"; next; } if ($line =~ /^deleteoldrdn\s*\:\s*(.*)$/i) { #$modrdn .= ", deleteoldrdn => $1"; #print "\n$modrdn\n"; next; } if ($line =~ /^newsuperior\s*\:\s*(.*)$/i) { $modrdn .= ", newsuperior => \"$1\""; print "\n$modrdn\n"; next; } } $message = $ldap->moddn( $modrdn ); } Please help me if you can. Thank you very much for your effort. Best regards Harri Czesla Harri Czesla ~ ~ Harri Czesla DFN Directory Services + + tel.: +49 (0)7071 29-70285 ZDV Univ. Tuebingen -- / fax: +49 (0)7071 29-5114 D-72074 Tuebingen || har...@di... Germany || http://www.directory.dfn.de - --------------------------^^---------------------------------- This article has been digitally signed, using GnuPG. Get my public key at http://www.keyserver.net/en/ for validating this signature. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Weitere Infos: siehe http://www.gnupg.org iD8DBQE8vShkVW8ZQyo1bk4RAukpAJ4uJCDO4ZYLVGXqwcC/Zsj9xN1uZACfY+xw mrwwIOWptHGp825sm5caSN8= =t0nZ -----END PGP SIGNATURE----- |