active_directory 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +3 -1
- data/VERSION +1 -1
- data/active_directory.gemspec +2 -3
- data/lib/active_directory.rb +11 -6
- data/lib/active_directory/base.rb +25 -47
- data/lib/active_directory/computer.rb +2 -5
- data/lib/active_directory/container.rb +2 -5
- data/lib/active_directory/field_type/binary.rb +2 -5
- data/lib/active_directory/field_type/date.rb +2 -5
- data/lib/active_directory/field_type/password.rb +2 -5
- data/lib/active_directory/field_type/timestamp.rb +2 -5
- data/lib/active_directory/group.rb +2 -5
- data/lib/active_directory/member.rb +2 -5
- data/lib/active_directory/user.rb +2 -5
- metadata +4 -5
- data/CHANGELOG +0 -7
data/README
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
= Active Directory
|
2
2
|
|
3
|
-
Ruby Integration with Microsoft's Active Directory system
|
3
|
+
Ruby Integration with Microsoft's Active Directory system based on original code by Justin Mecham and James Hunt at http://rubyforge.org/projects/activedirectory
|
4
|
+
|
5
|
+
See documentation on ActiveDirectory::Base for more information.
|
4
6
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.2
|
data/active_directory.gemspec
CHANGED
@@ -5,18 +5,17 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{active_directory}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Adam T Kerr"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-14}
|
13
13
|
s.description = %q{ActiveDirectory uses Net::LDAP to provide a means of accessing and modifying an Active Directory data store. This is a fork of the activedirectory gem.}
|
14
14
|
s.email = %q{ajrkerr@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"CHANGELOG",
|
20
19
|
"README",
|
21
20
|
"Rakefile",
|
22
21
|
"VERSION",
|
data/lib/active_directory.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -37,8 +34,16 @@ require 'active_directory/field_type/date.rb'
|
|
37
34
|
require 'active_directory/field_type/timestamp.rb'
|
38
35
|
|
39
36
|
module ActiveDirectory
|
37
|
+
|
40
38
|
#Special Fields
|
41
|
-
|
39
|
+
def self.special_fields
|
40
|
+
@@special_fields
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.special_fields= sp_fields
|
44
|
+
@@special_fields = sp_fields
|
45
|
+
end
|
46
|
+
|
42
47
|
@@special_fields = {
|
43
48
|
|
44
49
|
#All objects in the AD
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -72,20 +69,29 @@ module ActiveDirectory
|
|
72
69
|
"#{@@ldap.get_operation_result.code}: #{@@ldap.get_operation_result.message}"
|
73
70
|
end
|
74
71
|
|
72
|
+
##
|
73
|
+
# Return the last errorcode that ldap generated
|
75
74
|
def self.error_code
|
76
75
|
@@ldap.get_operation_result.code
|
77
76
|
end
|
78
77
|
|
78
|
+
##
|
79
|
+
# Check to see if the last query produced an error
|
80
|
+
# Note: Invalid username/password combinations will not
|
81
|
+
# produce errors
|
79
82
|
def self.error?
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.success?
|
84
|
-
@@ldap.get_operation_result.code == 0
|
83
|
+
@@ldap.nil? ? false : @@ldap.get_operation_result.code != 0
|
85
84
|
end
|
86
85
|
|
86
|
+
##
|
87
|
+
# Check to see if we are connected to the LDAP server
|
88
|
+
# This method will try to connect, if we haven't already
|
87
89
|
def self.connected?
|
88
|
-
|
90
|
+
begin
|
91
|
+
@@ldap.nil? ? false : @@ldap.bind
|
92
|
+
rescue Net::LDAP::LdapError => e
|
93
|
+
false
|
94
|
+
end
|
89
95
|
end
|
90
96
|
|
91
97
|
def self.filter # :nodoc:
|
@@ -179,6 +185,8 @@ module ActiveDirectory
|
|
179
185
|
# matching your filter.
|
180
186
|
#
|
181
187
|
def self.find(*args)
|
188
|
+
return false unless connected?
|
189
|
+
|
182
190
|
options = {
|
183
191
|
:filter => NIL_FILTER,
|
184
192
|
:in => ''
|
@@ -401,24 +409,20 @@ module ActiveDirectory
|
|
401
409
|
def get_field_type(name)
|
402
410
|
#Extract class name
|
403
411
|
klass = self.class.name[/.*::(.*)/, 1]
|
404
|
-
::Rails.logger.add 0, "special_fields[#{klass.classify.to_sym}][#{name.downcase.to_sym}] = #{::ActiveDirectory.special_fields[klass.classify.to_sym][name.downcase.to_sym]}"
|
405
412
|
type = ::ActiveDirectory.special_fields[klass.classify.to_sym][name.downcase.to_sym]
|
406
413
|
type.to_s.classify unless type.nil?
|
407
414
|
end
|
408
415
|
|
409
416
|
def decode_field(name, value)
|
410
|
-
|
417
|
+
#Extract class name
|
411
418
|
type = get_field_type name
|
412
|
-
::Rails.logger.add 0, "Type: #{type} Const: #{::ActiveDirectory::FieldType::const_get type unless type.nil?}"
|
413
419
|
return ::ActiveDirectory::FieldType::const_get(type).decode(value) if !type.nil? and ::ActiveDirectory::FieldType::const_defined? type
|
414
420
|
return value
|
415
421
|
end
|
416
422
|
|
417
423
|
def encode_field(name, value)
|
418
|
-
::Rails.logger.add 0, "Encoding #{name}, #{value}"
|
419
424
|
type = get_field_type name
|
420
|
-
::
|
421
|
-
return ::ActiveDirectory::FieldType::const_get(type).encode(value) if ::ActiveDirectory::FieldType::const_defined? type
|
425
|
+
return ::ActiveDirectory::FieldType::const_get(type).encode(value) if !type.nil? and ::ActiveDirectory::FieldType::const_defined? type
|
422
426
|
return value
|
423
427
|
end
|
424
428
|
|
@@ -433,44 +437,18 @@ module ActiveDirectory
|
|
433
437
|
return decode_field(name, @attributes[name.to_sym]) if @attributes.has_key?(name.to_sym)
|
434
438
|
|
435
439
|
if @entry
|
436
|
-
|
440
|
+
begin
|
437
441
|
value = @entry.send(name.to_sym)
|
438
442
|
value = value.first if value.kind_of?(Array) && value.size == 1
|
439
443
|
value = value.to_s if value.nil? || value.size == 1
|
440
|
-
::Rails.logger.add 0, "Decoded as #{decode_field(name, value)}\n"
|
441
|
-
::Rails.logger.add 0, ""
|
442
444
|
return decode_field(name, value)
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
# end
|
445
|
+
rescue NoMethodError
|
446
|
+
return nil
|
447
|
+
end
|
447
448
|
end
|
448
449
|
|
449
450
|
super
|
450
451
|
end
|
451
452
|
|
452
|
-
# def method_missing(name, args = []) # :nodoc:
|
453
|
-
# name_s = name.to_s.downcase
|
454
|
-
# name = name_s.to_sym
|
455
|
-
# if name_s[-1,1] == '='
|
456
|
-
# @attributes[name_s[0,name_s.size-1].to_sym] = args
|
457
|
-
# else
|
458
|
-
# if @attributes.has_key?(name)
|
459
|
-
# return @attributes[name]
|
460
|
-
# elsif @entry
|
461
|
-
# begin
|
462
|
-
# value = @entry.send(name)
|
463
|
-
# value = value.first if value.kind_of?(Array) && value.size == 1
|
464
|
-
# value = value.to_s if value.nil? || value.size == 1
|
465
|
-
# return value
|
466
|
-
# rescue NoMethodError
|
467
|
-
# return nil
|
468
|
-
# end
|
469
|
-
# else
|
470
|
-
# super
|
471
|
-
# end
|
472
|
-
# end
|
473
|
-
# end
|
474
|
-
|
475
453
|
end
|
476
454
|
end
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
@@ -1,10 +1,7 @@
|
|
1
1
|
#-- license
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright (c) 2008, James Hunt <filefrog@gmail.com>
|
7
|
-
# based on original code by Justin Mecham
|
3
|
+
# Based on original code by Justin Mecham and James Hunt
|
4
|
+
# at http://rubyforge.org/projects/activedirectory
|
8
5
|
#
|
9
6
|
# This program is free software: you can redistribute it and/or modify
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_directory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 2
|
10
|
+
version: 1.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam T Kerr
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-14 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,6 @@ extensions: []
|
|
43
43
|
extra_rdoc_files:
|
44
44
|
- README
|
45
45
|
files:
|
46
|
-
- CHANGELOG
|
47
46
|
- README
|
48
47
|
- Rakefile
|
49
48
|
- VERSION
|