use Net::LDAP::Util qw(ldap_error_text ldap_error_name) ; my $msg ; # you will need it several times $msg = $ldap->bind(%your_bind_params) ; if ($msg->is_error) { my $code = $msg->code ; die join "\n",ldap_error_name($code), ldap_error_text($code) ; }