Last active
March 1, 2019 15:19
-
-
Save stefanschmidt/a7cc98c8cc34cb98deecff9e3fffa7d6 to your computer and use it in GitHub Desktop.
Authenticate via LDAP with Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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