activeldap 5.2.4 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,26 @@
1
- h1. Rails
1
+ # Rails
2
2
 
3
3
  ActiveLdap supports Rails 4.0 or later.
4
4
 
5
- h2. Install
5
+ ## Install
6
6
 
7
7
  To install, simply add the following code to your Gemfile:
8
8
 
9
- <pre>
9
+ ```ruby
10
10
  gem 'activeldap', :require => 'active_ldap/railtie'
11
- </pre>
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
- <pre>
16
+ ```ruby
17
17
  gem 'ruby-ldap'
18
- </pre>
18
+ ```
19
19
 
20
20
  Bundler will install the gems automatically when you run
21
- 'bundle install'.
21
+ `bundle install`.
22
22
 
23
- h2. Configuration
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
- <pre class="command">
35
+ ```console
36
36
  % script/rails generate active_ldap:scaffold
37
- </pre>
37
+ ```
38
38
 
39
39
  You need to modify 'config/ldap.yml' generated by
40
- active_ldap:scaffold. For instance, the development entry
40
+ `active_ldap:scaffold`. For instance, the development entry
41
41
  would look something like the following:
42
42
 
43
- <pre>
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
- </pre>
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 'config/application.rb':
59
- <pre>config.app_generators.orm :active_ldap</pre>
57
+ to skip `active_ldap prefix` in `config/application.rb`:
60
58
 
61
- h2. Model
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
- <pre class="command">
77
+ ```console
67
78
  % script/rails generate active_ldap:model User --dn-attribute uid --classes person PosixAccount
68
- </pre>
79
+ ```
69
80
 
70
81
  It generates the following app/model/user.rb:
71
82
 
72
- <pre>
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
- </pre>
89
+ ```
79
90
 
80
91
  You can add relationships by modifying app/model/user.rb:
81
92
 
82
- <pre>
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
- </pre>
105
+ ```
95
106
 
96
107
  You can also generate a Group model by the following command:
97
108
 
98
- <pre class="command">
109
+ ```console
99
110
  % script/rails generate active_ldap:model Group --classes PosixGroup
100
- </pre>
111
+ ```
101
112
 
102
113
  app/model/group.rb:
103
114
 
104
- <pre>
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
- </pre>
121
+ ```
111
122
 
112
123
  You can add relationships by modifying app/model/group.rb:
113
124
 
114
- <pre>
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
- </pre>
138
+ ```
128
139
 
129
140
  You can also generate a Ou model by the following command:
130
141
 
131
- <pre class="command">
142
+ ```console
132
143
  % script/rails generate active_ldap:model Ou --prefix '' --classes organizationalUnit
133
- </pre>
144
+ ```
134
145
 
135
- <pre>
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
- </pre>
152
+ ```