active_directory 1.5.5 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d449033589eaaa462c257b527459168c87adb334
4
+ data.tar.gz: e564ced04b9c6db1105f4e053fd66cd211e25101
5
+ SHA512:
6
+ metadata.gz: 9daaae94f3e5a87bdab9b2e35f7a29769303c2b1a22cb7eee81ebe31fab57063e4ee04680009fdd1c93db096c9bc36ee4dd8e98d3e94f6e9ce8e86a4ac49a854
7
+ data.tar.gz: 25ad84712752a54175df9c6904e38cff0befa84ac612e2b51f2ead76af01ae1364e41adeb9f50a2f26645107c7a502c5c7be2d63b605cdbfeb58e1feb7b2f84a
data/README.md CHANGED
@@ -5,7 +5,7 @@ Ruby Integration with Microsoft's Active Directory system based on original code
5
5
  See documentation on ActiveDirectory::Base for more information.
6
6
 
7
7
  Caching:
8
- Queries for membership and group membership are based on the distinguished name of objects. Doing a lot of queries, especially for a Rails app, is a sizable slowdown. To alleviate the problem, I've implemented a very basic cache for queries which search by :distinguishedname. This is diabled by default. All other queries are unaffected.
8
+ Queries for membership and group membership are based on the distinguished name of objects. Doing a lot of queries, especially for a Rails app, is a sizable slowdown. To alleviate the problem, I've implemented a very basic cache for queries which search by :distinguishedname. This is disabled by default. All other queries are unaffected.
9
9
 
10
10
 
11
11
  A code example is worth a thousand words:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.5
1
+ 1.6.0
@@ -2,16 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: active_directory 1.6.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = %q{active_directory}
8
- s.version = "1.5.5"
8
+ s.name = "active_directory"
9
+ s.version = "1.6.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Adam T Kerr"]
12
- s.date = %q{2011-04-28}
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
- s.email = %q{ajrkerr@gmail.com}
14
+ s.date = "2015-01-29"
15
+ s.description = "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."
16
+ s.email = "ajrkerr@gmail.com"
15
17
  s.extra_rdoc_files = [
16
18
  "README.md"
17
19
  ]
@@ -36,13 +38,12 @@ Gem::Specification.new do |s|
36
38
  "lib/active_directory/member.rb",
37
39
  "lib/active_directory/user.rb"
38
40
  ]
39
- s.homepage = %q{http://github.com/ajrkerr/active_directory}
40
- s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.6.2}
42
- s.summary = %q{An interface library for accessing Microsoft's Active Directory.}
41
+ s.homepage = "http://github.com/ajrkerr/active_directory"
42
+ s.rubygems_version = "2.4.5"
43
+ s.summary = "An interface library for accessing Microsoft's Active Directory."
43
44
 
44
45
  if s.respond_to? :specification_version then
45
- s.specification_version = 3
46
+ s.specification_version = 4
46
47
 
47
48
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
49
  s.add_runtime_dependency(%q<net-ldap>, [">= 0.1.1"])
@@ -81,5 +81,15 @@ module ActiveDirectory
81
81
  :memberof => :GroupDnArray,
82
82
  :member => :MemberDnArray,
83
83
  },
84
+
85
+ #Computer objects
86
+ :Computer => {
87
+ :objectguid => :Binary,
88
+ :whencreated => :Date,
89
+ :whenchanged => :Date,
90
+ :objectsid => :Binary,
91
+ :memberof => :GroupDnArray,
92
+ :member => :MemberDnArray,
93
+ },
84
94
  }
85
95
  end
@@ -422,7 +422,8 @@ module ActiveDirectory
422
422
  begin
423
423
  attributes.merge!(required_attributes)
424
424
  if @@ldap.add(:dn => dn.to_s, :attributes => attributes)
425
- return find_by_distinguishedName(dn.to_s)
425
+ ldap_obj= @@ldap.search(:base => dn.to_s)
426
+ return new(ldap_obj[0])
426
427
  else
427
428
  return nil
428
429
  end
@@ -555,7 +556,7 @@ module ActiveDirectory
555
556
  end
556
557
 
557
558
  def set_attr(name, value)
558
- @attributes[name.to_sym] = encode_field(name, value)
559
+ @attributes[name.to_sym] = self.class.encode_field(name, value)
559
560
  end
560
561
 
561
562
  ##
@@ -98,7 +98,7 @@ module ActiveDirectory
98
98
  # belong to this Group, or any of its subgroups, are returned.
99
99
  #
100
100
  def member_users(recursive = false)
101
- @member_users = User.find(:all, :distinguishedname => @entry.member).delete_if { |u| u.nil? }
101
+ @member_users = User.find(:all, :distinguishedname => @entry[:member]).delete_if { |u| u.nil? }
102
102
  if recursive then
