#! /usr/bin/perl

use warnings;
use strict;
use Net::LDAP qw( LDAP_ALREADY_EXISTS );
sub add_entry($$) {
    my ( $ldap, $entry ) = @_;
    my $mesg = $entry->update( $ldap );
    if ( $mesg->code == LDAP_ALREADY_EXISTS ) {
        warn "The entry ", $entry->dn, " already is in the directory\n";
    } elsif ( $mesg->code ) {
        die "cannot add entry: ", $mesg->error;
    }
}
