I'm using Net::LDAP and Auth::SASL in a program. Not every person who
will use this command will have GSSAPI (krb5) credentials. If not, I'd
like the program to fall back to binding to LDAP using a password. Is
there anyway to determine if someone has the necessary GSSAPI
credentials before calling
$ldap->bind(sasl => $sasl); (line 107)
? I figured if this failed I can check for errors with sasl->error(),
but when it fails, the whole program exits. Here's the code in question:
my $dse = $ldap->root_dse();
if ($dse->supported_sasl_mechanism('GSSAPI')) {
# If SASL GSSAPI is supported, connect using it.
my $sasl = Authen::SASL->new( mechanism => 'GSSAPI' );
$ldap->bind(sasl => $sasl);
$sasl_error = $sasl->error();
if ($sasl_error) {
print "A sasl error was encountered: $sasl_error\n";
}
}
And here's the error
Local error at ./sns_chsh.pl line 107.
--
Prentice Bisbal
Linux Software Support Specialist/System Administrator
School of Natural Sciences
Institute for Advanced Study
Princeton, NJ