ruby-activeldap 0.8.3 → 0.8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +431 -0
- data/COPYING +340 -0
- data/LICENSE +58 -0
- data/README +104 -0
- data/Rakefile +165 -0
- data/TODO +22 -0
- data/benchmark/bench-al.rb +202 -0
- data/benchmark/config.yaml.sample +5 -0
- data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
- data/examples/al-admin/README +182 -0
- data/examples/al-admin/Rakefile +10 -0
- data/examples/al-admin/app/controllers/account_controller.rb +50 -0
- data/examples/al-admin/app/controllers/application.rb +15 -0
- data/examples/al-admin/app/controllers/directory_controller.rb +22 -0
- data/examples/al-admin/app/controllers/users_controller.rb +38 -0
- data/examples/al-admin/app/controllers/welcome_controller.rb +4 -0
- data/examples/al-admin/app/helpers/account_helper.rb +2 -0
- data/examples/al-admin/app/helpers/application_helper.rb +6 -0
- data/examples/al-admin/app/helpers/directory_helper.rb +2 -0
- data/examples/al-admin/app/helpers/users_helper.rb +13 -0
- data/examples/al-admin/app/helpers/welcome_helper.rb +2 -0
- data/examples/al-admin/app/models/entry.rb +19 -0
- data/examples/al-admin/app/models/ldap_user.rb +49 -0
- data/examples/al-admin/app/models/user.rb +91 -0
- data/examples/al-admin/app/views/account/login.rhtml +12 -0
- data/examples/al-admin/app/views/account/sign_up.rhtml +22 -0
- data/examples/al-admin/app/views/directory/index.rhtml +5 -0
- data/examples/al-admin/app/views/directory/populate.rhtml +2 -0
- data/examples/al-admin/app/views/layouts/application.rhtml +41 -0
- data/examples/al-admin/app/views/users/_attribute_information.rhtml +22 -0
- data/examples/al-admin/app/views/users/_entry.rhtml +12 -0
- data/examples/al-admin/app/views/users/_form.rhtml +29 -0
- data/examples/al-admin/app/views/users/_object_class_information.rhtml +23 -0
- data/examples/al-admin/app/views/users/edit.rhtml +10 -0
- data/examples/al-admin/app/views/users/index.rhtml +9 -0
- data/examples/al-admin/app/views/users/show.rhtml +3 -0
- data/examples/al-admin/app/views/welcome/index.rhtml +16 -0
- data/examples/al-admin/config/boot.rb +45 -0
- data/examples/al-admin/config/database.yml.example +19 -0
- data/examples/al-admin/config/environment.rb +68 -0
- data/examples/al-admin/config/environments/development.rb +21 -0
- data/examples/al-admin/config/environments/production.rb +18 -0
- data/examples/al-admin/config/environments/test.rb +19 -0
- data/examples/al-admin/config/ldap.yml.example +21 -0
- data/examples/al-admin/config/routes.rb +26 -0
- data/examples/al-admin/db/migrate/001_create_users.rb +16 -0
- data/examples/al-admin/lib/accept_http_rails_relative_url_root.rb +9 -0
- data/examples/al-admin/lib/authenticated_system.rb +131 -0
- data/examples/al-admin/lib/authenticated_test_helper.rb +113 -0
- data/examples/al-admin/lib/tasks/gettext.rake +35 -0
- data/examples/al-admin/po/en/al-admin.po +190 -0
- data/examples/al-admin/po/ja/al-admin.po +190 -0
- data/examples/al-admin/po/nl/al-admin.po +202 -0
- data/examples/al-admin/public/.htaccess +40 -0
- data/examples/al-admin/public/404.html +30 -0
- data/examples/al-admin/public/500.html +30 -0
- data/examples/al-admin/public/dispatch.cgi +10 -0
- data/examples/al-admin/public/dispatch.fcgi +24 -0
- data/examples/al-admin/public/dispatch.rb +10 -0
- data/examples/al-admin/public/favicon.ico +0 -0
- data/examples/al-admin/public/images/rails.png +0 -0
- data/examples/al-admin/public/javascripts/application.js +2 -0
- data/examples/al-admin/public/javascripts/controls.js +833 -0
- data/examples/al-admin/public/javascripts/dragdrop.js +942 -0
- data/examples/al-admin/public/javascripts/effects.js +1088 -0
- data/examples/al-admin/public/javascripts/prototype.js +2515 -0
- data/examples/al-admin/public/robots.txt +1 -0
- data/examples/al-admin/public/stylesheets/rails.css +35 -0
- data/examples/al-admin/public/stylesheets/screen.css +52 -0
- data/examples/al-admin/script/about +3 -0
- data/examples/al-admin/script/breakpointer +3 -0
- data/examples/al-admin/script/console +3 -0
- data/examples/al-admin/script/destroy +3 -0
- data/examples/al-admin/script/generate +3 -0
- data/examples/al-admin/script/performance/benchmarker +3 -0
- data/examples/al-admin/script/performance/profiler +3 -0
- data/examples/al-admin/script/plugin +3 -0
- data/examples/al-admin/script/process/inspector +3 -0
- data/examples/al-admin/script/process/reaper +3 -0
- data/examples/al-admin/script/process/spawner +3 -0
- data/examples/al-admin/script/runner +3 -0
- data/examples/al-admin/script/server +3 -0
- data/examples/al-admin/test/fixtures/users.yml +9 -0
- data/examples/al-admin/test/functional/account_controller_test.rb +24 -0
- data/examples/al-admin/test/functional/directory_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/users_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/welcome_controller_test.rb +18 -0
- data/examples/al-admin/test/run-test.sh +3 -0
- data/examples/al-admin/test/test_helper.rb +28 -0
- data/examples/al-admin/test/unit/user_test.rb +13 -0
- data/examples/al-admin/vendor/plugins/exception_notification/README +111 -0
- data/examples/al-admin/vendor/plugins/exception_notification/init.rb +1 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifiable.rb +99 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +67 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +77 -0
- data/examples/al-admin/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +61 -0
- data/examples/al-admin/vendor/plugins/exception_notification/test/test_helper.rb +7 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +1 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +7 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +16 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +3 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +2 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +3 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +6 -0
- data/examples/config.yaml.example +5 -0
- data/examples/example.der +0 -0
- data/examples/example.jpg +0 -0
- data/examples/groupadd +41 -0
- data/examples/groupdel +35 -0
- data/examples/groupls +49 -0
- data/examples/groupmod +42 -0
- data/examples/lpasswd +55 -0
- data/examples/objects/group.rb +13 -0
- data/examples/objects/ou.rb +4 -0
- data/examples/objects/user.rb +20 -0
- data/examples/ouadd +38 -0
- data/examples/useradd +45 -0
- data/examples/useradd-binary +50 -0
- data/examples/userdel +34 -0
- data/examples/userls +50 -0
- data/examples/usermod +42 -0
- data/examples/usermod-binary-add +47 -0
- data/examples/usermod-binary-add-time +51 -0
- data/examples/usermod-binary-del +48 -0
- data/examples/usermod-lang-add +43 -0
- data/lib/active_ldap.rb +978 -0
- data/lib/active_ldap/adapter/base.rb +512 -0
- data/lib/active_ldap/adapter/ldap.rb +233 -0
- data/lib/active_ldap/adapter/ldap_ext.rb +69 -0
- data/lib/active_ldap/adapter/net_ldap.rb +290 -0
- data/lib/active_ldap/adapter/net_ldap_ext.rb +29 -0
- data/lib/active_ldap/association/belongs_to.rb +47 -0
- data/lib/active_ldap/association/belongs_to_many.rb +42 -0
- data/lib/active_ldap/association/collection.rb +83 -0
- data/lib/active_ldap/association/has_many.rb +31 -0
- data/lib/active_ldap/association/has_many_utils.rb +35 -0
- data/lib/active_ldap/association/has_many_wrap.rb +46 -0
- data/lib/active_ldap/association/proxy.rb +102 -0
- data/lib/active_ldap/associations.rb +172 -0
- data/lib/active_ldap/attributes.rb +211 -0
- data/lib/active_ldap/base.rb +1256 -0
- data/lib/active_ldap/callbacks.rb +19 -0
- data/lib/active_ldap/command.rb +48 -0
- data/lib/active_ldap/configuration.rb +114 -0
- data/lib/active_ldap/connection.rb +234 -0
- data/lib/active_ldap/distinguished_name.rb +250 -0
- data/lib/active_ldap/escape.rb +12 -0
- data/lib/active_ldap/get_text/parser.rb +142 -0
- data/lib/active_ldap/get_text_fallback.rb +53 -0
- data/lib/active_ldap/get_text_support.rb +12 -0
- data/lib/active_ldap/helper.rb +23 -0
- data/lib/active_ldap/ldap_error.rb +74 -0
- data/lib/active_ldap/object_class.rb +93 -0
- data/lib/active_ldap/operations.rb +419 -0
- data/lib/active_ldap/populate.rb +44 -0
- data/lib/active_ldap/schema.rb +427 -0
- data/lib/active_ldap/timeout.rb +75 -0
- data/lib/active_ldap/timeout_stub.rb +17 -0
- data/lib/active_ldap/user_password.rb +93 -0
- data/lib/active_ldap/validations.rb +112 -0
- data/po/en/active-ldap.po +3011 -0
- data/po/ja/active-ldap.po +3044 -0
- data/rails/plugin/active_ldap/README +54 -0
- data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +7 -0
- data/rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml +21 -0
- data/rails/plugin/active_ldap/init.rb +19 -0
- data/test/al-test-utils.rb +362 -0
- data/test/command.rb +62 -0
- data/test/config.yaml.sample +6 -0
- data/test/run-test.rb +31 -0
- data/test/test-unit-ext.rb +4 -0
- data/test/test-unit-ext/always-show-result.rb +28 -0
- data/test/test-unit-ext/backtrace-filter.rb +17 -0
- data/test/test-unit-ext/long-display-for-emacs.rb +25 -0
- data/test/test-unit-ext/priority.rb +163 -0
- metadata +211 -4
data/LICENSE
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
|
3
|
+
(see COPYING file), or the conditions below:
|
|
4
|
+
|
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
|
6
|
+
software without restriction, provided that you duplicate all of the
|
|
7
|
+
original copyright notices and associated disclaimers.
|
|
8
|
+
|
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
|
10
|
+
you do at least ONE of the following:
|
|
11
|
+
|
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
|
13
|
+
make them Freely Available, such as by posting said
|
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
|
15
|
+
the author to include your modifications in the software.
|
|
16
|
+
|
|
17
|
+
b) use the modified software only within your corporation or
|
|
18
|
+
organization.
|
|
19
|
+
|
|
20
|
+
c) rename any non-standard executables so the names do not conflict
|
|
21
|
+
with standard executables, which must also be provided.
|
|
22
|
+
|
|
23
|
+
d) make other distribution arrangements with the author.
|
|
24
|
+
|
|
25
|
+
3. You may distribute the software in object code or executable
|
|
26
|
+
form, provided that you do at least ONE of the following:
|
|
27
|
+
|
|
28
|
+
a) distribute the executables and library files of the software,
|
|
29
|
+
together with instructions (in the manual page or equivalent)
|
|
30
|
+
on where to get the original distribution.
|
|
31
|
+
|
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
|
33
|
+
the software.
|
|
34
|
+
|
|
35
|
+
c) give non-standard executables non-standard names, with
|
|
36
|
+
instructions on where to get the original software distribution.
|
|
37
|
+
|
|
38
|
+
d) make other distribution arrangements with the author.
|
|
39
|
+
|
|
40
|
+
4. You may modify and include the part of the software into any other
|
|
41
|
+
software (possibly commercial). But some files in the distribution
|
|
42
|
+
are not written by the author, so that they are not under this terms.
|
|
43
|
+
|
|
44
|
+
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
|
45
|
+
files under the ./missing directory. See each file for the copying
|
|
46
|
+
condition.
|
|
47
|
+
|
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
|
49
|
+
output from the software do not automatically fall under the
|
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
|
52
|
+
software.
|
|
53
|
+
|
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
57
|
+
PURPOSE.
|
|
58
|
+
|
data/README
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Ruby/ActiveLdap -- ruby library for object-oriented LDAP interction
|
|
2
|
+
Copyright (C) 2004-2006 Will Drewry <will@alum.bu.edu>, Kouhei Sutou <kou@cozmixng.org>
|
|
3
|
+
Contributors:
|
|
4
|
+
* Dick Davies <rasputnik@hellooperator.net>
|
|
5
|
+
* Nathan Kinder <quicksilver02@mac.com>
|
|
6
|
+
* Patrick Cole <pac@independent.com.au>
|
|
7
|
+
* Google Inc.
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
'Ruby/ActiveLdap' is a ruby extension library which provides a clean objected
|
|
11
|
+
oriented interface to the Ruby/LDAP[0] library. It was inspired by
|
|
12
|
+
ActivRecord[2]. This is not nearly as clean or as flexible as ActiveRecord, but
|
|
13
|
+
it is still trivial to define new objects and manipulate them with minimal
|
|
14
|
+
difficulty.
|
|
15
|
+
|
|
16
|
+
For example and usage - read the rdoc in doc/ from lib/activeldap.rb.
|
|
17
|
+
It is also available on the web at:
|
|
18
|
+
|
|
19
|
+
http://ruby-activeldap.rubyforge.org/
|
|
20
|
+
|
|
21
|
+
PREREQUISITES
|
|
22
|
+
|
|
23
|
+
* Ruby 1.8.x [1]
|
|
24
|
+
* Ruby/LDAP [0]
|
|
25
|
+
* Log4r [4]
|
|
26
|
+
* ActiveRecord [2]
|
|
27
|
+
* (Optional) Ruby/LDAP+GSSAPI [3]
|
|
28
|
+
* An LDAP server compatible with Ruby/LDAP: OpenLDAP, etc
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
NOTES
|
|
32
|
+
|
|
33
|
+
* Only GSSAPI SASL support exists due to Ruby/LDAP limitations
|
|
34
|
+
* The API is subject to change as this package slowly approaches 1.0.0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
INSTALL
|
|
38
|
+
|
|
39
|
+
- Edit active_ldap/configuration.rb with your LDAP preferences
|
|
40
|
+
- Run -
|
|
41
|
+
sudo rake install
|
|
42
|
+
|
|
43
|
+
RAILS
|
|
44
|
+
|
|
45
|
+
There is a small rails plugin included that allows the use of a file named
|
|
46
|
+
'ldap.yml' in the config directory of your rails app. This file has a similar
|
|
47
|
+
function to the 'database.yml' file that allows you to set your database
|
|
48
|
+
connection settings per environment. Similarly, the ldap.yml file allows
|
|
49
|
+
settings to be set for development, test, and production environments. For
|
|
50
|
+
instance, the development entry would look something like the following:
|
|
51
|
+
|
|
52
|
+
development:
|
|
53
|
+
host: 127.0.0.1
|
|
54
|
+
port: 389
|
|
55
|
+
base: dc=localhost
|
|
56
|
+
bind_dn: cn=admin,dc=localhost
|
|
57
|
+
password: secret
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
To install, simply copy the rails/plugin/active_ldap folder into the
|
|
61
|
+
vendor/plugins directory of your rails application and create config/ldap.yml.
|
|
62
|
+
When your application starts up, the plugin will call #establish_connection
|
|
63
|
+
using the parameters specified for your current environment.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
LICENCE
|
|
67
|
+
|
|
68
|
+
This program is free software; you can redistribute it and/or modify it. It is
|
|
69
|
+
dual licensed under Ruby's license and under the terms of the GNU General
|
|
70
|
+
Public License as published by the Free Software Foundation; either version 2,
|
|
71
|
+
or (at your option) any later version.
|
|
72
|
+
|
|
73
|
+
Please see the file LICENSE for the terms of the licence.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
REFERENCES
|
|
77
|
+
|
|
78
|
+
[0] - http://ruby-ldap.sourceforge.net
|
|
79
|
+
[1] - http://www.ruby-lang.org
|
|
80
|
+
[2] - http://activerecord.rubyonrails.org
|
|
81
|
+
[3] - http://caliban.org/files/redhat/RPMS/i386/ruby-ldap-0.8.2-4.i386.rpm
|
|
82
|
+
[4] - http://log4r.sourceforge.net/
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
THANKS
|
|
86
|
+
|
|
87
|
+
This list may not be correct. If you notice mistakes of this
|
|
88
|
+
list, please point out.
|
|
89
|
+
|
|
90
|
+
* Nobody: Bug reports.
|
|
91
|
+
* James Hughes: Bug reports and advices and documentations.
|
|
92
|
+
* Buzz Chopra: Documentations.
|
|
93
|
+
* Christoph Lipp: Bug reports.
|
|
94
|
+
* Jeff Hall: Bug reports.
|
|
95
|
+
* Ernie Miller: Bug reports and advices.
|
|
96
|
+
* Daniel Pfile: Patches.
|
|
97
|
+
* Jacob Wilkins: Bug reports.
|
|
98
|
+
* Ace Suares:
|
|
99
|
+
* Bug reports.
|
|
100
|
+
* Nederlands translations.
|
|
101
|
+
* Iain Pople: Bug reports and API improvement ideas.
|
|
102
|
+
* Christoph Lipp: Tell us character escape syntax.
|
|
103
|
+
* Kevin McCarthy: Patches.
|
|
104
|
+
* Perry Smith: Patches and bug reports.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'hoe'
|
|
5
|
+
require 'find'
|
|
6
|
+
|
|
7
|
+
base_dir = File.expand_path(File.dirname(__FILE__))
|
|
8
|
+
$LOAD_PATH.unshift(File.join(base_dir, 'lib'))
|
|
9
|
+
require 'active_ldap'
|
|
10
|
+
|
|
11
|
+
truncate_base_dir = Proc.new do |x|
|
|
12
|
+
x.gsub(/^#{Regexp.escape(base_dir + File::SEPARATOR)}/, '')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
manifest = File.join(base_dir, "Manifest.txt")
|
|
16
|
+
manifest_contents = []
|
|
17
|
+
base_dir_included_components = %w(CHANGES COPYING LICENSE Manifest.txt
|
|
18
|
+
README Rakefile TODO)
|
|
19
|
+
excluded_components = %w(.svn .test-result .config doc log tmp
|
|
20
|
+
pkg html config.yaml database.yml ldap.yml)
|
|
21
|
+
excluded_suffixes = %w(.help .sqlite3)
|
|
22
|
+
white_list_paths =
|
|
23
|
+
[
|
|
24
|
+
"rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml"
|
|
25
|
+
]
|
|
26
|
+
Find.find(base_dir + "/") do |target|
|
|
27
|
+
target = truncate_base_dir[target]
|
|
28
|
+
components = target.split(File::SEPARATOR)
|
|
29
|
+
if components.size == 1 and !File.directory?(target)
|
|
30
|
+
next unless base_dir_included_components.include?(components[0])
|
|
31
|
+
end
|
|
32
|
+
unless white_list_paths.include?(target)
|
|
33
|
+
Find.prune if (excluded_components - components) != excluded_components
|
|
34
|
+
next if excluded_suffixes.include?(File.extname(target))
|
|
35
|
+
end
|
|
36
|
+
manifest_contents << target if File.file?(target)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
File.open(manifest, "w") do |f|
|
|
40
|
+
f.puts manifest_contents.sort.join("\n")
|
|
41
|
+
end
|
|
42
|
+
at_exit do
|
|
43
|
+
FileUtils.rm_f(manifest)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
project = Hoe.new('ruby-activeldap', ActiveLdap::VERSION) do |project|
|
|
48
|
+
project.rubyforge_name = 'ruby-activeldap'
|
|
49
|
+
project.author = ['Will Drewry', 'Kouhei Sutou']
|
|
50
|
+
project.email = ['will@alum.bu.edu', 'kou@cozmixng.org']
|
|
51
|
+
project.summary = 'Ruby/ActiveLdap is a object-oriented API to LDAP'
|
|
52
|
+
project.url = 'http://rubyforge.org/projects/ruby-activeldap/'
|
|
53
|
+
project.test_globs = ['test/test_*.rb']
|
|
54
|
+
project.changes = project.paragraphs_of('CHANGES', 0..1).join("\n\n")
|
|
55
|
+
project.extra_deps = [['log4r', '>= 1.0.4'], 'activerecord']
|
|
56
|
+
project.spec_extras = {
|
|
57
|
+
:requirements => ['ruby-ldap >= 0.8.2', '(Open)LDAP server'],
|
|
58
|
+
:autorequire => 'active_ldap',
|
|
59
|
+
:executables => [],
|
|
60
|
+
}
|
|
61
|
+
project.description = String.new(<<-EOF)
|
|
62
|
+
'Ruby/ActiveLdap' is a ruby extension library which provides a clean
|
|
63
|
+
objected oriented interface to the Ruby/LDAP library. It was inspired
|
|
64
|
+
by ActiveRecord. This is not nearly as clean or as flexible as
|
|
65
|
+
ActiveRecord, but it is still trivial to define new objects and manipulate
|
|
66
|
+
them with minimal difficulty.
|
|
67
|
+
EOF
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
publish_docs_actions = task(:publish_docs).instance_variable_get("@actions")
|
|
71
|
+
original_project_name = nil
|
|
72
|
+
before_publish_docs = Proc.new do
|
|
73
|
+
original_project_name = project.name
|
|
74
|
+
project.name = "doc"
|
|
75
|
+
end
|
|
76
|
+
after_publish_docs = Proc.new do
|
|
77
|
+
project.name = original_project_name
|
|
78
|
+
end
|
|
79
|
+
publish_docs_actions.unshift(before_publish_docs)
|
|
80
|
+
publish_docs_actions.push(after_publish_docs)
|
|
81
|
+
|
|
82
|
+
# fix Hoe's incorrect guess.
|
|
83
|
+
project.spec.executables.clear
|
|
84
|
+
project.bin_files = project.spec.files.grep(/^bin/)
|
|
85
|
+
|
|
86
|
+
# fix Hoe's install and uninstall task.
|
|
87
|
+
task(:install).instance_variable_get("@actions").clear
|
|
88
|
+
task(:uninstall).instance_variable_get("@actions").clear
|
|
89
|
+
|
|
90
|
+
task :install do
|
|
91
|
+
[
|
|
92
|
+
[project.lib_files, "lib", Hoe::RUBYLIB, 0444],
|
|
93
|
+
[project.bin_files, "bin", File.join(Hoe::PREFIX, 'bin'), 0555]
|
|
94
|
+
].each do |files, prefix, dest, mode|
|
|
95
|
+
FileUtils.mkdir_p dest unless test ?d, dest
|
|
96
|
+
files.each do |file|
|
|
97
|
+
base = File.dirname(file.sub(/^#{prefix}#{File::SEPARATOR}/, ''))
|
|
98
|
+
_dest = File.join(dest, base)
|
|
99
|
+
FileUtils.mkdir_p _dest unless test ?d, _dest
|
|
100
|
+
install file, _dest, :mode => mode
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
desc 'Uninstall the package.'
|
|
106
|
+
task :uninstall do
|
|
107
|
+
Dir.chdir Hoe::RUBYLIB do
|
|
108
|
+
rm_f project.lib_files.collect {|f| f.sub(/^lib#{File::SEPARATOR}/, '')}
|
|
109
|
+
end
|
|
110
|
+
Dir.chdir File.join(Hoe::PREFIX, 'bin') do
|
|
111
|
+
rm_f project.bin_files.collect {|f| f.sub(/^bin#{File::SEPARATOR}/, '')}
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
desc 'Tag the repository for release.'
|
|
116
|
+
task :tag do
|
|
117
|
+
system "svn copy -m 'New release tag' https://ruby-activeldap.googlecode.com/svn/trunk https://ruby-activeldap.googlecode.com/svn/tags/r#{ActiveLdap::VERSION}"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
desc "Update *.po/*.pot files and create *.mo from *.po files"
|
|
122
|
+
task :gettext => ["gettext:po:update", "gettext:mo:create"]
|
|
123
|
+
|
|
124
|
+
namespace :gettext do
|
|
125
|
+
desc "Setup environment for GetText"
|
|
126
|
+
task :environment do
|
|
127
|
+
require "gettext/utils"
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
namespace :po do
|
|
131
|
+
desc "Update po/pot files (GetText)"
|
|
132
|
+
task :update => "gettext:environment" do
|
|
133
|
+
require 'active_ldap/get_text/parser'
|
|
134
|
+
dummy_file = "@@@dummy-for-active-ldap@@@"
|
|
135
|
+
parser = Object.new
|
|
136
|
+
parser.instance_eval do
|
|
137
|
+
@parser = ActiveLdap::GetText::Parser.new
|
|
138
|
+
@dummy_file = dummy_file
|
|
139
|
+
end
|
|
140
|
+
def parser.target?(file)
|
|
141
|
+
file == @dummy_file
|
|
142
|
+
end
|
|
143
|
+
def parser.parse(file, targets)
|
|
144
|
+
@parser.extract_all_in_schema(targets)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
GetText::RGetText.add_parser(parser)
|
|
148
|
+
files = [dummy_file] + Dir.glob("{lib,rails,benchmark}/**/*.rb")
|
|
149
|
+
GetText.update_pofiles("active-ldap",
|
|
150
|
+
files,
|
|
151
|
+
"Ruby/ActiveLdap #{ActiveLdap::VERSION}")
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
namespace :mo do
|
|
156
|
+
desc "Create *.mo from *.po (GetText)"
|
|
157
|
+
task :create => "gettext:environment" do
|
|
158
|
+
GetText.create_mofiles(false)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
task(:gem).prerequisites.unshift("gettext:mo:create")
|
|
164
|
+
|
|
165
|
+
# vim: syntax=ruby
|
data/TODO
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
- Test SASL bind.
|
|
2
|
+
- Add result pagination via LDAP::Controls
|
|
3
|
+
- serialize & serialized_attributes
|
|
4
|
+
- schema mgmt - how does AR handle it?
|
|
5
|
+
- columns() -- ?
|
|
6
|
+
http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000865
|
|
7
|
+
- provide full documentation for new API.
|
|
8
|
+
- handle all exception raised from Ruby/LDAP and wrap as
|
|
9
|
+
ActiveLdap exception. I think we need to develop an
|
|
10
|
+
application using ActiveLdap.
|
|
11
|
+
- Add locking around Timeout.alarm() to ensure a multithreaded ruby
|
|
12
|
+
app doesn't hit any race conditions
|
|
13
|
+
- Add AR matching exceptions:
|
|
14
|
+
* ActiveRecordError -- ActiveLdapError as base
|
|
15
|
+
* AssociationTypeMismatch
|
|
16
|
+
* SerializationTypeMismatch
|
|
17
|
+
* ConnectionNotEstablished
|
|
18
|
+
* RecordNotFound
|
|
19
|
+
* LdapActionInvalid - like StatementInvalid
|
|
20
|
+
* MultiparameterAssignmentErrors
|
|
21
|
+
* AttributeAssignmentError
|
|
22
|
+
* RecordNotSaved
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
base = File.dirname(__FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(base))
|
|
3
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(base, "..", "lib")))
|
|
4
|
+
|
|
5
|
+
require "active_ldap"
|
|
6
|
+
require "benchmark"
|
|
7
|
+
|
|
8
|
+
include ActiveLdap::GetTextSupport
|
|
9
|
+
|
|
10
|
+
argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
|
|
11
|
+
options.prefix = "ou=People"
|
|
12
|
+
|
|
13
|
+
opts.on("--prefix=PREFIX",
|
|
14
|
+
_("Specify prefix for benchmarking"),
|
|
15
|
+
_("(default: %s)") % options.prefix) do |prefix|
|
|
16
|
+
options.prefix = prefix
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
ActiveLdap::Base.establish_connection
|
|
21
|
+
config = ActiveLdap::Base.configuration
|
|
22
|
+
|
|
23
|
+
LDAP_HOST = config[:host]
|
|
24
|
+
LDAP_PORT = config[:port]
|
|
25
|
+
LDAP_BASE = config[:base]
|
|
26
|
+
LDAP_PREFIX = options.prefix
|
|
27
|
+
LDAP_USER = config[:bind_dn]
|
|
28
|
+
LDAP_PASSWORD = config[:password]
|
|
29
|
+
|
|
30
|
+
class ALUser < ActiveLdap::Base
|
|
31
|
+
ldap_mapping :dn_attribute => 'uid', :prefix => LDAP_PREFIX,
|
|
32
|
+
:classes => ['posixAccount', 'person']
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# === search_al
|
|
36
|
+
#
|
|
37
|
+
def search_al
|
|
38
|
+
count = 0
|
|
39
|
+
ALUser.find(:all).each do |e|
|
|
40
|
+
count += 1
|
|
41
|
+
end
|
|
42
|
+
count
|
|
43
|
+
end # -- search_al
|
|
44
|
+
|
|
45
|
+
def search_al_without_object_creation
|
|
46
|
+
count = 0
|
|
47
|
+
ALUser.search.each do |e|
|
|
48
|
+
count += 1
|
|
49
|
+
end
|
|
50
|
+
count
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# === search_ldap
|
|
54
|
+
#
|
|
55
|
+
def search_ldap(conn)
|
|
56
|
+
count = 0
|
|
57
|
+
conn.search("#{LDAP_PREFIX},#{LDAP_BASE}",
|
|
58
|
+
LDAP::LDAP_SCOPE_SUBTREE,
|
|
59
|
+
"(uid=*)") do |e|
|
|
60
|
+
count += 1
|
|
61
|
+
end
|
|
62
|
+
count
|
|
63
|
+
end # -- search_ldap
|
|
64
|
+
|
|
65
|
+
def search_net_ldap(conn)
|
|
66
|
+
count = 0
|
|
67
|
+
conn.search(:base => "#{LDAP_PREFIX},#{LDAP_BASE}",
|
|
68
|
+
:scope => Net::LDAP::SearchScope_WholeSubtree,
|
|
69
|
+
:filter => "(uid=*)") do |e|
|
|
70
|
+
count += 1
|
|
71
|
+
end
|
|
72
|
+
count
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def ldap_connection
|
|
76
|
+
require 'ldap'
|
|
77
|
+
conn = LDAP::Conn.new(LDAP_HOST, LDAP_PORT)
|
|
78
|
+
conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
|
|
79
|
+
conn.bind(LDAP_USER, LDAP_PASSWORD) if LDAP_USER and LDAP_PASSWORD
|
|
80
|
+
conn
|
|
81
|
+
rescue LoadError
|
|
82
|
+
nil
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def net_ldap_connection
|
|
86
|
+
require 'net/ldap'
|
|
87
|
+
net_ldap_conn = Net::LDAP::Connection.new(:host => LDAP_HOST,
|
|
88
|
+
:port => LDAP_PORT)
|
|
89
|
+
if LDAP_USER and LDAP_PASSWORD
|
|
90
|
+
net_ldap_conn.bind(:method => :simple,
|
|
91
|
+
:username => LDAP_USER,
|
|
92
|
+
:password => LDAP_PASSWORD)
|
|
93
|
+
end
|
|
94
|
+
net_ldap_conn
|
|
95
|
+
rescue LoadError
|
|
96
|
+
nil
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def populate_base
|
|
100
|
+
suffixes = []
|
|
101
|
+
ActiveLdap::Base.base.split(/,/).reverse_each do |suffix|
|
|
102
|
+
prefix = suffixes.join(",")
|
|
103
|
+
suffixes.unshift(suffix)
|
|
104
|
+
name, value = suffix.split(/=/, 2)
|
|
105
|
+
next unless name == "dc"
|
|
106
|
+
dc_class = Class.new(ActiveLdap::Base)
|
|
107
|
+
dc_class.ldap_mapping :dn_attribute => "dc",
|
|
108
|
+
:prefix => "",
|
|
109
|
+
:scope => :base,
|
|
110
|
+
:classes => ["top", "dcObject", "organization"]
|
|
111
|
+
dc_class.instance_variable_set("@base", prefix)
|
|
112
|
+
next if dc_class.exists?(value, :prefix => "dc=#{value}")
|
|
113
|
+
dc = dc_class.new(value)
|
|
114
|
+
dc.o = dc.dc
|
|
115
|
+
begin
|
|
116
|
+
dc.save
|
|
117
|
+
rescue ActiveLdap::OperationNotPermitted
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if ActiveLdap::Base.search.empty?
|
|
122
|
+
raise "Can't populate #{ActiveLdap::Base.base}"
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def populate_users
|
|
127
|
+
ou_class = Class.new(ActiveLdap::Base)
|
|
128
|
+
ou_class.ldap_mapping :dn_attribute => "ou",
|
|
129
|
+
:prefix => "",
|
|
130
|
+
:classes => ["top", "organizationalUnit"]
|
|
131
|
+
ou_class.new(LDAP_PREFIX.split(/=/)[1]).save!
|
|
132
|
+
|
|
133
|
+
100.times do |i|
|
|
134
|
+
name = i.to_s
|
|
135
|
+
user = ALUser.new(name)
|
|
136
|
+
user.uid_number = 100000 + i
|
|
137
|
+
user.gid_number = 100000 + i
|
|
138
|
+
user.cn = name
|
|
139
|
+
user.sn = name
|
|
140
|
+
user.home_directory = "/nonexistent"
|
|
141
|
+
user.save!
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def populate
|
|
146
|
+
populate_base
|
|
147
|
+
populate_users
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# === main
|
|
151
|
+
#
|
|
152
|
+
def main(do_populate)
|
|
153
|
+
if do_populate
|
|
154
|
+
puts(_("Populating..."))
|
|
155
|
+
dumped_data = ActiveLdap::Base.dump(:scope => :sub)
|
|
156
|
+
ActiveLdap::Base.delete_all(nil, :scope => :sub)
|
|
157
|
+
populate
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Standard connection
|
|
161
|
+
#
|
|
162
|
+
ldap_conn = ldap_connection
|
|
163
|
+
net_ldap_conn = net_ldap_connection
|
|
164
|
+
|
|
165
|
+
al_count = 0
|
|
166
|
+
al_count_without_object_creation = 0
|
|
167
|
+
ldap_count = 0
|
|
168
|
+
net_ldap_count = 0
|
|
169
|
+
Benchmark.bm(20) do |x|
|
|
170
|
+
[1].each do |n|
|
|
171
|
+
x.report("%3dx: AL" % n) {n.times {al_count = search_al}}
|
|
172
|
+
x.report("%3dx: AL(No Obj)" % n) do
|
|
173
|
+
n.times do
|
|
174
|
+
al_count_without_object_creation = search_al_without_object_creation
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
if ldap_conn
|
|
178
|
+
x.report("%3dx: LDAP" % n) do
|
|
179
|
+
n.times {ldap_count = search_ldap(ldap_conn)}
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
if net_ldap_conn
|
|
183
|
+
x.report("%3dx: Net::LDAP" % n) do
|
|
184
|
+
n.times {net_ldap_count = search_net_ldap(net_ldap_conn)}
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
puts(_("Entries processed by Ruby/ActiveLdap: %d") % al_count)
|
|
190
|
+
puts(_("Entries processed by Ruby/ActiveLdap (without object creation): " \
|
|
191
|
+
"%d") % al_count_without_object_creation)
|
|
192
|
+
puts(_("Entries processed by Ruby/LDAP: %d") % ldap_count)
|
|
193
|
+
puts(_("Entries processed by Net::LDAP: %d") % net_ldap_count)
|
|
194
|
+
ensure
|
|
195
|
+
if do_populate
|
|
196
|
+
puts(_("Cleaning..."))
|
|
197
|
+
ActiveLdap::Base.delete_all(nil, :scope => :sub)
|
|
198
|
+
ActiveLdap::Base.load(dumped_data)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
main(LDAP_USER && LDAP_PASSWORD)
|