Skip to content

Instantly share code, notes, and snippets.

@bodgix
Last active December 29, 2015 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bodgix/0dfa6308d9747248b5ef to your computer and use it in GitHub Desktop.
Save bodgix/0dfa6308d9747248b5ef to your computer and use it in GitHub Desktop.
begin # start catching exceptions here
Net::LDAP.open(
:host => host,
:port => port,
:auth => {
:method => :simple,
:username => CONFIG['repldn'],
:password => CONFIG['replpw']
}
) do |ldap|
unless ldap.bind
LOG.warn "connected to #{host}:#{port} but bind failed."
exit 3
end
# Bind was succesful, let's use the server from now on.
# I want to end the exception handling block, but I'm in a nested block now
# How to do that without ending the block to whom ldap was yielded?
ldap.search()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment