Skip to content

Instantly share code, notes, and snippets.

@stefanschmidt
Last active March 1, 2019 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanschmidt/a7cc98c8cc34cb98deecff9e3fffa7d6 to your computer and use it in GitHub Desktop.
Save stefanschmidt/a7cc98c8cc34cb98deecff9e3fffa7d6 to your computer and use it in GitHub Desktop.
Authenticate via LDAP with Ruby
# Using an LDAP test server we will authenticate the user newton
# http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
# requires net-ldap gem
require 'net/ldap'
ldap = Net::LDAP.new
ldap.host = 'ldap.forumsys.com'
ldap.auth "uid=newton,dc=example,dc=com", "password"
if ldap.bind
puts 'authentication succeeded'
else
puts 'authentication failed'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment