require 'net/ldap'
class LDAPConn
HOST = "ldap.yourcorp.dev"
# 636 for ssl binding
PORT = "636"
USERNAME = "TestLDAP"
PASSWORD = "abcd1234"
TREEBASE = "OU=UserAccts,DC=yourdomain,DC=com"
def LDAPConn.getLDAP
ldap = Net::LDAP.new(:host => HOST,
:port => PORT,
:auth => {
:method => :simple,
:username => USERNAME,
:password => PASSWORD
},
:encryption => :simple_tls)
return ldap
end
def LDAPConn.validateLogin(email, password)
ldap = LDAPConn.getLDAP
filter = Net::LDAP::Filter.eq("mail", email)
result = ldap.bind_as(:base => TREEBASE, :filter => filter, :password => password)
return result
end
end
Sunday, September 15, 2013
LDAP sample in Ruby Code
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment