ucb_ldap 2.0.0.pre1 → 2.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/CHANGELOG +137 -135
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/{README → README.md} +82 -80
  7. data/Rakefile +38 -20
  8. data/lib/ucb_ldap.rb +238 -204
  9. data/lib/{ucb_ldap_address.rb → ucb_ldap/address.rb} +106 -106
  10. data/lib/{ucb_ldap_affiliation.rb → ucb_ldap/affiliation.rb} +16 -16
  11. data/lib/{ucb_ldap_entry.rb → ucb_ldap/entry.rb} +455 -448
  12. data/lib/{ucb_ldap_person_job_appointment.rb → ucb_ldap/job_appointment.rb} +77 -79
  13. data/lib/{ucb_ldap_namespace.rb → ucb_ldap/namespace.rb} +40 -50
  14. data/lib/{ucb_ldap_org.rb → ucb_ldap/org.rb} +427 -429
  15. data/lib/{ucb_ldap_person.rb → ucb_ldap/person.rb} +157 -148
  16. data/lib/{person → ucb_ldap/person}/affiliation_methods.rb +23 -22
  17. data/lib/ucb_ldap/person/common_attributes.rb +63 -0
  18. data/lib/{ucb_ldap_schema.rb → ucb_ldap/schema.rb} +28 -28
  19. data/lib/{ucb_ldap_schema_attribute.rb → ucb_ldap/schema_attribute.rb} +152 -153
  20. data/lib/{ucb_ldap_service.rb → ucb_ldap/service.rb} +17 -19
  21. data/lib/{ucb_ldap_student_term.rb → ucb_ldap/student_term.rb} +29 -31
  22. data/lib/ucb_ldap/version.rb +3 -0
  23. data/spec/rails_binds.yml +9 -0
  24. data/spec/spec_helper.rb +43 -0
  25. data/spec/ucb_ldap/address_spec.rb +54 -0
  26. data/spec/ucb_ldap/affiliation_spec.rb +85 -0
  27. data/spec/ucb_ldap/entry_spec.rb +241 -0
  28. data/spec/ucb_ldap/job_appointment_spec.rb +65 -0
  29. data/spec/ucb_ldap/namespace_spec.rb +72 -0
  30. data/spec/ucb_ldap/org_spec.rb +217 -0
  31. data/spec/ucb_ldap/person_spec.rb +225 -0
  32. data/spec/ucb_ldap/schema_attribute_spec.rb +122 -0
  33. data/spec/ucb_ldap/schema_spec.rb +104 -0
  34. data/spec/ucb_ldap/service_spec.rb +127 -0
  35. data/spec/ucb_ldap/student_term_spec.rb +121 -0
  36. data/spec/ucb_ldap_spec.rb +182 -0
  37. data/ucb_ldap.gemspec +20 -27
  38. metadata +113 -64
  39. data/Manifest +0 -23
  40. data/TODO +0 -2
  41. data/lib/person/adv_con_person.rb +0 -0
  42. data/lib/person/generic_attributes.rb +0 -68
  43. data/lib/ucb_ldap_exceptions.rb +0 -27
  44. data/version.yml +0 -1
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 80b10ceb4a7cdc53a3f27dd0d6ee6d4c0612ab2a
4
+ data.tar.gz: b2114b162809fdb4061ae5342590c0e7bb1218a6
5
+ SHA512:
6
+ metadata.gz: 764e80435a8f6f51ad3e8ad785239b7b460da025901f4c9266b2800dcb5f98c562f9105f5c89f829a9b4e093aaee99bb0a70af3089c48e2042006e7b7d12fe7f
7
+ data.tar.gz: 1f1a5747a32e69a44d196dcabc7135d02aea586b1876d7cdce079ad908b5fe4dc917c60beb94407f56dd027761aece85d9840753466305dbe4dff2b4c0d58b3e
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.iml
2
+ *.idea
3
+ .idea
4
+ *.gem
5
+ *.rbc
6
+ .bundle
7
+ .config
8
+ .yardoc
9
+ Gemfile.lock
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
21
+ spec/binds.yml
data/CHANGELOG CHANGED
@@ -1,135 +1,137 @@
1
- = UCB::LDAP Changelog
2
-
3
- == Version 2.0.0, April 4, 2012
4
- * Switch from ruby-net-ldap to net-ldap (UCB::LDAP should now work with ruby-1.9.x)
5
-
6
- == Version 1.4.2, August 3, 2010
7
- * Remove hack that tried to persist the net-ldap connection instance as this cause problems
8
- with leaving countless file descriptors open when run under JRuby.
9
- * Updated bundled schema.yml file
10
-
11
- == Version 1.2.1, January 22, 2008
12
-
13
- * fixed bug: include UCB::LDAP call at top level that corrupted namespace
14
- * fixed rspec tests to use production ldap server to verify Org structure
15
-
16
-
17
- == Version 1.2.0, September 20, 2007
18
-
19
- * fixed UCB::LDAP::Person.student_not_registered? which was broken
20
- * added support for new entities
21
- * Affiliation
22
- * Service
23
- * StudentTerm
24
- * added handling of timestamp attributes
25
- * various additions and clean-up to the various employee_*, student_*, affiliate_* methods
26
- including handling of expiration
27
- * fetches schema from url rather than file packaged with gem
28
- * made UCB::LDAP::Person searches exclude test entries by default
29
- * Rails applications can use UCB::LDAP.bind_for_rails() to get environment-specific binds
30
-
31
- == Version 1.1.1, August 2, 2007
32
-
33
- * fixed bug around deleting LDAP entries.
34
-
35
- == Version 1.1.0, August 1, 2007
36
-
37
- * added Org#level_<n>_code and Org#level_<n>_name where <n> is 1-6. Returns the
38
- org node's level "n" code/name
39
- * added option to Org.flattened_tree() to restrict levels returned.
40
-
41
- == Version 1.0.1, July 25, 2007
42
-
43
- * do a better job trapping dropped connections in UCB::LDAP.connection_open?
44
- * added Person#test? to check for test entries
45
-
46
- == Version 1.0.0
47
-
48
- * got complete schema info for attributes
49
- * replaced attribute synonyms in favor of explicit methods
50
- * added support for ldap updates
51
- * added support for new entities (if your bind supports it):
52
- * appointment
53
- * address
54
-
55
- == Version 0.8.1, May 18, 2007
56
-
57
- * added Person#dept_org (synonym for Person#deptid)
58
- * added Person#dept_name
59
-
60
- == Version 0.8.0, April 27, 2007
61
-
62
- * added support for privileged binds via UCB::LDAP::authenticate()
63
-
64
- == Version 0.7.0, January 16, 2007
65
-
66
- * updated: UCB::LDAP::Entry.search to use Net::LDAP::Filter objects: this fixed the
67
- problem with embedded whitespace
68
- * updated UCB::LDAP::Person.person_by_uid() to work with an Integer or a String
69
- and UCB::LDAP::Person.persons_by_uids() to work with an Array of Integers or Strings.
70
- * updated: UCB::LDAP::Person.student? to utilize the new LDAP v2 ou structure
71
- * added: UCB::LDAP::Person.student_registered?, UCB::LDAP::Person.student_not_registered?
72
- * deprecated: UCB::LDAP::Person.student_summer?, UCB::LDAP::Person.student_summer_only?,
73
- UCB::LDAP::Person.spring?, UCB::LDAP::Person.fall?. Except for UCB::LDAP::Person.student_summer_only?,
74
- these methods may be added in later versions of UCB::LDAP::Person. Note: accessing these
75
- attributes will required a privileged bind.
76
- * changed UCB::LDAP::Entry to only allow filter options in hash form: :filter => {:uid => 12345}
77
- * updated documentations
78
- * updated unit tests.
79
-
80
- == Version 0.6.0, January 10, 2007
81
-
82
- * Added loading/caching of all nodes
83
- * Added calculation of all child nodes
84
- * Added UCB::LDAP::Org.flattened_tree()
85
- * Added UCB::LDAP::Person.org_node()
86
-
87
- == Version 0.5.0, December 20, 2006
88
-
89
- * Added following methods to Org:
90
- * child_nodes
91
- * parent_node
92
- * parent_nodes
93
- * persons
94
-
95
- == Version 0.4.0, December 14, 2006
96
-
97
- * Added Person.persons_by_uids to return array of Person for given
98
- array of uids.
99
- * Changed implementation of Person.person_by_uid to use new Person.persons_by_uid.
100
-
101
- == Version 0.3.1, December 13, 2006
102
-
103
- * Added SchemaAttribute class and methods to load schema
104
- attributes in UCB::LDAP. Did not make use of the schema
105
- attributes.
106
-
107
- == Version 0.3.0, October 20, 2006
108
-
109
- * Moved to SVN
110
- * Reorganized doc directory
111
-
112
- == Version 0.2.2, October 12, 2006
113
-
114
- * Made more "booleans" actually return <tt>true</tt> and <tt>false</tt>
115
- rather than expressions that evaluate to <tt>true</tt> and <tt>false</tt>.
116
-
117
- * Added TODO[link:files/TODO.html].
118
-
119
- * Some documentation updates.
120
-
121
- == Version 0.2.1, October 10, 2006
122
-
123
- * Changed module name and namespace from UcbLdap to UCB::LDAP.
124
- * Fixed so UCB::LDAP::Entry and subclasses can be marshalled,
125
- otherwise can't store in a Rails session.
126
-
127
- == Version 0.2.0, October 9, 2006
128
-
129
- * Packaged as a Ruby Gem.
130
- * Converted underlying code to use Net::LDAP instead of LDAP.
131
- * Added support for searching the org unit tree.
132
-
133
- == Version 0.1.0, October 5, 2006
134
-
135
- * Initial release.
1
+ # UCB::LDAP Changelog
2
+
3
+ ## Version 2.0.0.pre3, June 8, 2013
4
+ * Reorganize file layout
5
+ * Fix bug where credentials get switched when building org tree
6
+ * Update default ldap hosts to new ldap host names
7
+
8
+ ## Version 2.0.0.pre1, April 4, 2012
9
+ * Switch from ruby-net-ldap to net-ldap (`UCB::LDAP` should now work with ruby-1.9.x)
10
+
11
+ ## Version 1.4.2, August 3, 2010
12
+ * Remove hack that tried to persist the net-ldap connection instance as this cause problems
13
+ with leaving countless file descriptors open when run under JRuby.
14
+ * Updated bundled schema.yml file
15
+
16
+ ## Version 1.2.1, January 22, 2008
17
+
18
+ * fixed bug: include `UCB::LDAP` call at top level that corrupted namespace
19
+ * fixed rspec tests to use production ldap server to verify Org structure
20
+
21
+
22
+ ## Version 1.2.0, September 20, 2007
23
+
24
+ * fixed `UCB::LDAP::Person.student_not_registered?` which was broken
25
+ * added support for new entities
26
+ * Affiliation
27
+ * Service
28
+ * StudentTerm
29
+ * added handling of timestamp attributes
30
+ * various additions and clean-up to the various employee_*, student_*, affiliate_* methods
31
+ including handling of expiration
32
+ * fetches schema from url rather than file packaged with gem
33
+ * made `UCB::LDAP::Person` searches exclude test entries by default
34
+ * Rails applications can use `UCB::LDAP.bind_for_rails` to get environment-specific binds
35
+
36
+ ## Version 1.1.1, August 2, 2007
37
+
38
+ * fixed bug around deleting LDAP entries.
39
+
40
+ ## Version 1.1.0, August 1, 2007
41
+
42
+ * added Org#level_<n>_code and Org#level_<n>_name where <n> is 1-6. Returns the
43
+ org node's level "n" code/name
44
+ * added option to Org.flattened_tree() to restrict levels returned.
45
+
46
+ ## Version 1.0.1, July 25, 2007
47
+
48
+ * do a better job trapping dropped connections in UCB::LDAP.connection_open?
49
+ * added Person#test? to check for test entries
50
+
51
+ ## Version 1.0.0
52
+
53
+ * got complete schema info for attributes
54
+ * replaced attribute synonyms in favor of explicit methods
55
+ * added support for ldap updates
56
+ * added support for new entities (if your bind supports it):
57
+ * appointment
58
+ * address
59
+
60
+ ## Version 0.8.1, May 18, 2007
61
+
62
+ * added Person#dept_org (synonym for Person#deptid)
63
+ * added Person#dept_name
64
+
65
+ ## Version 0.8.0, April 27, 2007
66
+
67
+ * added support for privileged binds via UCB::LDAP::authenticate()
68
+
69
+ ## Version 0.7.0, January 16, 2007
70
+
71
+ * updated: UCB::LDAP::Entry.search to use Net::LDAP::Filter objects: this fixed the
72
+ problem with embedded whitespace
73
+ * updated UCB::LDAP::Person.person_by_uid() to work with an Integer or a String
74
+ and UCB::LDAP::Person.persons_by_uids() to work with an Array of Integers or Strings.
75
+ * updated: UCB::LDAP::Person.student? to utilize the new LDAP v2 ou structure
76
+ * added: UCB::LDAP::Person.student_registered?, UCB::LDAP::Person.student_not_registered?
77
+ * deprecated: UCB::LDAP::Person.student_summer?, UCB::LDAP::Person.student_summer_only?,
78
+ UCB::LDAP::Person.spring?, UCB::LDAP::Person.fall?. Except for UCB::LDAP::Person.student_summer_only?,
79
+ these methods may be added in later versions of UCB::LDAP::Person. Note: accessing these
80
+ attributes will required a privileged bind.
81
+ * changed UCB::LDAP::Entry to only allow filter options in hash form: :filter => {:uid => 12345}
82
+ * updated documentations
83
+ * updated unit tests.
84
+
85
+ ## Version 0.6.0, January 10, 2007
86
+
87
+ * Added loading/caching of all nodes
88
+ * Added calculation of all child nodes
89
+ * Added UCB::LDAP::Org.flattened_tree()
90
+ * Added UCB::LDAP::Person.org_node()
91
+
92
+ ## Version 0.5.0, December 20, 2006
93
+
94
+ * Added following methods to Org:
95
+ * child_nodes
96
+ * parent_node
97
+ * parent_nodes
98
+ * persons
99
+
100
+ ## Version 0.4.0, December 14, 2006
101
+
102
+ * Added Person.persons_by_uids to return array of Person for given
103
+ array of uids.
104
+ * Changed implementation of Person.person_by_uid to use new Person.persons_by_uid.
105
+
106
+ ## Version 0.3.1, December 13, 2006
107
+
108
+ * Added SchemaAttribute class and methods to load schema
109
+ attributes in UCB::LDAP. Did not make use of the schema
110
+ attributes.
111
+
112
+ ## Version 0.3.0, October 20, 2006
113
+
114
+ * Moved to SVN
115
+ * Reorganized doc directory
116
+
117
+ ## Version 0.2.2, October 12, 2006
118
+
119
+ * Made more "booleans" actually return <tt>true</tt> and <tt>false</tt>
120
+ rather than expressions that evaluate to <tt>true</tt> and <tt>false</tt>.
121
+ * Some documentation updates.
122
+
123
+ ## Version 0.2.1, October 10, 2006
124
+
125
+ * Changed module name and namespace from UcbLdap to UCB::LDAP.
126
+ * Fixed so UCB::LDAP::Entry and subclasses can be marshalled,
127
+ otherwise can't store in a Rails session.
128
+
129
+ ## Version 0.2.0, October 9, 2006
130
+
131
+ * Packaged as a Ruby Gem.
132
+ * Converted underlying code to use Net::LDAP instead of LDAP.
133
+ * Added support for searching the org unit tree.
134
+
135
+ ## Version 0.1.0, October 5, 2006
136
+
137
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ucb_ldap.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 sahglie
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,80 +1,82 @@
1
- =UC Berkeley LDAP
2
-
3
- UCB::LDAP is a wrapper module around Net::LDAP intended to simplify searching the UC Berkeley
4
- LDAP directory: http://directory.berkeley.edu
5
-
6
- ==Introduction to LDAP
7
- If you are blissfully ignorant of LDAP, you should familiarize yourself with some of the basics.
8
- Here is a great online resource: http://www.zytrax.com/books/ldap
9
-
10
- The RDoc for the ruby-net-ldap Gem (http://rubyfurnace.com/docs/ruby-net-ldap-0.0.4/classes/Net/LDAP.html) also has a good introduction to LDAP.
11
-
12
-
13
- ==Examples
14
-
15
- ===General Search
16
-
17
- Search the directory specifying tree base and
18
- filter, getting back generic UCB::LDAP::Entry instances:
19
-
20
- entries = UCB::LDAP.search(:base => "ou=people,dc=berkeley,dc=edu", :filter => {:uid => 123}
21
-
22
- entry.uid #=> '123'
23
- entry.givenname #=> 'John'
24
- entry.sn #=> 'Doe'
25
-
26
- See UCB::LDAP::Entry for more information.
27
-
28
- ===Person Search
29
-
30
- Search the Person tree getting back UCB::LDAP::Person instances:
31
-
32
- person = UCB::LDAP::Person.find_by_uid("123")
33
-
34
- person.firstname #=> "John"
35
- person.affiliations #=> ['EMPLOYEE-TYPE-STAFF']
36
- person.employee? #=> true
37
- person.employee_staff? #=> true
38
- person.employee_academic? #=> false
39
- person.student? #=> false
40
-
41
- See UCB::LDAP::Person for more information.
42
-
43
- ===Org Unit Search
44
-
45
- Search the Org Unit tree getting back UCB::LDAP::Org instances:
46
-
47
- dept = UCB::LDAP::Org.org_by_ou 'jkasd'
48
-
49
- dept.deptid #=> "JKASD"
50
- dept.name #=> "Administrative Systems Dept"
51
-
52
- See UCB::LDAP::Org for more information.
53
-
54
- ===Privileged Binds
55
-
56
- If you want access the directory anonomously, no credentials are required.
57
- If you want to access via a privileged bind, authenticate before querying:
58
-
59
- p = UCB::LDAP::Person.find_by_uid("123")
60
- p.non_public_attr #=> NoMethodError
61
-
62
- UCB::LDAP.authenticate("mybind", "mypassword")
63
- p = UCB::LDAP::Person.find_by_uid("123")
64
- p.non_public_attr #=> "some value"
65
-
66
- === Privileged Binds and Rails
67
-
68
- See UCB::LDAP.bind_for_rails()
69
-
70
- ==Dependencies
71
-
72
- * Net::LDAP
73
- * Ruby 1.8.5 or better
74
-
75
- ==Authors
76
-
77
- Steven Hansen runner@berkeley.edu
78
- Lucas Rockwell
79
- Steve Downey
80
-
1
+ #UC Berkeley LDAP
2
+
3
+ UCB::LDAP is a wrapper module around Net::LDAP intended to simplify searching the UC Berkeley
4
+ LDAP directory: http://directory.berkeley.edu
5
+
6
+ ##Introduction to LDAP
7
+ If you are blissfully ignorant of LDAP, you should familiarize yourself with some of the basics.
8
+ Here is a great online resource: http://www.zytrax.com/books/ldap
9
+
10
+ The RDoc for the ruby-net-ldap Gem (http://rubyfurnace.com/docs/ruby-net-ldap-0.0.4/classes/Net/LDAP.html) also has a good introduction to LDAP.
11
+
12
+
13
+ ##Examples
14
+
15
+ ###General Search
16
+
17
+ Search the directory specifying tree base and filter, getting back generic `UCB::LDAP::Entry` instances:
18
+
19
+ ```ruby
20
+ entries = UCB::LDAP.search(:base => "ou=people,dc=berkeley,dc=edu", :filter => {:uid => 123})
21
+ entry.uid #=> '123'
22
+ entry.givenname #=> 'John'
23
+ entry.sn #=> 'Doe'
24
+ ```
25
+
26
+ See `UCB::LDAP::Entry` for more information.
27
+
28
+ ###Person Search
29
+
30
+ Search the Person tree getting back UCB::LDAP::Person instances:
31
+
32
+ ```ruby
33
+ person = UCB::LDAP::Person.find_by_uid("123")
34
+ person.firstname #=> "John"
35
+ person.affiliations #=> ['EMPLOYEE-TYPE-STAFF']
36
+ person.employee? #=> true
37
+ person.employee_staff? #=> true
38
+ person.employee_academic? #=> false
39
+ person.student? #=> false
40
+ ```
41
+
42
+ See `UCB::LDAP::Person` for more information.
43
+
44
+ ###Org Unit Search
45
+
46
+ Search the Org Unit tree getting back `UCB::LDAP::Org` instances:
47
+
48
+ ``` ruby
49
+ dept = UCB::LDAP::Org.org_by_ou('jkasd')
50
+ dept.deptid #=> "JKASD"
51
+ dept.name #=> "Administrative Systems Dept"
52
+ ```
53
+
54
+ See `UCB::LDAP::Org` for more information.
55
+
56
+ ###Privileged Binds
57
+
58
+ If you want access the directory anonymously, no credentials are required.
59
+ If you want to access via a privileged bind, authenticate before querying:
60
+
61
+ ```ruby
62
+ p = UCB::LDAP::Person.find_by_uid("123")
63
+ p.non_public_attr #=> NoMethodError
64
+
65
+ UCB::LDAP.authenticate("mybind", "mypassword")
66
+ p = UCB::LDAP::Person.find_by_uid("123")
67
+ p.non_public_attr #=> "some value"
68
+ ```
69
+
70
+ ###Privileged Binds and Rails
71
+
72
+ See `UCB::LDAP.bind_for_rails`
73
+
74
+ ##Dependencies
75
+
76
+ * Net::LDAP
77
+ * Ruby 1.9.2 or better
78
+
79
+ ##Maintainers
80
+
81
+ * Steven Hansen
82
+ * Steve Downey