15. Ruby with LDAP - libs
RFC 1823の実装 Pure Ruby. ActiveRecordのLDAP版
character 拡張ライブラリ Rails と相性がいい
抽象度が高い
ruby-ldap より10倍程 net-ldap よりも3倍程度
weak point ドキュメントが少ない
度遅い 遅い
advantage 速い! ポータビリティが高い 高度な抽象化と豊富な機能
install gem install ruby-ldap gem install net-ldap gen install activeldap
for use require “rubygems” require “rubygems” require “rubygems”
require “ldap” require “net-ldap” require “active_ldap”
16. Ruby with LDAP – ruby-ldap
ruby-ldap
RFC1823 (The LDAP Application Programming Interface)
のRuby版実装
使い方は同梱のテストが参考になる
速い!
bind
search
add
modify
C Extension
etc…
17. Ruby with LDAP – net-ldap
net-ldap
Pure Ruby な LDAP API 実装
ポータビリティに富む
RDoc のドキュメントが結構しっかりしている
bind
search
add
modify
Pure Ruby
etc…
18. Ruby with LDAP - activeldap
activeldap
ActiveRecord を参考に作られた、LDAP API
ruby-ldap や net-ldap, JNDI を内部的に利用
クラスはツリーを抽象、インスタンスはエントリを抽象
ActiveLdap::Base
find User
new (Subclass)
cn=
save
destroy
36. Code Examples – ruby-ldap (5)
Gathering Error Information
LDAP::Error
begin
@conn.delete("cn=Ruby Taro,o=RubyKaigi2010,c=jp")
rescue => e
e # => #<LDAP::ResultError: No such object>
e.message # => "No such object“
@conn.err # => 32
@conn.err2string(@conn.err) # => "No such object"
end
原則として LDAP::Error が投げられる様子
Human Readable なメッセージは LDAP::Error 自身が持っている
エラーコードが欲しい場合に #<LDAP::Conn> に問い合わせる