ruby-activeldap 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/test/test_adapter.rb +17 -0
  2. data/test/test_associations.rb +19 -0
  3. data/test/test_attributes.rb +2 -1
  4. data/test/test_base.rb +28 -1
  5. data/test/test_base_per_instance.rb +2 -1
  6. data/test/test_callback.rb +2 -2
  7. data/test/test_connection.rb +2 -1
  8. data/test/test_connection_per_dn.rb +81 -0
  9. data/test/test_dn.rb +3 -2
  10. data/test/test_find.rb +35 -1
  11. data/test/test_object_class.rb +12 -1
  12. data/test/test_reflection.rb +16 -10
  13. data/test/test_schema.rb +141 -2
  14. data/test/test_user.rb +14 -4
  15. metadata +7 -104
  16. data/CHANGES +0 -397
  17. data/COPYING +0 -340
  18. data/LICENSE +0 -58
  19. data/Manifest.txt +0 -99
  20. data/README +0 -85
  21. data/Rakefile +0 -70
  22. data/TODO +0 -23
  23. data/benchmark/bench-al.rb +0 -152
  24. data/examples/config.yaml.example +0 -5
  25. data/examples/example.der +0 -0
  26. data/examples/example.jpg +0 -0
  27. data/examples/groupadd +0 -41
  28. data/examples/groupdel +0 -35
  29. data/examples/groupls +0 -49
  30. data/examples/groupmod +0 -42
  31. data/examples/lpasswd +0 -55
  32. data/examples/objects/group.rb +0 -13
  33. data/examples/objects/ou.rb +0 -4
  34. data/examples/objects/user.rb +0 -20
  35. data/examples/ouadd +0 -38
  36. data/examples/useradd +0 -45
  37. data/examples/useradd-binary +0 -50
  38. data/examples/userdel +0 -34
  39. data/examples/userls +0 -50
  40. data/examples/usermod +0 -42
  41. data/examples/usermod-binary-add +0 -47
  42. data/examples/usermod-binary-add-time +0 -51
  43. data/examples/usermod-binary-del +0 -48
  44. data/examples/usermod-lang-add +0 -43
  45. data/lib/active_ldap.rb +0 -964
  46. data/lib/active_ldap/adapter/base.rb +0 -461
  47. data/lib/active_ldap/adapter/ldap.rb +0 -232
  48. data/lib/active_ldap/adapter/ldap_ext.rb +0 -69
  49. data/lib/active_ldap/adapter/net_ldap.rb +0 -288
  50. data/lib/active_ldap/adapter/net_ldap_ext.rb +0 -29
  51. data/lib/active_ldap/association/belongs_to.rb +0 -40
  52. data/lib/active_ldap/association/belongs_to_many.rb +0 -39
  53. data/lib/active_ldap/association/collection.rb +0 -80
  54. data/lib/active_ldap/association/has_many.rb +0 -40
  55. data/lib/active_ldap/association/has_many_wrap.rb +0 -55
  56. data/lib/active_ldap/association/proxy.rb +0 -89
  57. data/lib/active_ldap/associations.rb +0 -162
  58. data/lib/active_ldap/attributes.rb +0 -203
  59. data/lib/active_ldap/base.rb +0 -1510
  60. data/lib/active_ldap/callbacks.rb +0 -19
  61. data/lib/active_ldap/command.rb +0 -46
  62. data/lib/active_ldap/configuration.rb +0 -106
  63. data/lib/active_ldap/connection.rb +0 -142
  64. data/lib/active_ldap/distinguished_name.rb +0 -246
  65. data/lib/active_ldap/ldap_error.rb +0 -74
  66. data/lib/active_ldap/object_class.rb +0 -74
  67. data/lib/active_ldap/schema.rb +0 -299
  68. data/lib/active_ldap/timeout.rb +0 -75
  69. data/lib/active_ldap/timeout_stub.rb +0 -17
  70. data/lib/active_ldap/user_password.rb +0 -92
  71. data/lib/active_ldap/validations.rb +0 -76
  72. data/rails/plugin/active_ldap/README +0 -54
  73. data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +0 -7
  74. data/rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml +0 -21
  75. data/rails/plugin/active_ldap/init.rb +0 -12
  76. data/test/TODO +0 -2
  77. data/test/al-test-utils.rb +0 -381
  78. data/test/command.rb +0 -62
  79. data/test/config.yaml.sample +0 -6
  80. data/test/run-test.rb +0 -29
  81. data/test/test-unit-ext.rb +0 -2
  82. data/test/test-unit-ext/always-show-result.rb +0 -28
  83. data/test/test-unit-ext/priority.rb +0 -163
