Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created December 7, 2015 10:59
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 anonymous/903ad3e4d2f6cd9a73bb to your computer and use it in GitHub Desktop.
Save anonymous/903ad3e4d2f6cd9a73bb to your computer and use it in GitHub Desktop.
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