activeldap 1.2.4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +18 -0
- data/LICENSE +2 -1
- data/README.textile +137 -0
- data/doc/text/development.textile +50 -0
- data/{CHANGES → doc/text/news.textile} +256 -237
- data/doc/text/rails.textile +144 -0
- data/doc/text/tutorial.textile +1005 -0
- data/lib/active_ldap/adapter/base.rb +5 -3
- data/lib/active_ldap/adapter/net_ldap_ext.rb +1 -1
- data/lib/active_ldap/associations.rb +6 -2
- data/lib/active_ldap/base.rb +16 -71
- data/lib/active_ldap/callbacks.rb +52 -33
- data/lib/active_ldap/configuration.rb +2 -2
- data/lib/active_ldap/get_text/parser.rb +2 -2
- data/lib/active_ldap/human_readable.rb +5 -4
- data/lib/active_ldap/log_subscriber.rb +50 -0
- data/lib/active_ldap/persistence.rb +65 -0
- data/lib/active_ldap/railtie.rb +40 -0
- data/lib/active_ldap/railties/controller_runtime.rb +48 -0
- data/lib/active_ldap/user_password.rb +1 -0
- data/lib/active_ldap/validations.rb +34 -72
- data/lib/active_ldap.rb +13 -912
- data/{rails_generators/model_active_ldap → lib/rails/generators/active_ldap/model}/USAGE +2 -1
- data/lib/rails/generators/active_ldap/model/model_generator.rb +47 -0
- data/{rails_generators/model_active_ldap → lib/rails/generators/active_ldap/model}/templates/model_active_ldap.rb +0 -0
- data/lib/rails/generators/active_ldap/scaffold/scaffold_generator.rb +14 -0
- data/{rails_generators/scaffold_active_ldap → lib/rails/generators/active_ldap/scaffold}/templates/ldap.yml +1 -0
- data/test/test_base.rb +9 -0
- data/test/test_callback.rb +2 -6
- data/test/test_connection.rb +2 -2
- data/test/test_user.rb +2 -2
- data/test/test_validation.rb +11 -11
- metadata +165 -106
- data/README +0 -155
- data/Rakefile +0 -133
- data/rails/README +0 -54
- data/rails/init.rb +0 -33
- data/rails_generators/model_active_ldap/model_active_ldap_generator.rb +0 -69
- data/rails_generators/model_active_ldap/templates/unit_test.rb +0 -8
- data/rails_generators/scaffold_active_ldap/scaffold_active_ldap_generator.rb +0 -7
- data/test/al-test-utils.rb +0 -439
- data/test/command.rb +0 -112
- data/test/config.yaml.sample +0 -6
- data/test/fixtures/lower_case_object_class_schema.rb +0 -802
- data/test/run-test.rb +0 -44
data/README
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
= ActiveLdap
|
2
|
-
|
3
|
-
ruby library for object-oriented LDAP interction
|
4
|
-
|
5
|
-
* Copyright (C) 2004-2006 Will Drewry <tt><will@alum.bu.edu></tt>
|
6
|
-
* Copyright (C) 2006-2011 Kouhei Sutou <tt><kou@clear-code.com></tt>
|
7
|
-
|
8
|
-
Contributors::
|
9
|
-
* Dick Davies <tt><rasputnik AT hellooperator.net></tt>
|
10
|
-
* Nathan Kinder <tt><quicksilver02 AT mac.com></tt>
|
11
|
-
* Patrick Cole <tt><pac AT independent.com.au></tt>
|
12
|
-
* Google Inc.
|
13
|
-
|
14
|
-
== DESCRIPTION
|
15
|
-
|
16
|
-
'ActiveLdap' is a ruby extension library which provides a clean objected
|
17
|
-
oriented interface to the Ruby/LDAP[0] library. It was inspired by
|
18
|
-
ActivRecord[3]. This is not nearly as clean or as flexible as ActiveRecord, but
|
19
|
-
it is still trivial to define new objects and manipulate them with minimal
|
20
|
-
difficulty.
|
21
|
-
|
22
|
-
For example and usage - read the rdoc in doc/ from lib/activeldap.rb.
|
23
|
-
It is also available on the web at:
|
24
|
-
|
25
|
-
http://ruby-activeldap.rubyforge.org/
|
26
|
-
|
27
|
-
== PREREQUISITES
|
28
|
-
|
29
|
-
[Ruby intepreter]
|
30
|
-
One of them:
|
31
|
-
* Ruby[http://www.ruby-lang.org] (1.8.x or 1.9.1)
|
32
|
-
* JRuby[http://jruby.codehaus.org/]
|
33
|
-
|
34
|
-
[LDAP client]
|
35
|
-
JRuby doesn't need to install new library because JRuby
|
36
|
-
has builtin LDAP support. Ruby users need one of them:
|
37
|
-
* Ruby/LDAP[http://rubyforge.org/projects/ruby-ldap/]
|
38
|
-
* Net::LDAP[http://rubyforge.org/projects/net-ldap/]
|
39
|
-
|
40
|
-
* ActiveRecord[http://activerecord.rubyonrails.org]
|
41
|
-
|
42
|
-
== NOTES
|
43
|
-
|
44
|
-
* Only GSSAPI SASL support exists due to Ruby/LDAP limitations
|
45
|
-
|
46
|
-
== INSTALL
|
47
|
-
|
48
|
-
% sudo gem install activeldap
|
49
|
-
|
50
|
-
== RAILS
|
51
|
-
|
52
|
-
There is a small rails plugin included that allows the use
|
53
|
-
of a file named 'config/ldap.yml' in the config directory of
|
54
|
-
your rails app. This file has a similar function to the
|
55
|
-
'database.yml' file that allows you to set your database
|
56
|
-
connection settings per environment. Similarly, the ldap.yml
|
57
|
-
file allows settings to be set for development, test, and
|
58
|
-
production environments. For instance, the development entry
|
59
|
-
would look something like the following:
|
60
|
-
|
61
|
-
development:
|
62
|
-
host: 127.0.0.1
|
63
|
-
port: 389
|
64
|
-
base: dc=localhost
|
65
|
-
bind_dn: cn=admin,dc=localhost
|
66
|
-
password: secret
|
67
|
-
|
68
|
-
To install, simply add the following codes to you config/environment.rb:
|
69
|
-
|
70
|
-
config.gem "activeldap", :lib => "active_ldap"
|
71
|
-
|
72
|
-
When your application starts up, the plugin will call
|
73
|
-
ActiveLdap::Base.setup_connection using the parameters
|
74
|
-
specified for your current environment.
|
75
|
-
|
76
|
-
== LICENCE
|
77
|
-
|
78
|
-
This program is free software; you can redistribute it and/or modify it. It is
|
79
|
-
dual licensed under Ruby's license and under the terms of the GNU General
|
80
|
-
Public License as published by the Free Software Foundation; either version 2,
|
81
|
-
or (at your option) any later version.
|
82
|
-
|
83
|
-
Please see the file LICENSE for the terms of the licence.
|
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 and API improveent ideas.
|
91
|
-
* James Hughes: Bug reports and advices and documentations.
|
92
|
-
* Buzz Chopra: Documentations.
|
93
|
-
* Christoph Lipp:
|
94
|
-
* Bug reports.
|
95
|
-
* Tell us character escape syntax.
|
96
|
-
* Jeff Hall: Bug reports.
|
97
|
-
* Ernie Miller: Bug reports and advices.
|
98
|
-
* Daniel Pfile: Patches.
|
99
|
-
* Jacob Wilkins: Bug reports.
|
100
|
-
* Ace Suares:
|
101
|
-
* Bug reports.
|
102
|
-
* Nederlands translations.
|
103
|
-
* Iain Pople: Bug reports and API improvement ideas.
|
104
|
-
* Kevin McCarthy: Patches.
|
105
|
-
* Perry Smith: Patches, bug reports and indications.
|
106
|
-
* Marc Dequènes: API suggestions.
|
107
|
-
* Jeremy Pruitt: Bug reports.
|
108
|
-
* Bodaniel Jeanes:
|
109
|
-
* A suggestion for behavior on simple bind with empty password.
|
110
|
-
* Bug reports.
|
111
|
-
* Naoto Morishima: Bug reports.
|
112
|
-
* David Morton:
|
113
|
-
* An API improvement idea.
|
114
|
-
* Bug reports.
|
115
|
-
* Lennon Day-Reynolds: Bug reports.
|
116
|
-
* Tilo: A bug report.
|
117
|
-
* Matt Mencel: Bug reports.
|
118
|
-
* CultureSpy:
|
119
|
-
* Bug reports.
|
120
|
-
* Bug fixes.
|
121
|
-
* gwarf12: A bug report.
|
122
|
-
* Baptiste Grenier: API improvement ideas.
|
123
|
-
* Richard 3 Nicholas: API improvement ideas.
|
124
|
-
* Kazuhiro NISHIYAMA: A bug report.
|
125
|
-
* Grzegorz Marszałek: A bug report.
|
126
|
-
* しまさわらさん: A suggesetion.
|
127
|
-
* Ted Lepich: A suggestion.
|
128
|
-
* danger1986: A suggestion.
|
129
|
-
* michael.j.konopka: Bug reports.
|
130
|
-
* ingersoll: A suggestion.
|
131
|
-
* Alexey.Chebotar: Bug reports.
|
132
|
-
* ery.lee: A bug report.
|
133
|
-
* id:dicdak: A bug report.
|
134
|
-
* Raiko Mitsu: A bug report.
|
135
|
-
* Kazuaki Takase: Documents in Japanese.
|
136
|
-
* Tim Hermans: A bug report.
|
137
|
-
* Joe Francis: A suggestion.
|
138
|
-
* Tiago Fernandes: Bug reports.
|
139
|
-
* achemze: A suggestion.
|
140
|
-
* George Montana Harkin: A suggestion.
|
141
|
-
* Marc Dequènes: Bug reports.
|
142
|
-
* brad@lucky-dip.net: A bug report.
|
143
|
-
* Hideyuki Yasuda: Bug reports.
|
144
|
-
* zachwily: A bug report.
|
145
|
-
* syrius.ml@no-log.org: A bug report.
|
146
|
-
* Tim Hermans: A bug report.
|
147
|
-
* Anthony M. Martinez: Helped SASL options support
|
148
|
-
* ilusi0n.x: A bug report.
|
149
|
-
* projekttabla: A suggestion.
|
150
|
-
* christian.pennaforte: A bug report.
|
151
|
-
* planetmcd: A bug report.
|
152
|
-
* spoidar: Rails 3 support.
|
153
|
-
* Kris Wehner: Rails 2.3.8 support.
|
154
|
-
* Ryan Tandy: A test bug fix.
|
155
|
-
* rbq: A bug report.
|
data/Rakefile
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
|
-
require 'thread'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'hoe'
|
6
|
-
require 'find'
|
7
|
-
|
8
|
-
base_dir = File.expand_path(File.dirname(__FILE__))
|
9
|
-
$LOAD_PATH.unshift(File.join(base_dir, 'lib'))
|
10
|
-
require 'active_ldap'
|
11
|
-
|
12
|
-
truncate_base_dir = Proc.new do |x|
|
13
|
-
x.gsub(/\A#{Regexp.escape(base_dir + File::SEPARATOR)}/, '')
|
14
|
-
end
|
15
|
-
|
16
|
-
manifest = File.join(base_dir, "Manifest.txt")
|
17
|
-
manifest_contents = []
|
18
|
-
base_dir_included_components = %w(CHANGES COPYING LICENSE Manifest.txt
|
19
|
-
README Rakefile TODO)
|
20
|
-
excluded_components = %w(.svn .git .test-result .config doc log tmp
|
21
|
-
pkg html config.yaml database.yml ldap.yml)
|
22
|
-
excluded_suffixes = %w(.help .sqlite3)
|
23
|
-
white_list_paths =
|
24
|
-
[
|
25
|
-
"rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml",
|
26
|
-
"rails_generators/scaffold_active_ldap/templates/ldap.yml",
|
27
|
-
]
|
28
|
-
Find.find(base_dir + File::SEPARATOR) do |target|
|
29
|
-
target = truncate_base_dir[target]
|
30
|
-
components = target.split(File::SEPARATOR)
|
31
|
-
next if components.empty?
|
32
|
-
if components.size == 1 and !File.directory?(target)
|
33
|
-
next unless base_dir_included_components.include?(components[0])
|
34
|
-
end
|
35
|
-
unless white_list_paths.include?(target)
|
36
|
-
Find.prune if (excluded_components - components) != excluded_components
|
37
|
-
next if excluded_suffixes.include?(File.extname(target))
|
38
|
-
end
|
39
|
-
manifest_contents << target if File.file?(target)
|
40
|
-
end
|
41
|
-
|
42
|
-
File.open(manifest, "w") do |f|
|
43
|
-
f.puts manifest_contents.sort.join("\n")
|
44
|
-
end
|
45
|
-
at_exit do
|
46
|
-
FileUtils.rm_f(manifest)
|
47
|
-
end
|
48
|
-
|
49
|
-
# For Hoe's no user friendly default behavior. :<
|
50
|
-
File.open("README.txt", "w") {|file| file << "= Dummy README\n== XXX\n"}
|
51
|
-
FileUtils.cp("CHANGES", "History.txt")
|
52
|
-
at_exit do
|
53
|
-
FileUtils.rm_f("README.txt")
|
54
|
-
FileUtils.rm_f("History.txt")
|
55
|
-
end
|
56
|
-
|
57
|
-
ENV["VERSION"] ||= ActiveLdap::VERSION
|
58
|
-
version = ENV["VERSION"]
|
59
|
-
project = Hoe.spec('activeldap') do
|
60
|
-
self.version = version
|
61
|
-
self.rubyforge_name = 'ruby-activeldap'
|
62
|
-
self.author = ['Will Drewry', 'Kouhei Sutou']
|
63
|
-
self.email = ['redpig@dataspill.org', 'kou@cozmixng.org']
|
64
|
-
self.summary = 'ActiveLdap is a object-oriented API to LDAP'
|
65
|
-
self.url = 'http://rubyforge.org/projects/ruby-activeldap/'
|
66
|
-
self.test_globs = ['test/test_*.rb']
|
67
|
-
self.changes = self.paragraphs_of('CHANGES', 1..2).join("\n\n")
|
68
|
-
self.extra_deps = [
|
69
|
-
# ['ruby-ldap', '= 0.9.9'],
|
70
|
-
# ['net-ldap', '= 0.1.1'],
|
71
|
-
['activerecord', '~> 2.3.11'],
|
72
|
-
['locale', '= 2.0.5'],
|
73
|
-
['fast_gettext', '= 0.5.8'],
|
74
|
-
['gettext_i18n_rails', '= 0.2.2'],
|
75
|
-
]
|
76
|
-
self.remote_rdoc_dir = "doc"
|
77
|
-
self.rsync_args += " --chmod=Dg+ws,Fg+w"
|
78
|
-
self.description = String.new(<<-EOF)
|
79
|
-
'ActiveLdap' is a ruby extension library which provides a clean
|
80
|
-
objected oriented interface to the Ruby/LDAP library. It was inspired
|
81
|
-
by ActiveRecord. This is not nearly as clean or as flexible as
|
82
|
-
ActiveRecord, but it is still trivial to define new objects and manipulate
|
83
|
-
them with minimal difficulty.
|
84
|
-
EOF
|
85
|
-
end
|
86
|
-
|
87
|
-
project.spec.extra_rdoc_files = ["README", "CHANGES", "COPYING", "LICENSE"]
|
88
|
-
|
89
|
-
publish_docs_actions = task(:publish_docs).instance_variable_get("@actions")
|
90
|
-
original_project_name = nil
|
91
|
-
before_publish_docs = Proc.new do
|
92
|
-
original_project_name = project.name
|
93
|
-
project.name = "doc"
|
94
|
-
end
|
95
|
-
after_publish_docs = Proc.new do
|
96
|
-
project.name = original_project_name
|
97
|
-
end
|
98
|
-
publish_docs_actions.unshift(before_publish_docs)
|
99
|
-
publish_docs_actions.push(after_publish_docs)
|
100
|
-
|
101
|
-
|
102
|
-
rdoc_main = "lib/active_ldap.rb"
|
103
|
-
project.spec.rdoc_options.each do |option|
|
104
|
-
option.replace(rdoc_main) if option == "README.txt"
|
105
|
-
end
|
106
|
-
ObjectSpace.each_object(Rake::RDocTask) do |task|
|
107
|
-
task.main = rdoc_main if task.main == "README.txt"
|
108
|
-
task.rdoc_files = project.spec.require_paths + project.spec.extra_rdoc_files
|
109
|
-
end
|
110
|
-
|
111
|
-
begin
|
112
|
-
require "gettext_i18n_rails/tasks"
|
113
|
-
rescue LoadError
|
114
|
-
puts "gettext_i18n_rails is not installed, you probably should run 'rake gems:install' or 'bundle install'."
|
115
|
-
end
|
116
|
-
|
117
|
-
desc "Publish HTML to Web site."
|
118
|
-
task :publish_html do
|
119
|
-
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
120
|
-
host = "#{config["username"]}@rubyforge.org"
|
121
|
-
|
122
|
-
rsync_args = "-av --exclude '*.erb' --exclude '*.svg' --exclude .svn"
|
123
|
-
remote_dir = "/var/www/gforge-projects/#{project.rubyforge_name}/"
|
124
|
-
sh "rsync #{rsync_args} html/ #{host}:#{remote_dir}"
|
125
|
-
end
|
126
|
-
|
127
|
-
desc "Tag the current revision."
|
128
|
-
task :tag do
|
129
|
-
message = "Released ActiveLdap #{version}!"
|
130
|
-
sh 'git', 'tag', '-a', version, '-m', message
|
131
|
-
end
|
132
|
-
|
133
|
-
# vim: syntax=ruby
|
data/rails/README
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
= ActiveLdap plugin for Ruby on Rails
|
2
|
-
|
3
|
-
== Setup
|
4
|
-
|
5
|
-
You need to write RAILS_ROOT/config/ldap.yml like the following:
|
6
|
-
|
7
|
-
development:
|
8
|
-
host: 127.0.0.1
|
9
|
-
port: 389
|
10
|
-
base: dc=devel,dc=local,dc=net
|
11
|
-
bind_dn: cn=admin,dc=local,dc=net
|
12
|
-
password: secret
|
13
|
-
|
14
|
-
test:
|
15
|
-
host: 127.0.0.1
|
16
|
-
port: 389
|
17
|
-
base: dc=test,dc=local,dc=net
|
18
|
-
bind_dn: cn=admin,dc=local,dc=net
|
19
|
-
password: secret
|
20
|
-
|
21
|
-
production:
|
22
|
-
host: 127.0.0.1
|
23
|
-
port: 389
|
24
|
-
base: dc=production,dc=local,dc=net
|
25
|
-
bind_dn: cn=admin,dc=local,dc=net
|
26
|
-
password: secret
|
27
|
-
|
28
|
-
== Model
|
29
|
-
|
30
|
-
Here is some examples.
|
31
|
-
|
32
|
-
app/model/member.rb:
|
33
|
-
class Member < ActiveLdap::Base
|
34
|
-
ldap_mapping :dn_attribute => 'uid',
|
35
|
-
:classes => ['person', 'posixAccount']
|
36
|
-
belongs_to :primary_group, :class_name => "Group",
|
37
|
-
:foreign_key => "gidNumber", :primary_key => "gidNumber"
|
38
|
-
belongs_to :groups, :many => 'memberUid'
|
39
|
-
end
|
40
|
-
|
41
|
-
app/model/group.rb:
|
42
|
-
class Group < ActiveLdap::Base
|
43
|
-
ldap_mapping :dn_attribute => "cn", :classes => ['posixGroup']
|
44
|
-
has_many :members, :wrap => "memberUid"
|
45
|
-
has_many :primary_members,
|
46
|
-
:foreign_key => 'gidNumber',
|
47
|
-
:primary_key => 'gidNumber'
|
48
|
-
end
|
49
|
-
|
50
|
-
app/model/ou.rb:
|
51
|
-
class Ou < ActiveLdap::Base
|
52
|
-
ldap_mapping :prefix => "",
|
53
|
-
:classes => ["top", "organizationalUnit"]
|
54
|
-
end
|
data/rails/init.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require_library_or_gem 'active_ldap'
|
2
|
-
ActiveLdap::Base.logger ||= RAILS_DEFAULT_LOGGER
|
3
|
-
|
4
|
-
required_version = ["1", "1", "0"]
|
5
|
-
if (ActiveLdap::VERSION.split(".") <=> required_version) < 0
|
6
|
-
ActiveLdap::Base.class_eval do
|
7
|
-
format = _("You need ActiveLdap %s or later")
|
8
|
-
logger.error(format % required_version.join("."))
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
ldap_configuration_file = File.join(RAILS_ROOT, 'config', 'ldap.yml')
|
13
|
-
if File.exist?(ldap_configuration_file)
|
14
|
-
configurations = YAML.load(ERB.new(IO.read(ldap_configuration_file)).result)
|
15
|
-
ActiveLdap::Base.configurations = configurations
|
16
|
-
ActiveLdap::Base.setup_connection
|
17
|
-
else
|
18
|
-
ActiveLdap::Base.class_eval do
|
19
|
-
format = _("You should run 'script/generator scaffold_active_ldap' to make %s.")
|
20
|
-
logger.error(format % ldap_configuration_file)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class ::ActionView::Base
|
25
|
-
include ActiveLdap::Helper
|
26
|
-
end
|
27
|
-
|
28
|
-
require 'active_ldap/action_controller/ldap_benchmarking'
|
29
|
-
module ::ActionController
|
30
|
-
class Base
|
31
|
-
include ActiveLdap::ActionController::LdapBenchmarking
|
32
|
-
end
|
33
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'active_ldap'
|
2
|
-
|
3
|
-
class ModelActiveLdapGenerator < Rails::Generator::NamedBase
|
4
|
-
include ActiveLdap::GetTextSupport
|
5
|
-
|
6
|
-
default_options :dn_attribute => "cn", :classes => nil
|
7
|
-
|
8
|
-
def manifest
|
9
|
-
record do |m|
|
10
|
-
# Check for class naming collisions.
|
11
|
-
m.class_collisions class_path, class_name, "#{class_name}Test"
|
12
|
-
|
13
|
-
# Model and test directories.
|
14
|
-
m.directory File.join('app/models', class_path)
|
15
|
-
m.directory File.join('test/unit', class_path)
|
16
|
-
|
17
|
-
# Model class and unit test.
|
18
|
-
m.template('model_active_ldap.rb',
|
19
|
-
File.join('app/models', class_path, "#{file_name}.rb"),
|
20
|
-
:assigns => {:ldap_mapping => ldap_mapping})
|
21
|
-
m.template('unit_test.rb',
|
22
|
-
File.join('test/unit', class_path, "#{file_name}_test.rb"))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
def add_options!(opt)
|
28
|
-
opt.separator ''
|
29
|
-
opt.separator 'Options:'
|
30
|
-
opt.on("--dn-attribute=ATTRIBUTE",
|
31
|
-
_("Use ATTRIBUTE as default DN attribute for " \
|
32
|
-
"instances of this model"),
|
33
|
-
_("(default: %s)") % default_options[:dn_attribute]) do |attribute|
|
34
|
-
options[:dn_attribute] = attribute
|
35
|
-
end
|
36
|
-
|
37
|
-
opt.on("--prefix=PREFIX",
|
38
|
-
_("Use PREFIX as prefix for this model"),
|
39
|
-
_("(default: %s)") % "ou=Names") do |prefix|
|
40
|
-
options[:prefix] = prefix
|
41
|
-
end
|
42
|
-
|
43
|
-
opt.on("--classes=CLASS,CLASS,...",
|
44
|
-
Array,
|
45
|
-
"Use CLASSES as required objectClass for instances of this model",
|
46
|
-
"(default: %s)" % default_options[:classes]) do |classes|
|
47
|
-
options[:classes] = classes
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def prefix
|
52
|
-
options[:prefix] || default_prefix
|
53
|
-
end
|
54
|
-
|
55
|
-
def default_prefix
|
56
|
-
"ou=#{name.demodulize.pluralize}"
|
57
|
-
end
|
58
|
-
|
59
|
-
def ldap_mapping(indent=' ')
|
60
|
-
mapping = "ldap_mapping "
|
61
|
-
mapping_options = [":dn_attribute => #{options[:dn_attribute].dump}"]
|
62
|
-
mapping_options << ":prefix => #{prefix.dump}"
|
63
|
-
if options[:classes]
|
64
|
-
mapping_options << ":classes => #{options[:classes].inspect}"
|
65
|
-
end
|
66
|
-
mapping_options = mapping_options.join(",\n#{indent}#{' ' * mapping.size}")
|
67
|
-
"#{indent}#{mapping}#{mapping_options}"
|
68
|
-
end
|
69
|
-
end
|