# HG changeset patch # User Mahlon E. Smith # Date 1367603883 25200 # Node ID 85cc85d0c1b15673dc522a4535aed64f39b2e55e # Parent 32e313d5d2d235bfcf3a2f52e073890aaee9afdb 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. diff -r 32e313d5d2d2 -r 85cc85d0c1b1 shelldap --- a/shelldap Fri Apr 26 15:52:03 2013 -0700 +++ b/shelldap Fri May 03 10:58:03 2013 -0700 @@ -471,7 +471,8 @@ }; # 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(); # get an initial list of all objectClasses @@ -574,15 +575,20 @@ } my $err = $rv->error(); + $self->debug( + "Bind as " . + ( $conf->{'binddn'} ? $conf->{'binddn'} : 'anonymous' ) . + " to " . $conf->{'server'} . ": $err\n" + ); + if ( $rv->code() ) { $err .= " (try the --tls flag?)" if $err =~ /confidentiality required/i; die "LDAP bind error: $err\n"; } - # offer to cache authentication info - # if we enter this conditional, we have successfully - # authed with the server (non anonymous), and - # we haven't cached anything in the past. + # Offer to cache authentication info. + # If we enter this conditional, we have successfully authed with the server + # (non anonymous), and we haven't cached anything in the past. # if ( $conf->{'binddn'} && ! -e $conf->{'configfile'} ) { print "Would you like to cache your connection information? [Yn]: "; @@ -2038,8 +2044,8 @@ sub run_whoami { my $self = shift; - print $conf->{'binddn'} || 'anonymous bind'; - print "\n"; + my $msg = ( $conf->{'binddn'} || 'anonymous bind' ) . ' (' . $conf->{'server'} . ')'; + print "$msg\n"; return; }