ruby-ldap 0.9.11 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/ChangeLog +18 -0
  2. data/FAQ +5 -9
  3. data/NOTES +29 -0
  4. data/README +22 -18
  5. data/TODO +10 -0
  6. data/clientauth.c +605 -0
  7. data/conn.c +24 -1
  8. data/entry.c +9 -9
  9. data/extconf.rb +70 -29
  10. data/ldap.c +67 -0
  11. data/lib/ldap/control.rb +3 -3
  12. data/lib/ldap/ldif.rb +264 -269
  13. data/lib/ldap/schema.rb +39 -33
  14. data/mod.c +7 -3
  15. data/rbldap.h +8 -6
  16. data/test/cookbooks/apt/metadata.rb +13 -0
  17. data/test/cookbooks/apt/providers/repository.rb +73 -0
  18. data/test/cookbooks/apt/recipes/cacher-client.rb +44 -0
  19. data/test/cookbooks/apt/recipes/cacher.rb +45 -0
  20. data/test/cookbooks/apt/recipes/default.rb +50 -0
  21. data/test/cookbooks/apt/resources/repository.rb +30 -0
  22. data/test/cookbooks/nginx/attributes/default.rb +35 -0
  23. data/test/cookbooks/nginx/definitions/nginx_site.rb +35 -0
  24. data/test/cookbooks/nginx/metadata.rb +86 -0
  25. data/test/cookbooks/nginx/recipes/default.rb +56 -0
  26. data/test/cookbooks/nginx/recipes/source.rb +143 -0
  27. data/test/cookbooks/openldap/attributes/default.rb +61 -0
  28. data/test/cookbooks/openldap/metadata.rb +99 -0
  29. data/test/cookbooks/openldap/recipes/auth.rb +70 -0
  30. data/test/cookbooks/openldap/recipes/client.rb +28 -0
  31. data/test/cookbooks/openldap/recipes/default.rb +18 -0
  32. data/test/cookbooks/openldap/recipes/server.rb +110 -0
  33. data/test/cookbooks/postgresql/attributes/default.rb +68 -0
  34. data/test/cookbooks/postgresql/metadata.rb +15 -0
  35. data/test/cookbooks/postgresql/recipes/client.rb +27 -0
  36. data/test/cookbooks/postgresql/recipes/default.rb +20 -0
  37. data/test/cookbooks/postgresql/recipes/server.rb +36 -0
  38. data/test/cookbooks/postgresql/recipes/server_debian.rb +51 -0
  39. data/test/cookbooks/postgresql/recipes/server_redhat.rb +84 -0
  40. data/test/cookbooks/sqlite/metadata.rb +11 -0
  41. data/test/cookbooks/sqlite/recipes/default.rb +26 -0
  42. data/test/cookbooks/vagrant_main/recipes/default.rb +12 -0
  43. data/test/moz_cert.rb +105 -0
  44. data/test/setup.rb +2 -2
  45. data/win/wldap32.def +257 -0
  46. metadata +78 -55
