ldapmapper 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ldapmapper.rb +56 -10
- metadata +41 -32
data/lib/ldapmapper.rb
CHANGED
@@ -9,8 +9,15 @@
|
|
9
9
|
# * Author:: Romain GEORGES
|
10
10
|
# * type:: class definition Ruby
|
11
11
|
# * obj:: Generic LDAP class
|
12
|
-
# *
|
12
|
+
# * VCS Version:: $Id$
|
13
13
|
#
|
14
|
+
# === Websites :
|
15
|
+
# * http://www.ultragreen.net
|
16
|
+
# * http://ldapmapper.rubyforge.org
|
17
|
+
#
|
18
|
+
# === Contact :
|
19
|
+
# Romain GEORGES <romain@ultragreen.net>
|
20
|
+
#
|
14
21
|
# == Exemples :
|
15
22
|
#
|
16
23
|
# #!/usr/local/bin/ruby
|
@@ -94,7 +101,7 @@ module Ldapmapper
|
|
94
101
|
|
95
102
|
# identity lib
|
96
103
|
# version of the library
|
97
|
-
LIB_VERSION='1.0.
|
104
|
+
LIB_VERSION='1.0.1'
|
98
105
|
# name of the author
|
99
106
|
AUTHOR='Romain GEORGES'
|
100
107
|
# date of creation
|
@@ -108,18 +115,25 @@ module Ldapmapper
|
|
108
115
|
# attributs for LDAP connection
|
109
116
|
|
110
117
|
# hostname of the LDAP server
|
118
|
+
# default : 'localhost'
|
111
119
|
attr_accessor :host_ldap
|
112
120
|
# TCP/IP port of the LDAP server
|
113
|
-
|
121
|
+
# default : 389
|
122
|
+
attr_accessor :port_ldap
|
114
123
|
# LDAP scope for search
|
124
|
+
# dafault : LDAP::LDAP_SCOPE_SUBTREE
|
115
125
|
attr_accessor :scope_ldap
|
116
126
|
# current filter for search
|
127
|
+
# default : '(objectClass=*)'
|
117
128
|
attr_accessor :filter_ldap
|
118
129
|
# LDAP base DN for the instance
|
130
|
+
# no default get by LDAP bind for ROOT DSE record
|
119
131
|
attr_accessor :basedn_ldap
|
120
132
|
# credential for the instance
|
133
|
+
# no default get by instance initializer
|
121
134
|
attr_accessor :passdn_ldap
|
122
135
|
# LDAP rootdn for LDAP
|
136
|
+
# default 'cn=root'
|
123
137
|
attr_accessor :rootdn_ldap
|
124
138
|
|
125
139
|
# constructor for LdapTemplate
|
@@ -150,12 +164,16 @@ module Ldapmapper
|
|
150
164
|
class LdapMapper < LdapTemplate
|
151
165
|
|
152
166
|
# DN binding point attribut
|
167
|
+
# no default get by instance initializer
|
153
168
|
attr_accessor :dn_ldap
|
154
169
|
# Hash of attributes with optional or mandatory aspects in value
|
170
|
+
# no default get by LDAP query on Schema
|
155
171
|
attr_accessor :list_attributs_type
|
156
172
|
# Array of objectclass for the current record
|
173
|
+
# no default, could be empty for nonexistants mapping get by LDIF LDAP query
|
157
174
|
attr_accessor :list_objectclass
|
158
175
|
# Hash of attributes in LDIF mapping, value should be an array in case of multivalue data
|
176
|
+
# no default, could be empty for nonexistants mapping get by LDIF LDAP query
|
159
177
|
attr_accessor :list_attributs
|
160
178
|
|
161
179
|
# constructor with dn_ldap initialisation
|
@@ -348,8 +366,10 @@ module Ldapmapper
|
|
348
366
|
_table_res = _e.to_hash()['objectClass']
|
349
367
|
}
|
350
368
|
}
|
351
|
-
ensure
|
352
369
|
return _table_res
|
370
|
+
rescue
|
371
|
+
raise LdapmapperGetObjectclassesError
|
372
|
+
return Array::new
|
353
373
|
end
|
354
374
|
end
|
355
375
|
|
@@ -366,8 +386,10 @@ module Ldapmapper
|
|
366
386
|
_conn.bind {
|
367
387
|
_my_basedn = _conn.root_dse[0]["namingContexts"].to_s
|
368
388
|
}
|
369
|
-
ensure
|
370
389
|
return _my_basedn
|
390
|
+
rescue
|
391
|
+
raise LdapmapperGetDSEError
|
392
|
+
return Array::new
|
371
393
|
end
|
372
394
|
end
|
373
395
|
|
@@ -384,9 +406,10 @@ module Ldapmapper
|
|
384
406
|
_schema = _conn.schema()
|
385
407
|
_my_list_attributs = _schema.alias(_attribute)
|
386
408
|
}
|
387
|
-
|
388
|
-
ensure
|
389
409
|
return _my_list_attributs
|
410
|
+
rescue
|
411
|
+
raise LdapmapperGetSchemaError
|
412
|
+
return Array::new
|
390
413
|
end
|
391
414
|
end
|
392
415
|
|
@@ -407,8 +430,10 @@ module Ldapmapper
|
|
407
430
|
_table_res.push(_e.dn)
|
408
431
|
}
|
409
432
|
}
|
410
|
-
ensure
|
411
433
|
return _table_res
|
434
|
+
rescue
|
435
|
+
raise LdapmapperGetDnError
|
436
|
+
return Array::new
|
412
437
|
end
|
413
438
|
|
414
439
|
end
|
@@ -433,10 +458,12 @@ module Ldapmapper
|
|
433
458
|
end
|
434
459
|
}
|
435
460
|
}
|
436
|
-
ensure
|
437
461
|
_my_list_attributs["dn"] = "MUST"
|
438
462
|
_my_list_attributs["objectClass"] = "MUST"
|
439
463
|
return _my_list_attributs
|
464
|
+
rescue
|
465
|
+
raise LdapmapperGetSchemaError
|
466
|
+
return Hash::new
|
440
467
|
end
|
441
468
|
end
|
442
469
|
|
@@ -455,6 +482,7 @@ module Ldapmapper
|
|
455
482
|
}
|
456
483
|
}
|
457
484
|
rescue
|
485
|
+
raise LdapmapperGetLdifError
|
458
486
|
return Hash::new
|
459
487
|
end
|
460
488
|
end
|
@@ -477,6 +505,7 @@ module Ldapmapper
|
|
477
505
|
_conn.add("#{_dn}", _data)
|
478
506
|
return true
|
479
507
|
rescue LDAP::ResultError
|
508
|
+
raise LdapmapperAddLdifError
|
480
509
|
return false
|
481
510
|
end
|
482
511
|
}
|
@@ -501,6 +530,7 @@ module Ldapmapper
|
|
501
530
|
_conn.add("#{_dn}", _data)
|
502
531
|
return true
|
503
532
|
rescue LDAP::ResultError
|
533
|
+
raise LdapmapperModLdifError
|
504
534
|
return false
|
505
535
|
end
|
506
536
|
}
|
@@ -516,7 +546,23 @@ module Ldapmapper
|
|
516
546
|
puts "Date release : #{DATE}"
|
517
547
|
puts "Observation : #{OBS}"
|
518
548
|
end
|
519
|
-
|
549
|
+
|
550
|
+
# exceptions definitions
|
551
|
+
# raise when a modification of a record failed
|
552
|
+
class LdapmapperModLdifError < Exception; end
|
553
|
+
# raise when an adding of a record failed
|
554
|
+
class LdapmapperAddLdifError < Exception; end
|
555
|
+
# raise when the retrieving of a record failed
|
556
|
+
class LdapmapperGetLdifError < Exception; end
|
557
|
+
# raise when the retrieving of Schema's data failed
|
558
|
+
class LdapmapperGetSchemaError < Exception; end
|
559
|
+
# raise when the browsing of an LDAP tree failed
|
560
|
+
class LdapmapperGetDnError < Exception; end
|
561
|
+
# raise when the retrieving of root DSE record failed
|
562
|
+
class LdapmapperGetDSEError < Exception; end
|
563
|
+
# raise when the retrieving of objectclasses list failed
|
564
|
+
class LdapmapperGetObjectclassesError < Exception; end
|
565
|
+
|
520
566
|
end
|
521
567
|
|
522
568
|
#==END==#
|
metadata
CHANGED
@@ -1,46 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
4
2
|
name: ldapmapper
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
- lib
|
11
|
-
email: romain@ultragreen.net
|
12
|
-
homepage: http://www.ultragreen.net
|
13
|
-
rubyforge_project:
|
14
|
-
description: "Ldapmapper : provide CRUD object for LDAP data manipulations"
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Romain GEORGES
|
15
8
|
autorequire:
|
16
|
-
default_executable:
|
17
9
|
bindir:
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-16 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "Ldapmapper : provide CRUD object for LDAP data manipulations"
|
17
|
+
email: romain@ultragreen.net
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/ldapmapper.rb
|
18
26
|
has_rdoc: true
|
19
|
-
|
27
|
+
homepage: http://www.ultragreen.net/projects/ldapmapper
|
28
|
+
licenses: []
|
29
|
+
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
20
36
|
requirements:
|
21
37
|
- - ">="
|
22
38
|
- !ruby/object:Gem::Version
|
23
39
|
version: 1.8.1
|
24
40
|
version:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
29
48
|
|
30
|
-
|
31
|
-
|
32
|
-
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.3.5
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: "Ldapmapper : CRUD Objects for LDAP mapping"
|
33
54
|
test_files:
|
34
55
|
- test/testldapmapper.rb
|
35
|
-
rdoc_options: []
|
36
|
-
|
37
|
-
extra_rdoc_files: []
|
38
|
-
|
39
|
-
executables: []
|
40
|
-
|
41
|
-
extensions: []
|
42
|
-
|
43
|
-
requirements: []
|
44
|
-
|
45
|
-
dependencies: []
|
46
|
-
|