Hello,

Thus far had good luck with perldap. Able to search directory, change attributes and objectclasses etc. The only problem is now I need to remove an attribute, but the remove function is not working. There are no errors, but when I check the directory no changes have been made. I am on Iplanet directory server 5.1sp2 and running the latest version of perldap. Here is some simple code I am testing with:

use Mozilla::LDAP::Conn;
use Mozilla::LDAP::Utils;

$server = $ARGV[0];
$port   = getservbyname("ldap","tcp") || "389";
$basedn = "o=isp";
$scope  = "sub";
$rootdn = "";
$pw     = "";

# non-anonymous bind
$c = new Mozilla::LDAP::Conn($server,$port,$rootdn,$pw);
die "Unable to bind to $server\n" unless $c;

# notice that we ask for the least amount of info
# possible for a speedy search
$entry = $c->search($basedn,$scope,"(mgrMailList=false)",1,'');
die "Error in search:". $c->getErrorString()."\n" if $c->getErrorCode(  );

if ($entry){
    while($entry){
        #$entry->removeValue("mgrMailList","false");
        $entry->remove("mgrMailList");
        $c->update($entry);
        die "Error in update:" . $c->getErrorString(  ) . "\n"
          if $c->getErrorCode(  );
        $entry = $c->nextEntry(  );
    };
}
$c->close(  );
 

$server = $ARGV[0];
$port   = getservbyname("ldap","tcp") || "389";
$basedn = "o=isp";
$scope  = "sub";
$rootdn = "cn=Directory Manager";
$pw     = "so50admin";

# non-anonymous bind
$c = new Mozilla::LDAP::Conn($server,$port,$rootdn,$pw);
die "Unable to bind to $server\n" unless $c;

# notice that we ask for the least amount of info
# possible for a speedy search
$entry = $c->search($basedn,$scope,"(mgrMailList=false)",1,'');
die "Error in search:". $c->getErrorString()."\n" if $c->getErrorCode(  );

if ($entry){
    while($entry){
        #$entry->removeValue("mgrMailList","false");
 $entry->remove("mgrMailList");
        #$entry->addValue("l","Indiana");
        $c->update($entry);
        die "Error in update:" . $c->getErrorString(  ) . "\n"
          if $c->getErrorCode(  );
        $entry = $c->nextEntry(  );
    };
}
$c->close(  );
 

thanks.
 

Reply via email to