data/README DELETED
@@ -1,85 +0,0 @@
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
-
data/Rakefile DELETED
@@ -1,70 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'hoe'
5
- $LOAD_PATH.unshift('./lib')
6
- require 'active_ldap'
7
-
8
- project = Hoe.new('ruby-activeldap', ActiveLdap::VERSION) do |project|
9
- project.rubyforge_name = 'ruby-activeldap'
10
- project.author = ['Will Drewry', 'Kouhei Sutou']
11
- project.email = ['will@alum.bu.edu', 'kou@cozmixng.org']
12
- project.summary = 'Ruby/ActiveLdap is a object-oriented API to LDAP'
13
- project.url = 'http://rubyforge.org/projects/ruby-activeldap/'
14
- project.test_globs = ['test/test_*.rb']
15
- project.changes = project.paragraphs_of('CHANGES', 0..1).join("\n\n")
16
- project.extra_deps = [['log4r', '>= 1.0.4'], 'activerecord']
17
- project.spec_extras = {
18
- :requirements => ['ruby-ldap >= 0.8.2', '(Open)LDAP server'],
19
- :autorequire => 'active_ldap',
20
- :executables => [],
21
- }
22
- project.description = String.new(<<-EOF)
23
- 'Ruby/ActiveLdap' is a ruby extension library which provides a clean
24
- objected oriented interface to the Ruby/LDAP library. It was inspired
25
- by ActiveRecord. This is not nearly as clean or as flexible as
26
- ActiveRecord, but it is still trivial to define new objects and manipulate
27
- them with minimal difficulty.
28
- EOF
29
- end
30
-
31
- # fix Hoe's incorrect guess.
32
- project.spec.executables.clear
33
- project.bin_files = project.spec.files.grep(/^bin/)
34
-
35
- # fix Hoe's install and uninstall task.
36
- task(:install).instance_variable_get("@actions").clear
37
- task(:uninstall).instance_variable_get("@actions").clear
38
-
39
- task :install do
40
- [
41
- [project.lib_files, "lib", Hoe::RUBYLIB, 0444],
42
- [project.bin_files, "bin", File.join(Hoe::PREFIX, 'bin'), 0555]
43
- ].each do |files, prefix, dest, mode|
44
- FileUtils.mkdir_p dest unless test ?d, dest
45
- files.each do |file|
46
- base = File.dirname(file.sub(/^#{prefix}#{File::SEPARATOR}/, ''))
47
- _dest = File.join(dest, base)
48
- FileUtils.mkdir_p _dest unless test ?d, _dest
49
- install file, _dest, :mode => mode
50
- end
51
- end
52
- end
53
-
54
- desc 'Uninstall the package.'
55
- task :uninstall do
56
- Dir.chdir Hoe::RUBYLIB do
57
- rm_f project.lib_files.collect {|f| f.sub(/^lib#{File::SEPARATOR}/, '')}
58
- end
59
- Dir.chdir File.join(Hoe::PREFIX, 'bin') do
60
- rm_f project.bin_files.collect {|f| f.sub(/^bin#{File::SEPARATOR}/, '')}
61
- end
62
- end
63
-
64
-
65
- desc 'Tag the repository for release.'
66
- task :tag do
67
- system "svn copy -m 'New release tag' https://ruby-activeldap.googlecode.com/svn/trunk https://ruby-activeldap.googlecode.com/svn/tags/r#{ActiveLdap::VERSION}"
68
- end
69
-
70
- # vim: syntax=ruby
data/TODO DELETED
@@ -1,23 +0,0 @@
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
- - support Ruby/GetText.
12
- - Add locking around Timeout.alarm() to ensure a multithreaded ruby
13
- app doesn't hit any race conditions
14
- - Add AR matching exceptions:
15
- * ActiveRecordError -- ActiveLdapError as base
16
- * AssociationTypeMismatch
17
- * SerializationTypeMismatch
18
- * ConnectionNotEstablished
19
- * RecordNotFound
20
- * LdapActionInvalid - like StatementInvalid
21
- * MultiparameterAssignmentErrors
22
- * AttributeAssignmentError
23
- * RecordNotSaved
@@ -1,152 +0,0 @@
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
- LDAP_SERVER = "127.0.0.1"
9
- LDAP_PORT = 389
10
- LDAP_BASE = ENV["LDAP_BASE"] || "dc=localdomain"
11
- LDAP_PREFIX = "ou=People"
12
- LDAP_USER = nil
13
- LDAP_PASSWORD = nil
14
-
15
- class ALUser < ActiveLdap::Base
16
- ldap_mapping :dn_attribute => 'uid', :prefix => LDAP_PREFIX,
17
- :classes => ['posixAccount', 'person']
18
- end
19
-
20
- # === search_al
21
- #
22
- def search_al
23
- count = 0
24
- ALUser.find(:all).each do |e|
25
- count += 1
26
- end
27
- return count
28
- end # -- search_al
29
-
30
- def search_al_without_object_creation
31
- count = 0
32
- ALUser.search.each do |e|
33
- count += 1
34
- end
35
- return count
36
- end
37
-
38
- # === search_ldap
39
- #
40
- def search_ldap(conn)
41
- count = 0
42
- conn.search("#{LDAP_PREFIX},#{LDAP_BASE}",
43
- LDAP::LDAP_SCOPE_SUBTREE,
44
- "(uid=*)") do |e|
45
- count += 1
46
- end
47
- count
48
- end # -- search_ldap
49
-
50
- def populate_base
51
- suffixes = []
52
- ActiveLdap::Base.base.split(/,/).reverse_each do |suffix|
53
- prefix = suffixes.join(",")
54
- suffixes.unshift(suffix)
55
- name, value = suffix.split(/=/, 2)
56
- next unless name == "dc"
57
- dc_class = Class.new(ActiveLdap::Base)
58
- dc_class.ldap_mapping :dn_attribute => "dc",
59
- :prefix => "",
60
- :scope => :base,
61
- :classes => ["top", "dcObject", "organization"]
62
- dc_class.instance_variable_set("@base", prefix)
63
- next if dc_class.exists?(value, :prefix => "dc=#{value}")
64
- dc = dc_class.new(value)
65
- dc.o = dc.dc
66
- dc.save
67
- end
68
-
69
- if ActiveLdap::Base.search.empty?
70
- raise "Can't populate #{ActiveLdap::Base.base}"
71
- end
72
- end
73
-
74
- def populate_users
75
- ou_class = Class.new(ActiveLdap::Base)
76
- ou_class.ldap_mapping :dn_attribute => "ou",
77
- :prefix => "",
78
- :classes => ["top", "organizationalUnit"]
79
- ou_class.new(LDAP_PREFIX.split(/=/)[1]).save!
80
-
81
- 100.times do |i|
82
- name = i.to_s
83
- user = ALUser.new(name)
84
- user.uid_number = 100000 + i
85
- user.gid_number = 100000 + i
86
- user.cn = name
87
- user.sn = name
88
- user.home_directory = "/nonexistent"
89
- user.save!
90
- end
91
- end
92
-
93
- def populate
94
- populate_base
95
- populate_users
96
- end
97
-
98
- # === main(argv)
99
- #
100
- def main(argv)
101
- # Connect with AL
102
- #
103
- config = {
104
- :host => LDAP_SERVER,
105
- :port => LDAP_PORT,
106
- :base => LDAP_BASE,
107
- }
108
-
109
- do_populate = LDAP_USER && LDAP_PASSWORD
110
-
111
- if do_populate
112
- config[:bind_dn] = LDAP_USER
113
- config[:password] = LDAP_PASSWORD
114
- end
115
- ActiveLdap::Base.establish_connection(config)
116
-
117
- if do_populate
118
- puts "populating..."
119
- dumped_data = ActiveLdap::Base.dump(:scope => :sub)
120
- ActiveLdap::Base.delete_all(nil, :scope => :sub)
121
- populate
122
- end
123
-
124
- # Standard connection
125
- #
126
- conn = LDAP::Conn.new(LDAP_SERVER, LDAP_PORT)
127
- al_count = 0
128
- al_count_without_object_creation = 0
129
- ldap_count = 0
130
- Benchmark.bm(10) do |x|
131
- x.report("AL") { al_count = search_al }
132
- x.report("AL(No Obj)") do
133
- al_count_without_object_creation = search_al_without_object_creation
134
- end
135
- x.report("LDAP") { ldap_count = search_ldap(conn) }
136
- end
137
- print "Entries processed by Ruby/ActiveLdap: #{al_count}\n"
138
- print "Entries processed by Ruby/ActiveLdap (without object creation)" +
139
- ": #{al_count_without_object_creation}\n"
140
- print "Entries processed by Ruby/LDAP: #{ldap_count}\n"
141
-
142
- 0
143
- ensure
144
- if do_populate
145
- ActiveLdap::Base.delete_all(nil, :scope => :sub)
146
- ActiveLdap::Base.load(dumped_data)
147
- end
148
- end
149
-
150
- if $0 == __FILE__ then
151
- exit(main(ARGV) || 1)
152
- end
@@ -1,5 +0,0 @@
1
- host: 127.0.0.1
2
- method: :tls
3
- base: dc=localdomain
4
- bind_dn: cn=admin,dc=localdomain
5
- #adapter: net-ldap
data/examples/example.der DELETED
Binary file
data/examples/example.jpg DELETED
Binary file
data/examples/groupadd DELETED
@@ -1,41 +0,0 @@
1
- #!/usr/bin/ruby -W0
2
-
3
- base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
4
- $LOAD_PATH << File.join(base, "lib")
5
- $LOAD_PATH << File.join(base, "examples")
6
-
7
- require 'active_ldap'
8
- require 'objects/user'
9
- require 'objects/group'
10
-
11
- argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
12
- opts.banner += " GROUP_NAME"
13
- end
14
-
15
- if argv.size == 1
16
- name = argv.shift
17
- else
18
- $stderr.puts opts
19
- exit 1
20
- end
21
-
22
- pwb = Proc.new do |user|
23
- ActiveLdap::Command.read_password("[#{user}] Password: ")
24
- end
25
-
26
- ActiveLdap::Base.establish_connection(:password_block => pwb,
27
- :allow_anonymous => false)
28
-
29
- if Group.exists?(name)
30
- $stderr.puts("Group #{name} already exists.")
31
- exit 1
32
- end
33
-
34
- group = Group.new(name)
35
- group.gid_number = 9000
36
-
37
- unless group.save
38
- puts "failed"
39
- puts group.errors.full_messages
40
- exit 1
41
- end
data/examples/groupdel DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/ruby -W0
2
-
3
- base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
4
- $LOAD_PATH << File.join(base, "lib")
5
- $LOAD_PATH << File.join(base, "examples")
6
-
7
- require 'active_ldap'
8
- require 'objects/user'
9
- require 'objects/group'
10
-
11
- argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
12
- opts.banner += " GROUP_NAME"
13
- end
14
-
15
- if argv.size == 1
16
- name = argv.shift
17
- else
18
- $stderr.puts opts
19
- exit 1
20
- end
21
-
22
- pwb = Proc.new do |user|
23
- ActiveLdap::Command.read_password("[#{user}] Password: ")
24
- end
25
-
26
- ActiveLdap::Base.establish_connection(:password_block => pwb,
27
- :allow_anonymous => false)
28
-
29
-
30
- unless Group.exists?(name)
31
- $stderr.puts("Group #{name} doesn't exist.")
32
- exit 1
33
- end
34
-
35
- Group.destroy(name)
data/examples/groupls DELETED
@@ -1,49 +0,0 @@
1
- #!/usr/bin/ruby -W0
2
-
3
- base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
4
- $LOAD_PATH << File.join(base, "lib")
5
- $LOAD_PATH << File.join(base, "examples")
6
-
7
- require 'active_ldap'
8
- require 'objects/user'
9
- require 'objects/group'
10
-
11
- argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
12
- opts.banner += " GROUP_NAME"
13
- end
14
-
15
- if argv.size == 1
16
- name = argv.shift
17
- else
18
- $stderr.puts opts
19
- exit 1
20
- end
21
-
22
- pwb = Proc.new do |user|
23
- ActiveLdap::Command.read_password("[#{user}] Password: ")
24
- end
25
-
26
- ActiveLdap::Base.establish_connection(:password_block => pwb,
27
- :allow_anonymous => false)
28
-
29
- unless Group.exists?(name)
30
- $stderr.puts("Group #{name} doesn't exist.")
31
- exit 1
32
- end
33
-
34
- group = Group.find(name)
35
-
36
- members = []
37
- group.primary_members.each do |mem|
38
- members << "#{mem.uid}[#{mem.uidNumber}]"
39
- end
40
-
41
- group.members.each do |mem|
42
- if mem.new_entry?
43
- members << "#{mem.uid}[????]"
44
- else
45
- members << "#{mem.uid}[#{mem.uidNumber}]"
46
- end
47
- end
48
-
49
- puts("#{group.id}(#{group.gid_number}): #{members.join(', ')}")