-
-
Save anonymous/903ad3e4d2f6cd9a73bb to your computer and use it in GitHub Desktop.
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
require 'net-ldap' | |
ldap = Net::LDAP.new | |
ldap.host = "ad-dns.test.com" | |
ldap.port = 389 | |
ldap.auth 'CN=LDAP Query,OU=User Accounts,DC=TEST,DC=COM', 'Password@123' | |
user, psw = "vikas.kumar@TEST.COM", "Password@123" | |
result = ldap.bind_as( | |
:base => "OU=User Accounts,DC=TEST,DC=COM", | |
:filter => "(mail=#{user})", | |
:password => psw | |
) | |
if result | |
puts "Authenticated #{result.first.dn}" | |
else | |
puts "Authentication FAILED." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment