ruby-activeldap 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/CHANGES +5 -0
  2. data/Manifest.txt +91 -25
  3. data/README +22 -0
  4. data/Rakefile +41 -8
  5. data/TODO +1 -6
  6. data/examples/config.yaml.example +5 -0
  7. data/examples/example.der +0 -0
  8. data/examples/example.jpg +0 -0
  9. data/examples/groupadd +41 -0
  10. data/examples/groupdel +35 -0
  11. data/examples/groupls +49 -0
  12. data/examples/groupmod +42 -0
  13. data/examples/lpasswd +55 -0
  14. data/examples/objects/group.rb +13 -0
  15. data/examples/objects/ou.rb +4 -0
  16. data/examples/objects/user.rb +20 -0
  17. data/examples/ouadd +38 -0
  18. data/examples/useradd +45 -0
  19. data/examples/useradd-binary +50 -0
  20. data/examples/userdel +34 -0
  21. data/examples/userls +50 -0
  22. data/examples/usermod +42 -0
  23. data/examples/usermod-binary-add +47 -0
  24. data/examples/usermod-binary-add-time +51 -0
  25. data/examples/usermod-binary-del +48 -0
  26. data/examples/usermod-lang-add +43 -0
  27. data/lib/active_ldap.rb +213 -214
  28. data/lib/active_ldap/adapter/base.rb +461 -0
  29. data/lib/active_ldap/adapter/ldap.rb +232 -0
  30. data/lib/active_ldap/adapter/ldap_ext.rb +69 -0
  31. data/lib/active_ldap/adapter/net_ldap.rb +288 -0
  32. data/lib/active_ldap/adapter/net_ldap_ext.rb +29 -0
  33. data/lib/active_ldap/association/belongs_to.rb +3 -1
  34. data/lib/active_ldap/association/belongs_to_many.rb +5 -6
  35. data/lib/active_ldap/association/has_many.rb +9 -17
  36. data/lib/active_ldap/association/has_many_wrap.rb +4 -5
  37. data/lib/active_ldap/attributes.rb +4 -0
  38. data/lib/active_ldap/base.rb +201 -56
  39. data/lib/active_ldap/configuration.rb +11 -1
  40. data/lib/active_ldap/connection.rb +15 -9
  41. data/lib/active_ldap/distinguished_name.rb +246 -0
  42. data/lib/active_ldap/ldap_error.rb +74 -0
  43. data/lib/active_ldap/object_class.rb +9 -5
  44. data/lib/active_ldap/schema.rb +50 -9
  45. data/lib/active_ldap/validations.rb +11 -13
  46. data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +7 -0
  47. data/rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml +21 -0
  48. data/rails/plugin/active_ldap/init.rb +10 -4
  49. data/test/al-test-utils.rb +46 -3
  50. data/test/run-test.rb +16 -4
  51. data/test/test-unit-ext/always-show-result.rb +28 -0
  52. data/test/test-unit-ext/priority.rb +163 -0
  53. data/test/test_adapter.rb +81 -0
  54. data/test/test_attributes.rb +8 -1
  55. data/test/test_base.rb +132 -3
  56. data/test/test_base_per_instance.rb +14 -3
  57. data/test/test_connection.rb +19 -0
  58. data/test/test_dn.rb +161 -0
  59. data/test/test_find.rb +24 -0
  60. data/test/test_object_class.rb +15 -2
  61. data/test/test_schema.rb +108 -1
  62. metadata +111 -41
  63. data/lib/active_ldap/adaptor/base.rb +0 -29
  64. data/lib/active_ldap/adaptor/ldap.rb +0 -466
  65. data/lib/active_ldap/ldap.rb +0 -113
