richardun / active_directory

Native Ruby Access to Microsoft Active Directory
http://rubyforge.org/projects/activedirectory
12 stars 8 forks source link

Issue with "member_of?" function #14

Open acaeti opened 10 years ago

acaeti commented 10 years ago

I get an error when I am attempting to add a user to a group they already belong to:

group.has_member?(user) TypeError: can't convert Symbol into Integer from /home/acaeti/.rvm/gems/ruby-1.9.3-p392/gems/active_directory-1.5.5/lib/active_directory/base.rb:345:in []' from /home/acaeti/.rvm/gems/ruby-1.9.3-p392/gems/active_directory-1.5.5/lib/active_directory/base.rb:345:in==' from /home/acaeti/.rvm/gems/ruby-1.9.3-p392/gems/active_directory-1.5.5/lib/active_directory/member.rb:31:in include?' from /home/acaeti/.rvm/gems/ruby-1.9.3-p392/gems/active_directory-1.5.5/lib/active_directory/member.rb:31:inmember_of?' from /home/acaeti/.rvm/gems/ruby-1.9.3-p392/gems/active_directory-1.5.5/lib/active_directory/group.rb:48:in has_member?' from (irb):31 from /home/acaeti/.rvm/rubies/ruby-1.9.3-p392/bin/irb:13:in

'

It seems to stem from code in the member.rb function "member_of?".

At line 28 in member.rb it seems you set a variable "group_dns": group_dns = memberOf And at line 31 you see if this "includes?" the DN of the group in question: group_dns.include?(usergroup.dn)

However, the "group_dns" is an Array of ActiveDirectory::Group objects, which is being compared by the include?() to a Net::BER::BerIdentifiedString. This isn't going to work :).

I think the line 31 code should be "group_dns.include?(usergroup)" instead.