@@ -0,0 +1,84 @@
1
+ #/postgresql.conf.
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: server
4
+ #
5
+ # Copyright 2009-2010, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include_recipe "postgresql::client"
21
+
22
+ # Create a group and user like the package will.
23
+ # Otherwise the templates fail.
24
+
25
+ group "postgres" do
26
+ # Workaround lack of option for -r and -o...
27
+ group_name "-r -o postgres"
28
+ not_if { Etc.getgrnam("postgres") }
29
+ gid 26
30
+ end
31
+
32
+ user "postgres" do
33
+ # Workaround lack of option for -M and -n...
34
+ username "-M -n postgres"
35
+ not_if { Etc.getpwnam("postgres") }
36
+ shell "/bin/bash"
37
+ comment "PostgreSQL Server"
38
+ home "/var/lib/pgsql"
39
+ gid "postgres"
40
+ system true
41
+ uid 26
42
+ supports :non_unique => true
43
+ end
44
+
45
+ package "postgresql" do
46
+ case node.platform
47
+ when "redhat","centos"
48
+ package_name "postgresql#{node.postgresql.version.split('.').join}"
49
+ else
50
+ package_name "postgresql"
51
+ end
52
+ end
53
+
54
+ case node.platform
55
+ when "redhat","centos"
56
+ package "postgresql#{node.postgresql.version.split('.').join}-server"
57
+ when "fedora","suse"
58
+ package "postgresql-server"
59
+ end
60
+
61
+ execute "/sbin/service postgresql initdb" do
62
+ not_if { ::FileTest.exist?(File.join(node.postgresql.dir, "PG_VERSION")) }
63
+ end
64
+
65
+ service "postgresql" do
66
+ supports :restart => true, :status => true, :reload => true
67
+ action [:enable, :start]
68
+ end
69
+
70
+ template "#{node[:postgresql][:dir]}/pg_hba.conf" do
71
+ source "redhat.pg_hba.conf.erb"
72
+ owner "postgres"
73
+ group "postgres"
74
+ mode 0600
75
+ notifies :reload, resources(:service => "postgresql")
76
+ end
77
+
78
+ template "#{node[:postgresql][:dir]}/postgresql.conf" do
79
+ source "redhat.postgresql.conf.erb"
80
+ owner "postgres"
81
+ group "postgres"
82
+ mode 0600
83
+ notifies :restart, resources(:service => "postgresql")
84
+ end
@@ -0,0 +1,11 @@
1
+ maintainer "Opscode, Inc."
2
+ maintainer_email "cookbooks@opscode.com"
3
+ license "Apache 2.0"
4
+ description "Installs sqlite"
5
+ version "0.7.1"
6
+
7
+ recipe "sqlite", "Installs sqlite"
8
+
9
+ %w{ubuntu debian}.each do |os|
10
+ supports os
11
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # Cookbook Name:: sqlite
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2009, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ package "sqlite3" do
21
+ action :upgrade
22
+ end
23
+
24
+ package "sqlite3-doc" do
25
+ action :upgrade
26
+ end
@@ -0,0 +1,12 @@
1
+ # vagrant_main cookbook
2
+ # This cookbook includes and sets up a server with openldap.
3
+ #
4
+ require_recipe 'apt'
5
+ require_recipe 'openldap::server'
6
+
7
+ execute[apt-get-update]
8
+
9
+ # require_recipe 'nginx'
10
+ # include_recipe "openldap::server"
11
+ # require_recipe 'postgresql'
12
+ # require_recipe 'sqlite'
data/test/moz_cert.rb ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ # gem 'ruby-ldap', '~> 0.9.12'
5
+ require 'ldap'
6
+ require 'optparse'
7
+ require 'pp'
8
+
9
+ options = {
10
+ :host => 'localhost',
11
+ :port => '389',
12
+ :scope => 'base',
13
+ :filter => '(objectclass=*)',
14
+ :key_pw => ''
15
+ }
16
+
17
+ optparse = OptionParser.new do |opts|
18
+ opts.on("-P", "--certpath [CERTFILE]", "cert8 path") do |cp|
19
+ options[:cp] = cp
20
+ end
21
+
22
+ opts.on("-N", "--certname [CERTNAME]", "certificate name") do |opt|
23
+ options[:cn] = opt
24
+ end
25
+
26
+ opts.on("-W", "--keypassword PASSWORD", "key password") do |opt|
27
+ options[:key_pw] = opt
28
+ end
29
+
30
+ opts.on("-h", "--host HOST", "server hostname") do |host|
31
+ options[:host] = host
32
+ end
33
+
34
+ opts.on("-p", "--port PORT", "server port") do |opt|
35
+ options[:port] = opt
36
+ end
37
+
38
+ opts.on("-b", "--base [BASE]", "search base") do |opt|
39
+ options[:base] = opt
40
+ end
41
+
42
+ opts.on("-s", "--scope SCOPE", "search scope") do |opt|
43
+ options[:scope] = opt
44
+ end
45
+
46
+ opts.on("-f", "--filter FILTER", "search filter") do |opt|
47
+ options[:filter] = opt
48
+ end
49
+
50
+ opts.on("-a", "--attributes ATTRS", "attrs to return") do |opt|
51
+ options[:attrs] = opt.split(/ *, */)
52
+ end
53
+
54
+ opts.on("--help") do |opt|
55
+ puts opts
56
+ exit 0
57
+ end
58
+ end
59
+
60
+ optparse.parse!
61
+
62
+ required_keys = [:cp, :cn, :base]
63
+ if (required_keys - options.keys).length > 0
64
+ puts "Some options are missing."
65
+ puts optparse
66
+ exit 1
67
+ end
68
+
69
+ options[:scope] = case options[:scope]
70
+ when "sub"
71
+ LDAP::LDAP_SCOPE_SUBTREE
72
+ when "one"
73
+ LDAP::LDAP_SCOPE_ONELEVEL
74
+ else
75
+ LDAP::LDAP_SCOPE_BASE
76
+ end
77
+
78
+ raise ArgumentError.new("cert file's missing") unless (File.exists? options[:cp])
79
+
80
+ #Signal.trap("INT") { puts("INT"); exit(2); }
81
+
82
+ # Connect
83
+ conn = LDAP::SSLAuthConn.new(options[:host], options[:port].to_i, true,
84
+ File.expand_path(options[:cp]), options[:cn], options[:key_pw])
85
+ conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
86
+
87
+
88
+ # oid = '2.16.840.1.113730.3.4.15' # get bound DN
89
+ # bindctls = [LDAP::Control.new(oid, "", false)]
90
+ # pass bindctls as argument to bind()
91
+
92
+ begin
93
+ conn.bind
94
+
95
+ results = {}
96
+ conn.search(options[:base], options[:scope], options[:filter], options[:attrs], false, 10) do |entry|
97
+ results[entry.dn] = entry.to_hash
98
+ end
99
+
100
+ pp results
101
+ rescue LDAP::ResultError => e
102
+ puts "error: #{e.to_s}"
103
+ end
104
+
105
+ exit 0
data/test/setup.rb CHANGED
@@ -13,7 +13,7 @@ class TC_LDAPTest < Test::Unit::TestCase
13
13
  # Get the LDAP host and base DN from /etc/ldap.conf.
