This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/config/initializers/nccu_ldap_connection.rb

25 lines
707 B
Ruby

#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