Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical...
Transcript of Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical...
![Page 1: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/1.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
Railsで作るActive Directoryと連携した社内システム
須藤功平株式会社クリアコード
2009/12/14
![Page 2: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/2.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
話すこと
社内システム✓
Active Directory✓
ActiveLdap入門✓
Rails + ActiveLdap Tips✓
1/48
![Page 3: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/3.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
自己紹介
ActiveLdapメイン開発者✓
Rubyコミッタ(RSS)✓
札幌Ruby会議02スピーカー✓
2/48
![Page 4: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/4.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
会社
3/48
![Page 5: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/5.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
社内システム
業務を効率化顧客管理・プロジェクト管理・…✓
✓
社内環境の改善社内SNS・会議室予約・…✓
✓
社内情報と密接✓
4/48
![Page 6: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/6.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
社内情報
社員情報名前・メールアドレス・所属・…✓
✓
リソース情報会議室・サーバ・プロキシ・…✓
備品・ソフトウェア・…✓
✓
一元管理✓5/48
![Page 7: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/7.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
社内システムの実現
ネイティブアプリ→Webアプリ✓
セットアップが楽インストール不要✓
ブラウザがあれば使える✓
✓
アップデートが楽サーバ側を更新✓
✓
6/48
![Page 8: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/8.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
Webアプリ
Railsで作れる✓
問題:既存の社内システムとの連携✓
社内情報へのアクセス方法✓
✓
ActiveLdapで解決✓
7/48
![Page 9: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/9.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
豆知識
クリアコードはFirefoxのサポートサービスを
提供しています
http://www.clear-code.com/services/mozilla/menu.html
8/48
![Page 10: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/10.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
Active Directory
社内システム✓
Active Directory✓
ActiveLdap入門✓
Rails + ActiveLdap Tips✓
9/48
![Page 11: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/11.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
Active Directory
ネットワーク管理システム認証機能✓
ネットワーク資源のデータベース✓
✓
ネットワーク資源ユーザー・コンピューター・…✓
✓
社内情報を一括管理✓10/48
![Page 12: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/12.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
データベース
ツリー構造部門毎にグループ化✓
分割して管理✓
✓
参照・検索に特化✓
11/48
![Page 13: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/13.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
ツリー構造データベース
12/48
![Page 14: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/14.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
LDAP
13/48
![Page 15: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/15.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
LDAP
Lightweight軽量✓
✓
Directoryネットワーク資源のデータベース✓
✓
Access✓
Protocol✓14/48
![Page 16: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/16.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
ディレクトリ
15/48
![Page 17: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/17.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
ディレクトリ: まとめツリー構造✓
節・葉: エントリ✓
エントリ内の情報: オブジェクト✓
オブジェクト1つの名前✓
複数の属性: 名前と値✓
複数の属性値✓
✓
16/48
![Page 18: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/18.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
ActiveLdap入門
社内システム✓
Active Directory✓
ActiveLdap入門✓
Rails + ActiveLdap Tips✓
17/48
![Page 19: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/19.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
ActiveLdap?
18/48
![Page 20: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/20.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
ActiveLdap?: まとめ
ActiveRecordのLDAP版
対応関係テーブル → ツリー✓
レコード → エントリ✓
カラム → 属性✓
✓
同じようなインターフェイス✓19/48
![Page 21: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/21.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
名前
20/48
![Page 22: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/22.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
名前: まとめ
DN: Distinguished Nameツリー内で一意な名前✓
RDNを「,」区切りで連結✓
✓
RDN: Relative DN同階層内で一意な名前✓
✓
21/48
![Page 23: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/23.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
入門の入門
サンプルディレクトリ✓
scaffold_active_ldap✓
search✓
クラス定義✓
find✓
22/48
![Page 24: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/24.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
コードを書くこと
私たちができることはコードを書くこと。コードを通じて伝えられることは多いよ。
[「http://adzuki34.blogspot.com/2009/12/ruby02.html」より引用]
23/48
![Page 25: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/25.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
サンプルディレクトリ
24/48
![Page 26: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/26.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
scaffold_active_ldap
% rails sample% cd sample% script/generate scaffold_active_ldap% vim config/ldap.yml% vim config/environment.rb config.gem "activeldap", :lib => "active_ldap"
25/48
![Page 27: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/27.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
search
% script/console>> pp ActiveLdap::Base.search.collect {|dn, attributes| dn.to_s}["dc=clear-code,dc=local", "cn=admin,dc=clear-code,dc=local", "ou=users,dc=clear-code,dc=local", "cn=user1,ou=users,dc=clear-code,dc=local", "cn=user2,ou=users,dc=clear-code,dc=local", "cn=user3,ou=users,dc=clear-code,dc=local"]=> nil
26/48
![Page 28: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/28.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
クラス定義
% script/generate model_active_ldap user% cat app/models/user.rbclass User < ActiveLdap::Base ldap_mapping :dn_attribute => "cn", :prefix => "ou=users"end
27/48
![Page 29: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/29.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
find
% script/console>> pp User.find(:all).collect {|user| user.dn.to_s}["cn=user1,ou=users,dc=clear-code,dc=local", "cn=user2,ou=users,dc=clear-code,dc=local", "cn=user3,ou=users,dc=clear-code,dc=local"]=> nil>> user1 = User.find("user1")>> user1.dn.to_s=> "cn=user1,ou=users,dc=clear-code,dc=local">> puts user1.to_ldifversion: 1dn: cn=user1,ou=users,dc=clear-code,dc=localcn: user1objectClass: personsn: User1userPassword: {SSHA}KDKfYE+hwXYYqN8dtrUwxwFij3EzUTdC=> nil
28/48
![Page 30: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/30.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
入門
認証✓
save✓
validation✓
パスワード変更✓
29/48
![Page 31: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/31.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
認証
>> user1.bind("secret")=> true>> user1.bind("wrong")ActiveLdap::AuthenticationError: Invalid credentials
30/48
![Page 32: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/32.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
save
>> user1.description=> nil>> user1.description = "sample user"=> "sample user">> user1.save=> true>> user1 = User.find("user1")>> user1.description=> "sample user"
31/48
![Page 33: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/33.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
validation
% vim app/model/user.rb validates_presence_of :description% script/console>> user2 = User.find("user2")>> user2.save!ActiveLdap::EntryInvalid: 入力値が正しくありません。: 説明(description)を入力してください。>> user2.description = "sample user2">> user2.save!
32/48
![Page 34: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/34.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
パスワード変更
>> user2.user_password = ActiveLdap::UserPassword.ssha("new password")>> user2.bind("new password")ActiveLdap::AuthenticationError: Invalid credentials>> user2.save!>> user2.bind("new password")=> true
33/48
![Page 35: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/35.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
入門後
LDIF✓
スキーマ一覧✓
コマンドラインツール✓
34/48
![Page 36: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/36.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
Rails + ActiveLdap Tips
社内システム✓
Active Directory✓
ActiveLdap入門✓
Rails + ActiveLdap Tips✓
35/48
![Page 37: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/37.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
接続
36/48
![Page 38: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/38.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
スケール
接続はプロセス間共有不可ユーザ毎に接続 → Passenger✓
✓
対策:ユーザ毎の接続を持たない✓
1リクエストで完結させる✓
✓
37/48
![Page 39: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/39.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
スケール対策: 同期
LDAPサーバは参照がメイン✓
必要な情報だけRDBに取り込むログイン時に同期a.
定期的にバッチで同期b.
管理画面に同期ボタンc.
✓
認証はLDAPサーバへ✓38/48
![Page 40: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/40.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
バックエンド
Ruby/LDAPOpenLDAPのバインディング✓
✓
Net::LDAPPure Ruby実装✓
✓
JNDIJava Naming and Directory Interface✓
✓
39/48
![Page 41: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/41.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
バックエンド: おすすめ
RubyならRuby/LDAP✓
JRubyならJNDI✓
Pure RubyがよいならNet::LDAPただしtrunkに限る✓
0.0.4は問題がいくつか✓
trunkでは修正済✓
✓
40/48
![Page 42: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/42.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
テスト: フィクスチャ
def setup @ldif = ActiveLdap::Base.dump ActiveLdap::Base.delete_all # テスト用データを読み込みend
def teardown ActiveLdap::Base.delete_all ActiveLdap::Base.load(@ldif) if @ldifend
41/48
![Page 43: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/43.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
フィクスチャ: 便利機能ActiveLdap::Base
.dump: データをLDIFで取得✓
.load: LDIFをロード✓
.delete_all: データを削除✓
✓
ActiveLdap::Populate.ensure_dc: dc=XXX作成✓
.ensure_ou: ou=XXX作成✓
.ensure_base: dc=XXX,dc=YYY,...作成✓
✓
42/48
![Page 44: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/44.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
フィクスチャ: AD用注意点
LDAPSで接続することパスワードが設定できない✓
✓
パスワードは"..." + UTF-16 LE
def encode_password(passowrd) quoted_password = "\"#{password}\"" Iconv.iconv("UTF16LE", "UTF8", quoted_password)[0]end
✓
43/48
![Page 45: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/45.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
フィクスチャ: LDIF
バイナリ値: Base64で"::"区切り✓
パスワードはunicodePwdへ
unicodePwd:: <%= [encode_password("secret")].pack("m").chomp %>
✓
オススメの作成方法コンテナはRubyで✓
オブジェクトはLDIFで: dump→編集✓
✓
44/48
![Page 46: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/46.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
Samba + LDAP
ActiveSambaLdapActiveLdapを利用✓
Samba + LDAP用便利ライブラリ✓
管理用コマンドラインツール✓
✓
Samba 3: LDAPはオプション✓
Samba 4: LDAP必須✓45/48
![Page 47: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/47.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
まとめLDAPエントリをActiveRecord風APIで操作
Railsと相性がよい✓
✓
Active Directoryにも使える✓
LDAP特有の問題点ユーザ毎に接続を持たない✓
✓
テスト作成もサポート✓46/48
![Page 48: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/48.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
次のステップ
るびまのActiveLdap記事
http://jp.rubyist.net/magazine/?0027-ActiveLdap
47/48
![Page 49: Railsで作るActive Directoryと連携 した社内システム · 〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3 スケール対策: 同期 LDAPサーバは参照がメイン](https://reader035.fdocuments.net/reader035/viewer/2022062917/5ed2db2ea079355bb26d9b3b/html5/thumbnails/49.jpg)
〜Ruby on Rails Technical Night〜 Powered by Rabbit 0.6.3
大事なこと
Ruby・Railsのことならクリアコードへ
http://www.clear-code.com/contact/
48/48