14
14
  def setup
15
15
  unless @@conn && @@conn.bound?
16
- File.open( '/etc/openldap/slapd.conf' ) do |f|
16
+ File.open( '/etc/ldap.conf' ) do |f|
17
17
  while line = f.gets
18
18
  if line =~ /^host\s+(\S+)$/
19
19
  @@host = $1
@@ -33,6 +33,6 @@ class TC_LDAPTest < Test::Unit::TestCase
33
33
  end
34
34
  end
35
35
 
36
- #undef_method :default_test
36
+ undef_method :default_test
37
37
 
38
38
  end
data/win/wldap32.def ADDED
@@ -0,0 +1,257 @@
1
+ ; wldap32.def
2
+ ;
3
+ ; $Id: wldap32.def,v 1.3 2006/04/19 19:33:00 ianmacd Exp $
4
+ ;
5
+ ; Exports for WLDAP32 DLL
6
+ ;
7
+ ; Created by Chris Scharf <scharfie@gmail.com> using instructions from:
8
+ ;
9
+ ; http://support.microsoft.com/kb/q131313/
10
+
11
+ LIBRARY WLDAP32
12
+ EXPORTS
13
+ LdapGetLastError
14
+ LdapMapErrorToWin32
15
+ LdapUTF8ToUnicode
16
+ LdapUnicodeToUTF8
17
+ ber_alloc_t
18
+ ber_bvdup
19
+ ber_bvecfree
20
+ ber_bvfree
21
+ ber_first_element
22
+ ber_flatten
23
+ ber_free
24
+ ber_init
25
+ ber_next_element
26
+ ber_peek_tag
27
+ ber_printf
28
+ ber_scanf
29
+ ber_skip_tag
30
+ cldap_open
31
+ cldap_openA
32
+ cldap_openW
33
+ ldap_abandon
34
+ ldap_add
35
+ ldap_addA
36
+ ldap_addW
37
+ ldap_add_ext
38
+ ldap_add_extA
39
+ ldap_add_extW
40
+ ldap_add_ext_s
41
+ ldap_add_ext_sA
42
+ ldap_add_ext_sW
43
+ ldap_add_s
44
+ ldap_add_sA
45
+ ldap_add_sW
46
+ ldap_bind
47
+ ldap_bindA
48
+ ldap_bindW
49
+ ldap_bind_s
50
+ ldap_bind_sA
51
+ ldap_bind_sW
52
+ ldap_check_filterA
53
+ ldap_check_filterW
54
+ ldap_cleanup
55
+ ldap_close_extended_op
56
+ ldap_compare
57
+ ldap_compareA
58
+ ldap_compareW
59
+ ldap_compare_ext
60
+ ldap_compare_extA
61
+ ldap_compare_extW
62
+ ldap_compare_ext_s
63
+ ldap_compare_ext_sA
64
+ ldap_compare_ext_sW
65
+ ldap_compare_s
66
+ ldap_compare_sA
67
+ ldap_compare_sW
68
+ ldap_conn_from_msg
69
+ ldap_connect
70
+ ldap_control_free
71
+ ldap_control_freeA
72
+ ldap_control_freeW
73
+ ldap_controls_free
74
+ ldap_controls_freeA
75
+ ldap_controls_freeW
76
+ ldap_count_entries
77
+ ldap_count_references
78
+ ldap_count_values
79
+ ldap_count_valuesA
80
+ ldap_count_valuesW
81
+ ldap_count_values_len
82
+ ldap_create_page_control
83
+ ldap_create_page_controlA
84
+ ldap_create_page_controlW
85
+ ldap_create_sort_control
86
+ ldap_create_sort_controlA
87
+ ldap_create_sort_controlW
88
+ ldap_create_vlv_controlA
89
+ ldap_create_vlv_controlW
90
+ ldap_delete
91
+ ldap_deleteA
92
+ ldap_deleteW
93
+ ldap_delete_ext
94
+ ldap_delete_extA
95
+ ldap_delete_extW
96
+ ldap_delete_ext_s
97
+ ldap_delete_ext_sA
98
+ ldap_delete_ext_sW
99
+ ldap_delete_s
100
+ ldap_delete_sA
101
+ ldap_delete_sW
102
+ ldap_dn2ufn
103
+ ldap_dn2ufnA
104
+ ldap_dn2ufnW
105
+ ldap_encode_sort_controlA
106
+ ldap_encode_sort_controlW
107
+ ldap_err2string
108
+ ldap_err2stringA
109
+ ldap_err2stringW
110
+ ldap_escape_filter_element
111
+ ldap_escape_filter_elementA
112
+ ldap_escape_filter_elementW
113
+ ldap_explode_dn
114
+ ldap_explode_dnA
115
+ ldap_explode_dnW
116
+ ldap_extended_operation
117
+ ldap_extended_operationA
118
+ ldap_extended_operationW
119
+ ldap_extended_operation_sA
120
+ ldap_extended_operation_sW
121
+ ldap_first_attribute
122
+ ldap_first_attributeA
123
+ ldap_first_attributeW
124
+ ldap_first_entry
125
+ ldap_first_reference
126
+ ldap_free_controls
127
+ ldap_free_controlsA
128
+ ldap_free_controlsW
129
+ ldap_get_dn
130
+ ldap_get_dnA
131
+ ldap_get_dnW
132
+ ldap_get_next_page
133
+ ldap_get_next_page_s
134
+ ldap_get_option
135
+ ldap_get_optionA
136
+ ldap_get_optionW
137
+ ldap_get_paged_count
138
+ ldap_get_values
139
+ ldap_get_valuesA
140
+ ldap_get_valuesW
141
+ ldap_get_values_len
142
+ ldap_get_values_lenA
143
+ ldap_get_values_lenW
144
+ ldap_init
145
+ ldap_initA
146
+ ldap_initW
147
+ ldap_memfree
148
+ ldap_memfreeA
149
+ ldap_memfreeW
150
+ ldap_modify
151
+ ldap_modifyA
152
+ ldap_modifyW
153
+ ldap_modify_ext
154
+ ldap_modify_extA
155
+ ldap_modify_extW
156
+ ldap_modify_ext_s
157
+ ldap_modify_ext_sA
158
+ ldap_modify_ext_sW
159
+ ldap_modify_s
160
+ ldap_modify_sA
161
+ ldap_modify_sW
162
+ ldap_modrdn
163
+ ldap_modrdn2
164
+ ldap_modrdn2A
165
+ ldap_modrdn2W
166
+ ldap_modrdn2_s
167
+ ldap_modrdn2_sA
168
+ ldap_modrdn2_sW
169
+ ldap_modrdnA
170
+ ldap_modrdnW
171
+ ldap_modrdn_s
172
+ ldap_modrdn_sA
173
+ ldap_modrdn_sW
174
+ ldap_msgfree
175
+ ldap_next_attribute
176
+ ldap_next_attributeA
177
+ ldap_next_attributeW
178
+ ldap_next_entry
179
+ ldap_next_reference
180
+ ldap_open
181
+ ldap_openA
182
+ ldap_openW
183
+ ldap_parse_extended_resultA
184
+ ldap_parse_extended_resultW
185
+ ldap_parse_page_control
186
+ ldap_parse_page_controlA
187
+ ldap_parse_page_controlW
188
+ ldap_parse_reference
189
+ ldap_parse_referenceA
190
+ ldap_parse_referenceW
191
+ ldap_parse_result
192
+ ldap_parse_resultA
193
+ ldap_parse_resultW
194
+ ldap_parse_sort_control
195
+ ldap_parse_sort_controlA
196
+ ldap_parse_sort_controlW
197
+ ldap_parse_vlv_controlA
198
+ ldap_parse_vlv_controlW
199
+ ldap_perror
200
+ ldap_rename_ext
201
+ ldap_rename_extA
202
+ ldap_rename_extW
203
+ ldap_rename_ext_s
204
+ ldap_rename_ext_sA
205
+ ldap_rename_ext_sW
206
+ ldap_result
207
+ ldap_result2error
208
+ ldap_sasl_bindA
209
+ ldap_sasl_bindW
210
+ ldap_sasl_bind_sA
211
+ ldap_sasl_bind_sW
212
+ ldap_search
213
+ ldap_searchA
214
+ ldap_searchW
215
+ ldap_search_abandon_page
216
+ ldap_search_ext
217
+ ldap_search_extA
218
+ ldap_search_extW
219
+ ldap_search_ext_s
220
+ ldap_search_ext_sA
221
+ ldap_search_ext_sW
222
+ ldap_search_init_page
223
+ ldap_search_init_pageA
224
+ ldap_search_init_pageW
225
+ ldap_search_s
226
+ ldap_search_sA
227
+ ldap_search_sW
228
+ ldap_search_st
229
+ ldap_search_stA
230
+ ldap_search_stW
231
+ ldap_set_dbg_flags
232
+ ldap_set_dbg_routine
233
+ ldap_set_option
234
+ ldap_set_optionA
235
+ ldap_set_optionW
236
+ ldap_simple_bind
237
+ ldap_simple_bindA
238
+ ldap_simple_bindW
239
+ ldap_simple_bind_s
240
+ ldap_simple_bind_sA
241
+ ldap_simple_bind_sW
242
+ ldap_sslinit
243
+ ldap_sslinitA
244
+ ldap_sslinitW
245
+ ldap_start_tls_sA
246
+ ldap_start_tls_sW
247
+ ldap_startup
248
+ ldap_stop_tls_s
249
+ ldap_ufn2dn
250
+ ldap_ufn2dnA
251
+ ldap_ufn2dnW
252
+ ldap_unbind
253
+ ldap_unbind_s
254
+ ldap_value_free
255
+ ldap_value_freeA
256
+ ldap_value_freeW
257
+ ldap_value_free_len