Catch a case where the LDAP object is defined, but in a state that

schema/root_dse are not obtainable.  Add the connected server to
'id/whoami' output.

FossilOrigin-Name: c10f105d78e9063d679b2b052d2037b9fc1fca6c80004aacf00054c6af7a14a3
This commit is contained in:
mahlon@laika.com 2013-05-03 17:58:02 +00:00
parent 6b7777f51c
commit 7402148c97

View file

@ -471,7 +471,8 @@ sub init
}; };
# gather metadata from the LDAP server # gather metadata from the LDAP server
$self->{'root_dse'} = $self->ldap->root_dse(); $self->{'root_dse'} = $self->ldap->root_dse() or
die "Unable to retrieve LDAP server information. (Doublecheck connection arguments.)\n";
$self->{'schema'} = $self->ldap->schema(); $self->{'schema'} = $self->ldap->schema();
# get an initial list of all objectClasses # get an initial list of all objectClasses
@ -574,15 +575,20 @@ You may try connecting insecurely, or install the module and try again.\n} if $@
} }
my $err = $rv->error(); my $err = $rv->error();
$self->debug(
"Bind as " .
( $conf->{'binddn'} ? $conf->{'binddn'} : 'anonymous' ) .
" to " . $conf->{'server'} . ": $err\n"
);
if ( $rv->code() ) { if ( $rv->code() ) {
$err .= " (try the --tls flag?)" if $err =~ /confidentiality required/i; $err .= " (try the --tls flag?)" if $err =~ /confidentiality required/i;
die "LDAP bind error: $err\n"; die "LDAP bind error: $err\n";
} }
# offer to cache authentication info # Offer to cache authentication info.
# if we enter this conditional, we have successfully # If we enter this conditional, we have successfully authed with the server
# authed with the server (non anonymous), and # (non anonymous), and we haven't cached anything in the past.
# we haven't cached anything in the past.
# #
if ( $conf->{'binddn'} && ! -e $conf->{'configfile'} ) { if ( $conf->{'binddn'} && ! -e $conf->{'configfile'} ) {
print "Would you like to cache your connection information? [Yn]: "; print "Would you like to cache your connection information? [Yn]: ";
@ -2038,8 +2044,8 @@ sub run_pwd
sub run_whoami sub run_whoami
{ {
my $self = shift; my $self = shift;
print $conf->{'binddn'} || 'anonymous bind'; my $msg = ( $conf->{'binddn'} || 'anonymous bind' ) . ' (' . $conf->{'server'} . ')';
print "\n"; print "$msg\n";
return; return;
} }