activeldap 4.0.5 → 6.1.0
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.
- checksums.yaml +5 -5
- data/.yardopts +3 -1
- data/doc/text/development.md +26 -0
- data/doc/text/{news.textile → news.md} +451 -241
- data/doc/text/{rails.textile → rails.md} +44 -33
- data/doc/text/{tutorial.textile → tutorial.md} +177 -185
- data/lib/active_ldap/adapter/base.rb +40 -17
- data/lib/active_ldap/adapter/jndi.rb +21 -9
- data/lib/active_ldap/adapter/jndi_connection.rb +83 -20
- data/lib/active_ldap/adapter/ldap.rb +50 -28
- data/lib/active_ldap/adapter/ldap_ext.rb +32 -13
- data/lib/active_ldap/adapter/net_ldap.rb +26 -24
- data/lib/active_ldap/associations.rb +5 -5
- data/lib/active_ldap/attribute_methods/before_type_cast.rb +1 -1
- data/lib/active_ldap/attribute_methods/dirty.rb +4 -7
- data/lib/active_ldap/attribute_methods/query.rb +1 -1
- data/lib/active_ldap/attribute_methods/read.rb +5 -1
- data/lib/active_ldap/attribute_methods/write.rb +1 -1
- data/lib/active_ldap/attribute_methods.rb +1 -2
- data/lib/active_ldap/base.rb +61 -14
- data/lib/active_ldap/callbacks.rb +7 -8
- data/lib/active_ldap/configuration.rb +27 -3
- data/lib/active_ldap/connection.rb +4 -22
- data/lib/active_ldap/distinguished_name.rb +1 -1
- data/lib/active_ldap/human_readable.rb +5 -4
- data/lib/active_ldap/operations.rb +24 -4
- data/lib/active_ldap/persistence.rb +3 -2
- data/lib/active_ldap/populate.rb +5 -3
- data/lib/active_ldap/railties/controller_runtime.rb +1 -2
- data/lib/active_ldap/schema/syntaxes.rb +8 -4
- data/lib/active_ldap/validations.rb +12 -4
- data/lib/active_ldap/version.rb +1 -1
- data/lib/active_ldap.rb +0 -7
- data/po/en/active-ldap.po +2 -2
- data/po/ja/active-ldap.po +3 -3
- data/test/add-phonetic-attribute-options-to-slapd.ldif +3 -3
- data/test/al-test-utils.rb +125 -38
- data/test/command.rb +13 -16
- data/test/enable-dynamic-groups.ldif +22 -0
- data/test/enable-start-tls.ldif +27 -0
- data/test/run-test.rb +0 -4
- data/test/test_base.rb +223 -22
- data/test/test_base_per_instance.rb +33 -1
- data/test/test_callback.rb +10 -8
- data/test/test_connection.rb +4 -0
- data/test/test_connection_per_class.rb +34 -0
- data/test/test_dn.rb +7 -0
- data/test/test_entry.rb +1 -0
- data/test/test_find.rb +14 -3
- data/test/test_supported_control.rb +1 -1
- data/test/test_syntax.rb +5 -0
- data/test/test_validation.rb +28 -15
- metadata +23 -24
- data/README.textile +0 -141
- data/doc/text/development.textile +0 -54
- data/lib/active_ldap/timeout.rb +0 -75
- data/lib/active_ldap/timeout_stub.rb +0 -17
@@ -1,26 +1,26 @@
|
|
1
|
-
|
1
|
+
# Rails
|
2
2
|
|
3
3
|
ActiveLdap supports Rails 4.0 or later.
|
4
4
|
|
5
|
-
|
5
|
+
## Install
|
6
6
|
|
7
7
|
To install, simply add the following code to your Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
10
|
gem 'activeldap', :require => 'active_ldap/railtie'
|
11
|
-
|
11
|
+
```
|
12
12
|
|
13
13
|
You should also depend on an LDAP adapter such as Net::LDAP
|
14
14
|
or Ruby/LDAP. The following example uses Ruby/LDAP:
|
15
15
|
|
16
|
-
|
16
|
+
```ruby
|
17
17
|
gem 'ruby-ldap'
|
18
|
-
|
18
|
+
```
|
19
19
|
|
20
20
|
Bundler will install the gems automatically when you run
|
21
|
-
|
21
|
+
`bundle install`.
|
22
22
|
|
23
|
-
|
23
|
+
## Configuration
|
24
24
|
|
25
25
|
You can use a LDAP configuration per environment. They are in
|
26
26
|
a file named 'ldap.yml' in the config directory of your
|
@@ -32,54 +32,65 @@ development, test, and production environments.
|
|
32
32
|
|
33
33
|
You can generate 'config/ldap.yml' by the following command:
|
34
34
|
|
35
|
-
|
35
|
+
```console
|
36
36
|
% script/rails generate active_ldap:scaffold
|
37
|
-
|
37
|
+
```
|
38
38
|
|
39
39
|
You need to modify 'config/ldap.yml' generated by
|
40
|
-
active_ldap:scaffold
|
40
|
+
`active_ldap:scaffold`. For instance, the development entry
|
41
41
|
would look something like the following:
|
42
42
|
|
43
|
-
|
44
|
-
!!!plain
|
43
|
+
```yaml
|
45
44
|
development:
|
46
45
|
host: 127.0.0.1
|
47
46
|
port: 389
|
48
47
|
base: dc=localhost
|
49
48
|
bind_dn: cn=admin,dc=localhost
|
50
49
|
password: secret
|
51
|
-
|
50
|
+
```
|
52
51
|
|
53
52
|
When your application starts up,
|
54
53
|
ActiveLdap::Base.setup_connection will be called with the
|
55
54
|
parameters specified for your current environment.
|
56
55
|
|
57
56
|
You can replace default orm generators with gems one
|
58
|
-
to skip active_ldap prefix in
|
59
|
-
<pre>config.app_generators.orm :active_ldap</pre>
|
57
|
+
to skip `active_ldap prefix` in `config/application.rb`:
|
60
58
|
|
61
|
-
|
59
|
+
```ruby
|
60
|
+
config.app_generators.orm :active_ldap
|
61
|
+
```
|
62
|
+
|
63
|
+
Concurrency is now enabled by default to ensure thread safe searches and modifications. This can
|
64
|
+
still be disabled if desired.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
# config/initializers/active_ldap.rb
|
68
|
+
|
69
|
+
ActiveLdap::Base.allow_concurrency = false
|
70
|
+
```
|
71
|
+
|
72
|
+
## Model
|
62
73
|
|
63
74
|
You can generate a User model that represents entries under
|
64
75
|
ou=Users by the following command:
|
65
76
|
|
66
|
-
|
77
|
+
```console
|
67
78
|
% script/rails generate active_ldap:model User --dn-attribute uid --classes person PosixAccount
|
68
|
-
|
79
|
+
```
|
69
80
|
|
70
81
|
It generates the following app/model/user.rb:
|
71
82
|
|
72
|
-
|
83
|
+
```ruby
|
73
84
|
class User < ActiveLdap::Base
|
74
85
|
ldap_mapping :dn_attribute => "uid",
|
75
86
|
:prefix => "ou=Users",
|
76
87
|
:classes => ["person", "PosixAccount"]
|
77
88
|
end
|
78
|
-
|
89
|
+
```
|
79
90
|
|
80
91
|
You can add relationships by modifying app/model/user.rb:
|
81
92
|
|
82
|
-
|
93
|
+
```ruby
|
83
94
|
class User < ActiveLdap::Base
|
84
95
|
ldap_mapping :dn_attribute => 'uid',
|
85
96
|
:prefix => "ou=Users",
|
@@ -91,27 +102,27 @@ class User < ActiveLdap::Base
|
|
91
102
|
belongs_to :groups,
|
92
103
|
:many => 'memberUid'
|
93
104
|
end
|
94
|
-
|
105
|
+
```
|
95
106
|
|
96
107
|
You can also generate a Group model by the following command:
|
97
108
|
|
98
|
-
|
109
|
+
```console
|
99
110
|
% script/rails generate active_ldap:model Group --classes PosixGroup
|
100
|
-
|
111
|
+
```
|
101
112
|
|
102
113
|
app/model/group.rb:
|
103
114
|
|
104
|
-
|
115
|
+
```ruby
|
105
116
|
class Group < ActiveLdap::Base
|
106
117
|
ldap_mapping :dn_attribute => "cn",
|
107
118
|
:prefix => "ou=Groups",
|
108
119
|
:classes => ["PosixGroup"]
|
109
120
|
end
|
110
|
-
|
121
|
+
```
|
111
122
|
|
112
123
|
You can add relationships by modifying app/model/group.rb:
|
113
124
|
|
114
|
-
|
125
|
+
```ruby
|
115
126
|
class Group < ActiveLdap::Base
|
116
127
|
ldap_mapping :dn_attribute => "cn",
|
117
128
|
:prefix => "ou=Groups",
|
@@ -124,18 +135,18 @@ class Group < ActiveLdap::Base
|
|
124
135
|
:foreign_key => "gidNumber",
|
125
136
|
:primary_key => "gidNumber"
|
126
137
|
end
|
127
|
-
|
138
|
+
```
|
128
139
|
|
129
140
|
You can also generate a Ou model by the following command:
|
130
141
|
|
131
|
-
|
142
|
+
```console
|
132
143
|
% script/rails generate active_ldap:model Ou --prefix '' --classes organizationalUnit
|
133
|
-
|
144
|
+
```
|
134
145
|
|
135
|
-
|
146
|
+
```ruby
|
136
147
|
class Ou < ActiveLdap::Base
|
137
148
|
ldap_mapping :dn_attribute => "cn",
|
138
149
|
:prefix => "",
|
139
150
|
:classes => ["organizationalUnit"]
|
140
151
|
end
|
141
|
-
|
152
|
+
```
|