103
103
  self.member_groups.each do |group|
104
104
  @member_users.concat(group.member_users(true))
@@ -117,7 +117,7 @@ module ActiveDirectory
117
117
  # belong to this Group, or any of its subgroups, are returned.
118
118
  #
119
119
  def member_groups(recursive = false)
120
- @member_groups ||= Group.find(:all, :distinguishedname => @entry.member).delete_if { |g| g.nil? }
120
+ @member_groups ||= Group.find(:all, :distinguishedname => @entry[:member]).delete_if { |g| g.nil? }
121
121
  if recursive then
122
122
  self.member_groups.each do |group|
123
123
  @member_groups.concat(group.member_groups(true))
@@ -28,7 +28,7 @@ module ActiveDirectory
28
28
  group_dns = memberOf
29
29
  return false if group_dns.nil? || group_dns.empty?
30
30
  #group_dns = [group_dns] unless group_dns.is_a?(Array)
31
- group_dns.include?(usergroup.dn)
31
+ group_dns.map{ |g| g.dn }.include?(usergroup.dn)
32
32
  end
33
33
 
34
34
  #
@@ -24,6 +24,7 @@ module ActiveDirectory
24
24
 
25
25
  UAC_ACCOUNT_DISABLED = 0x0002
26
26
  UAC_NORMAL_ACCOUNT = 0x0200 # 512
27
+ UAC_PASSWORD_NEVER_EXPIRES = 0x10000 #65536
27
28
 
28
29
  def self.filter # :nodoc:
29
30
  Net::LDAP::Filter.eq(:objectClass,'user') & ~Net::LDAP::Filter.eq(:objectClass,'computer')
@@ -104,6 +105,37 @@ module ActiveDirectory
104
105
  userAccountControl.to_i & UAC_ACCOUNT_DISABLED != 0
105
106
  end
106
107
 
108
+ #
109
+ # Disables the account
110
+ #
111
+ def disable
112
+ new_mask = userAccountControl.to_i | UAC_ACCOUNT_DISABLED
113
+ update_attributes userAccountControl: new_mask.to_s
114
+ end
115
+
116
+ #
117
+ # Enables the account
118
+ #
119
+ def enable
120
+ new_mask = userAccountControl.to_i ^ UAC_ACCOUNT_DISABLED
121
+ update_attributes userAccountControl: new_mask.to_s
122
+ end
123
+
124
+
125
+ #
126
+ # Returns true if this account is expired.
127
+ #
128
+ def expired?
129
+ !lockoutTime.nil? && lockoutTime.to_i != 0
130
+ end
131
+
132
+ #
133
+ # Returns true if this account has a password that does not expire.
134
+ #
135
+ def password_never_expires?
136
+ userAccountControl.to_i & UAC_PASSWORD_NEVER_EXPIRES != 0
137
+ end
138
+
107
139
  #
108
140
  # Returns true if the user should be able to log in with a correct
109
141
  # password (essentially, their account is not disabled or locked
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_directory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
5
- prerelease:
4
+ version: 1.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Adam T Kerr
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-04-28 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: net-ldap
16
- requirement: &2153664380 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.1.1
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2153664380
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.1
25
27
  description: ActiveDirectory uses Net::LDAP to provide a means of accessing and modifying
26
28
  an Active Directory data store. This is a fork of the activedirectory gem.
27
29
  email: ajrkerr@gmail.com
@@ -51,26 +53,25 @@ files:
51
53
  - lib/active_directory/user.rb
52
54
  homepage: http://github.com/ajrkerr/active_directory
53
55
  licenses: []
56
+ metadata: {}
54
57
  post_install_message:
55
58
  rdoc_options: []
56
59
  require_paths:
57
60
  - lib
58
61
  required_ruby_version: !ruby/object:Gem::Requirement
59
- none: false
60
62
  requirements:
61
- - - ! '>='
63
+ - - ">="
62
64
  - !ruby/object:Gem::Version
63
65
  version: '0'
64
66
  required_rubygems_version: !ruby/object:Gem::Requirement
65
- none: false
66
67
  requirements:
67
- - - ! '>='
68
+ - - ">="
68
69
  - !ruby/object:Gem::Version
69
70
  version: '0'
70
71
  requirements: []
71
72
  rubyforge_project:
72
- rubygems_version: 1.8.10
73
+ rubygems_version: 2.4.5
73
74
  signing_key:
74
- specification_version: 3
75
+ specification_version: 4
75
76
  summary: An interface library for accessing Microsoft's Active Directory.
76
77
  test_files: []