active_directory 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
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
+ 1.2.2
@@ -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.1"
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-10}
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",
@@ -1,10 +1,7 @@
1
1
  #-- license
2
2
  #
3
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- mattr_accessor :special_fields
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- !success?
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
- @@ldap.bind
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
- ::Rails.logger.add 0, "Decoding #{name}, #{value}"
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
- ::Rails.logger.add 0, "Type: #{type} Const: #{::ActiveDirectory::FieldType::const_get type}"
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
- # begin
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
- # rescue NoMethodError => e
444
- # ::Rails.logger.add 0, "#{e.inspect}"
445
- # return nil
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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
- # This file is part of the Ruby Active Directory Project
4
- # on the web at http://rubyforge.org/projects/activedirectory
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
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-10 00:00:00 -05:00
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
data/CHANGELOG DELETED
@@ -1,7 +0,0 @@
1
- 2008-12-01 James Hunt <filefrog@gmail.com>
2
-
3
- * Fixed bug [#22307] "syntax errors"
4
- (http://rubyforge.org/tracker/index.php?func=detail&aid=22307&group_id=1580&atid=6154)
5
-
6
- Broke out module declarations
7
- Added parens around _merge_ call