Novell is now a part of Micro Focus

Sample Code - Moving/Renaming Objects in eDirectory using LDAP and Perl

Novell Cool Solutions: Feature

Digg This - Slashdot This

Posted: 10 Aug 2005

Note: You will need to replace the generic IP address in the sample with a working IP address.

You can also find this sample code at:

Sample Code


use Net::LDAP;
use Net::LDAP::LDIF;
use File::Path qw(rmtree);
use File::Basename qw(basename);

print "Content-type: text/html\n\n";

$HOST = '137.x.x.x';
$PORT = 389;
$PASSWD   = 'novell';
$BASEDN   = "o=novell";
$ADMIN= "cn=admin,o=novell";

#connect to the server
until($ldap = Net::LDAP->new($HOST, port => $PORT)) {
  die "Can not connect to ldap://$HOST:$PORT/" if ++$count > 10;
  sleep 1;

$r = $ldap->bind($ADMIN, password => $PASSWD, version=>3);
die $r->error if $r->code;

$r = $ldap->moddn("cn=pjones,ou=users,o=novell", 
					newrdn 		=>	"cn=admin",
					newsuperior	=>	"ou=admins,o=novell");
die $r->error if $r->code;

$r = $ldap->search(	base 	=> 	$BASEDN,
					scope	=>	'sub',
					filter 	=> 	$searchstring,
					attrs	=>	$attnames);

foreach my $entry ($r->entries){
	print "<p><b>dn: ".$entry->dn."</b><br>";
	my @attrs = $entry->attributes;
	foreach my $attr (@attrs) {
		my @value = $entry->get_value($attr);
		foreach my $value (@value){
			print "$attr: $value <br>";
	print "</p>";

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates