use Net::LDAP::Util qw(ldap_error_text); my $result = $ldap->bind(); if ($result->code) { die "An error occurred binding to the LDAP server: " .ldap_error_text($result->code)."\n"; }