@@ -1,113 +0,0 @@
1
- # Extensions to Rubu/LDAP to make ActiveLdap behave better
2
- #
3
- # Copyright 2006 Will Drewry <will@alum.bu.edu>
4
- # Some portions Copyright 2006 Google Inc
5
-
6
- require 'ldap'
7
-
8
- module LDAP
9
- class PrettyError < LDAP::Error
10
- end
11
-
12
- ERRORS = [
13
- "LDAP_SUCCESS",
14
- "LDAP_OPERATIONS_ERROR",
15
- "LDAP_PROTOCOL_ERROR",
16
- "LDAP_TIMELIMIT_EXCEEDED",
17
- "LDAP_SIZELIMIT_EXCEEDED",
18
- "LDAP_COMPARE_FALSE",
19
- "LDAP_COMPARE_TRUE",
20
- "LDAP_STRONG_AUTH_NOT_SUPPORTED",
21
- "LDAP_AUTH_METHOD_NOT_SUPPORTED",
22
- "LDAP_STRONG_AUTH_REQUIRED",
23
- "LDAP_REFERRAL",
24
- "LDAP_ADMINLIMIT_EXCEEDED",
25
- "LDAP_UNAVAILABLE_CRITICAL_EXTENSION",
26
- "LDAP_CONFIDENTIALITY_REQUIRED",
27
- "LDAP_SASL_BIND_IN_PROGRESS",
28
- "LDAP_PARTIAL_RESULTS",
29
- "LDAP_NO_SUCH_ATTRIBUTE",
30
- "LDAP_UNDEFINED_TYPE",
31
- "LDAP_INAPPROPRIATE_MATCHING",
32
- "LDAP_CONSTRAINT_VIOLATION",
33
- "LDAP_TYPE_OR_VALUE_EXISTS",
34
- "LDAP_INVALID_SYNTAX",
35
- "LDAP_NO_SUCH_OBJECT",
36
- "LDAP_ALIAS_PROBLEM",
37
- "LDAP_INVALID_DN_SYNTAX",
38
- "LDAP_IS_LEAF",
39
- "LDAP_ALIAS_DEREF_PROBLEM",
40
- "LDAP_INAPPROPRIATE_AUTH",
41
- "LDAP_INVALID_CREDENTIALS",
42
- "LDAP_INSUFFICIENT_ACCESS",
43
- "LDAP_BUSY",
44
- "LDAP_UNAVAILABLE",
45
- "LDAP_UNWILLING_TO_PERFORM",
46
- "LDAP_LOOP_DETECT",
47
- "LDAP_NAMING_VIOLATION",
48
- "LDAP_OBJECT_CLASS_VIOLATION",
49
- "LDAP_NOT_ALLOWED_ON_NONLEAF",
50
- "LDAP_NOT_ALLOWED_ON_RDN",
51
- "LDAP_ALREADY_EXISTS",
52
- "LDAP_NO_OBJECT_CLASS_MODS",
53
- "LDAP_RESULTS_TOO_LARGE",
54
- "LDAP_OTHER",
55
- "LDAP_SERVER_DOWN",
56
- "LDAP_LOCAL_ERROR",
57
- "LDAP_ENCODING_ERROR",
58
- "LDAP_DECODING_ERROR",
59
- "LDAP_TIMEOUT",
60
- "LDAP_AUTH_UNKNOWN",
61
- "LDAP_FILTER_ERROR",
62
- "LDAP_USER_CANCELLED",
63
- "LDAP_PARAM_ERROR",
64
- "LDAP_NO_MEMORY",
65
- "LDAP_CONNECT_ERROR"
66
- ]
67
- attr_reader :error_map
68
- # Calls err2exception() with 1...100 to
69
- # pregenerate all the constants for errors.
70
- # TODO: look at other support LDAP SDKs for weirdness
71
- def LDAP.generate_err2exceptions()
72
- hash = {}
73
- ERRORS.each do |err|
74
- begin
75
- val = LDAP.const_get(err)
76
- # Make name into a exception
77
- exc = err.gsub(/^LDAP_/, '')
78
- exc = exc.split('_').collect {|w| w.capitalize }.join('')
79
- # Doesn't exist :-)
80
- LDAP.module_eval(<<-end_module_eval)
81
- class #{exc} < LDAP::PrettyError
82
- end
83
- end_module_eval
84
- hash[val] = exc
85
- rescue NameError
86
- # next!
87
- end
88
- end
89
- @@error_map = hash
90
- end
91
-
92
- # Creates useful exceptions from @@conn.err output
93
- # Returns [exception, message] based on err2string
94
- def LDAP.err2exception(errno=0)
95
- need_to_rebuild = true
96
- begin
97
- exc = LDAP.const_get(@@error_map[errno])
98
- rescue NameError
99
- if need_to_rebuild
100
- generate_err2exceptions()
101
- need_to_rebuild = false
102
- retry
103
- end
104
- exc = RuntimeError
105
- end
106
- return [exc, err2string(errno)]
107
- end
108
-
109
-
110
- end
111
-
112
- # Generate LDAP constants
113
- LDAP::generate_err2exceptions()