orbit-basic/config/initializers/nccu_ldap_connection.rb

25 lines
707 B
Ruby
Raw Normal View History

2012-05-15 03:37:45 +00:00
#encoding: utf-8
require 'mysql2'
$nccu_ldap_connection
module NccuLdapConnection
BASE = 'ou=People,dc=nccu,dc=edu,dc=tw'
@ldap_host = {
:host => '127.0.0.1', #140.119.166.23 or 127.0.0.1
:port => 8001, #389 or 8001
# :filter => "(uid=#{login_uid})",
# :base => "ou=People,dc=nccu,dc=edu,dc=tw",
:authenticate_info => "cn=uccn,ou=profile,dc=nccu,dc=edu,dc=tw",
:authenticate_pwd => "nccu2ucc"
}
def self.establish
$nccu_ldap_connection = Net::LDAP.new
$nccu_ldap_connection.port = @ldap_host[:port]
$nccu_ldap_connection.host = @ldap_host[:host]
$nccu_ldap_connection.authenticate(@ldap_host[:authenticate_info],@ldap_host[:authenticate_pwd])
end
end