google-code-export / ruby-activeldap

Automatically exported from code.google.com/p/ruby-activeldap
Other
1 stars 1 forks source link

TypeError: can't convert nil into Array when searching for groups #40

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Search for groups where one attributes returns nil (why ? I don't know) 

u=AD::User.find("cpennafo")
p u.groupes.collect{|g|g.cn}

What is the expected output? What do you see instead?

The expected output is : 

["PEMOD-CRIH", "CANADA-CRIH" ...] # A list of groups cn

The result I see instead is : 

TypeError: can't convert nil into Array
    from /Library/Ruby/Gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb:71:in 
`concat'
    from /Library/Ruby/Gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb:71:in 
`search'

What version of the product are you using? On what operating system?
activeldap-1.2.1

Please provide any additional information below.

I patched activeldap-1.2.1/lib/active_ldap/operations.rb on line 71 
transforming 
normalized_value into a table. It also seems to work adding a "if 
normalized_value" at the end of 
the line :
 71             attributes[normalized_attr].concat([normalized_value])

Original issue reported on code.google.com by christia...@gmail.com on 3 Feb 2010 at 1:55

GoogleCodeExporter commented 9 years ago
Could you show your AD::User class definition and all backtrace on error?

Original comment by kou...@gmail.com on 6 Mar 2010 at 7:32

GoogleCodeExporter commented 9 years ago
Looks like I'm having the exact same issue here.

class AdUser < AdBase
  ldap_mapping :dn_attribute => "samaccountname",
               :prefix => "ou=wiu",
               :classes => ['top','person','organizationalPerson','user'],
               :scope => :sub
  belongs_to :groups, :class_name => 'AdGroup', :many => 'member', :primary_key =>
'distinguishedName'

$ rake accounts:sync --trace
(in /Users/mrm114/Development/railsdev/idm)
** Invoke accounts:sync (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute accounts:sync
Modifying memberships for GLOBAL groups (ACTIVESTUDENTS, FACULTY-STAFF, etc...)
rake aborted!
can't convert nil into Array
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb
:71:in `concat'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb
:71
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb
:67:in `each'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb
:67
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:163:in
`call'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:163
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/ldap.
rb:96:in
`call'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/ldap.
rb:96:in
`search'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/ldap.
rb:185:in
`send'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/ldap.
rb:185:in
`execute'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:659:in
`log'
/opt/local/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:659:in
`log'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/ldap.
rb:185:in
`execute'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/ldap.
rb:90:in
`search'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:170:in
`search'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:275:in
`operation'
/opt/local/lib/ruby/1.8/timeout.rb:53:in `timeout'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/timeout_stub.
rb:6:in
`alarm'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:321:in
`with_timeout'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:274:in
`operation'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/base.
rb:169:in
`search'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/adapter/ldap.
rb:83:in
`search'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb
:65:in `search'
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb
:96:in `exists?'
/Users/mrm114/Development/railsdev/idm/app/models/ad_group.rb:141:in
`find_or_create_by_cn'
/Users/mrm114/Development/railsdev/idm/app/models/ad_group.rb:78:in
`add_array_members_to_group'
/Users/mrm114/Development/railsdev/idm/app/models/idm_account.rb:140:in
`modify_global_group_memberships'
/Users/mrm114/Development/railsdev/idm/lib/tasks/accounts.rake:47
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in 
`invoke_with_call_chain'
/opt/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in 
`invoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/opt/local/bin/rake:19:in `load'
/opt/local/bin/rake:19

Original comment by techmi...@gmail.com on 12 Apr 2010 at 3:06

GoogleCodeExporter commented 9 years ago
Adding "if normalized_value" to the end of line 71 in operations.rb seems to 
resolve
the issue for me too.  Not sure if this will break anything else though.

Matt

Original comment by techmi...@gmail.com on 12 Apr 2010 at 3:09

GoogleCodeExporter commented 9 years ago
Thanks.
We need data returned by LDAP server.

Please modify
/opt/local/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/operations.rb
 like
the following:

  65      values = options[:connection].search(search_options) do |dn, attrs|
  ADD!!!    p [dn, attrs]
  66        attributes = {}
  67        attrs.each do |key, _value|
  68          normalized_attr, normalized_value =
  69            normalize_attribute_options(key, _value)
  70          attributes[normalized_attr] ||= []
  71          attributes[normalized_attr].concat(normalized_value)
  72        end
  73        [dn, attributes]
  74      end

And run your script again.

Please show the output of your script.

Original comment by kou...@gmail.com on 25 Apr 2010 at 10:32

GoogleCodeExporter commented 9 years ago
It had been fixed in trunk.

Original comment by kou...@gmail.com on 8 Jul 2010 at 9:28