adap 0.0.15 → 0.0.20

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d6b9c74a5d53a24227c3753f17a5ae0cd6013dd462384eeaa264a36026e4c2f
4
- data.tar.gz: 62080295b2ebfaac3831693a162300f9cea86066f614f6a5327b6f4149c6dfa5
3
+ metadata.gz: 717838e91b87a82d3c3989bbfb3b723c2d02d301fdfa619a74397f1b54faf847
4
+ data.tar.gz: 36670ebfbde205a1ddb89ad60b5b4f6a14d2c9e73abf5f8a9c26d2675674abcc
5
5
  SHA512:
6
- metadata.gz: 4dd9414e4ca4340024de4bcf337f495c706fe3c482ac2eafcca491ca6a1445a248c36256a506cc16b4487594e3ecba5f7465a1be0571a70a3ccef9d6bee95f4e
7
- data.tar.gz: e469a2cca56ea3c20eb4a25ff211d76d8a1f7daaed9f1b06e766fd840102e69125d92a667774fc6c0849d905179a62a89e6cac8769ed219a01a5cc208372a84d
6
+ metadata.gz: 8c383f2725b47a79632d68af4733243a841caf43ec017e932a20217fc63854acb00fb3998a3665346b2632200766f9ad55d36929197ab311e6cfc3544e9e5c32
7
+ data.tar.gz: dfdb8c54733642e6849b0ecc5b55b490184cb1d29136bdc551c0417d1080096b71b2e99540d89d4a5b242705bb494a5110f26c3032249a612f942b3bf410f347
data/Gemfile CHANGED
@@ -8,3 +8,5 @@ gem "unix-crypt", "~> 1.3"
8
8
  gem "net-ldap", "~> 0.16.2"
9
9
 
10
10
  gem "mocha", "~> 1.10"
11
+
12
+ gem "rake", "~> 13.0"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adap (0.0.7)
4
+ adap (0.0.19)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -9,7 +9,7 @@ GEM
9
9
  minitest (5.14.0)
10
10
  mocha (1.11.2)
11
11
  net-ldap (0.16.2)
12
- rake (10.5.0)
12
+ rake (13.0.1)
13
13
  unix-crypt (1.3.0)
14
14
 
15
15
  PLATFORMS
@@ -21,7 +21,7 @@ DEPENDENCIES
21
21
  minitest (~> 5.0)
22
22
  mocha (~> 1.10)
23
23
  net-ldap (~> 0.16.2)
24
- rake (~> 10.0)
24
+ rake (~> 13.0)
25
25
  unix-crypt (~> 1.3)
26
26
 
27
27
  BUNDLED WITH
@@ -24,9 +24,9 @@ class Adap
24
24
  }
25
25
 
26
26
  # List of attributes for user in AD
27
- @ad_user_required_attributes = [:cn, :sn, :uid, :uidnumber, :gidnumber, :displayname, :loginshell, :gecos, :givenname, :unixhomedirectory]
27
+ @ad_user_required_attributes = [:cn, :sn, :uid, :uidnumber, :gidnumber, :displayname, :loginshell, :gecos, :givenname, :description, :mail, :unixhomedirectory]
28
28
  # List of attributes for user in LDAP
29
- @ldap_user_required_attributes = [:cn, :sn, :uid, :uidnumber, :gidnumber, :displayname, :loginshell, :gecos, :givenname, :homedirectory]
29
+ @ldap_user_required_attributes = [:cn, :sn, :uid, :uidnumber, :gidnumber, :displayname, :loginshell, :gecos, :givenname, :description, :mail, :homedirectory]
30
30
 
31
31
  @ad_host = params[:ad_host]
32
32
  @ad_port = (params[:ad_port] ? params[:ad_port] : 389)
@@ -36,6 +36,7 @@ class Adap
36
36
  @ldap_host = params[:ldap_host]
37
37
  @ldap_port = (params[:ldap_port] ? params[:ldap_port] : 389)
38
38
  @ldap_binddn = params[:ldap_binddn]
39
+ @ldap_suffix_ou = (params[:ldap_suffix_ou] ? params[:ldap_suffix_ou] : "ou=Users")
39
40
  @ldap_basedn = params[:ldap_basedn]
40
41
  @ldap_user_basedn = params[:ldap_user_basedn]
41
42
  @ldap_auth = (params.has_key?(:ldap_password) ? { :method => :simple, :username => @ldap_binddn, :password => params[:ldap_password] } : nil )
@@ -83,7 +84,7 @@ class Adap
83
84
  end
84
85
 
85
86
  def get_ldap_dn(username)
86
- "uid=#{username},ou=Users,#{@ldap_basedn}"
87
+ "uid=#{username},#{@ldap_suffix_ou},#{@ldap_basedn}"
87
88
  end
88
89
 
89
90
  def create_ldap_attributes(ad_entry)
@@ -112,14 +113,12 @@ class Adap
112
113
  end
113
114
 
114
115
  def get_password(username)
115
- password = get_raw_password(username, @password_hash_algorithm)
116
-
117
- if password == nil || password.empty?
118
- raise "Failed to get password of #{username} from AD. Did you enabled AD password option virtualCryptSHA512 and/or virtualCryptSHA256?"
116
+ result = get_raw_password(username, @password_hash_algorithm)
117
+ if not result.nil? then
118
+ result = result.chomp
119
119
  end
120
- password = password.chomp
121
120
 
122
- password
121
+ return result
123
122
  end
124
123
 
125
124
  def get_raw_password(username, algo)
@@ -183,6 +182,10 @@ class Adap
183
182
  end
184
183
 
185
184
  def add_user(ldap_user_dn, ad_entry, password)
185
+ if password == nil || password.empty?
186
+ raise "Password of #{ldap_user_dn} from AD in add_user is empty or nil. Did you enabled AD password option virtualCryptSHA512 and/or virtualCryptSHA256?"
187
+ end
188
+
186
189
  attributes = create_ldap_attributes(ad_entry)
187
190
 
188
191
  @ldap_client.add(
@@ -272,7 +275,9 @@ class Adap
272
275
 
273
276
  # AD does not have password as simple ldap attribute.
274
277
  # So password will always be updated for this reason.
275
- operations.push([:replace, :userpassword, password])
278
+ if not password.nil? and not password.empty? then
279
+ operations.push([:replace, :userpassword, password])
280
+ end
276
281
 
277
282
  operations
278
283
  end
@@ -501,12 +506,13 @@ class Adap
501
506
 
502
507
  def get_primary_gidnumber_from_ad(uid)
503
508
  return nil if uid ==nil
509
+ primary_gid = nil
504
510
 
505
511
  @ad_client.search(:base => "CN=#{uid},CN=Users,#{@ad_basedn}") do |entry|
506
512
  primary_gid = entry[:gidnumber].first
507
513
  end
508
514
 
509
- return primary_gid
515
+ primary_gid
510
516
  end
511
517
 
512
518
  end
@@ -1,3 +1,3 @@
1
1
  module ModAdap
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.20"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsutomu Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-15 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler