Add LDAP v3 protocol support
Signed-off-by: Sergey Bogdanov <sergey.bogdanov@oktetlabs.ru>master
parent
a8df72ef9e
commit
228a170065
|
@ -17,7 +17,11 @@ class DiaryEnv
|
|||
DB_DATABASE = "diary"
|
||||
|
||||
LDAP_HOST = 'ldap.example.com'
|
||||
LDAP_PORT = 389
|
||||
LDAP_ROOT = "ou=People,dc=example,dc=com"
|
||||
LDAP_VER = 3
|
||||
LDAP_BIND_DN = ""
|
||||
LDAP_BIND_PW = ""
|
||||
|
||||
HOME_ORGANIZATION = "Example ORG"
|
||||
HOME_OU = "Employees"
|
||||
|
@ -31,8 +35,12 @@ class DiaryEnv
|
|||
def initialize
|
||||
@confirmation = Array.new
|
||||
Person.setup(:host => LDAP_HOST,
|
||||
:root => LDAP_ROOT,
|
||||
:key => "uid")
|
||||
:port => LDAP_PORT,
|
||||
:root => LDAP_ROOT,
|
||||
:ver => LDAP_VER,
|
||||
:binddn => LDAP_BIND_DN,
|
||||
:bindpw => LDAP_BIND_PW,
|
||||
:key => "uid")
|
||||
Person.set_local(HOME_ORGANIZATION, HOME_OU)
|
||||
DataMapper.setup(:adapter => "Mysql",
|
||||
:database => DB_DATABASE,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# Class LdapRecord for Diary Management Application.
|
||||
#
|
||||
|
||||
require 'ldap_cache'
|
||||
require_relative 'ldap_cache'
|
||||
require 'net/smtp'
|
||||
|
||||
class LdapRecord
|
||||
|
@ -17,6 +17,12 @@ class LdapRecord
|
|||
raise "Invalid parameters" unless args.is_a? Hash
|
||||
raise "LDAP server is not specified" unless args[:host]
|
||||
@@ldap = LDAP::Conn.new(args[:host], args[:port] || LDAP::LDAP_PORT)
|
||||
if args[:ver] == 3
|
||||
@@ldap.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
|
||||
end
|
||||
if args[:binddn] != ""
|
||||
@@ldap.bind(args[:binddn], args[:bindpw])
|
||||
end
|
||||
#@@ldap.bind # Bind is optional for LDAPv3
|
||||
|
||||
raise "LDAP tree root is not specified" unless args[:root]
|
||||
|
|
Loading…
Reference in New Issue