Open cthielen opened 12 years ago
Hello,
I would put a breakpoint where you're checking member_of? and check what you're getting back from u.groups. If the user is a member of just one group (in AD), that will be their primary group and will NOT show up in groups.
Also, I'm not sure exactly what method it's complaining about when you get that ArgumentError exception... is that "member_of?" or something found inside the member_of? method? member_of? itself should be part of that user anyway because the User class includes Member.
Thanks, R
On Thu, Jul 12, 2012 at 3:58 PM, Christopher Thielen < reply@reply.github.com
wrote:
I'm getting an ArgumentError ("no id given") when I use member_of? on only certain users.
Here's an example:
require 'active_directory'
Load settings from file in config/
AD_PEOPLE_SETTINGS = YAML.load_file("#{Rails.root.to_s}/config/database.yml")['ad_people'] AD_GROUPS_SETTINGS = YAML.load_file("#{Rails.root.to_s}/config/database.yml")['ad_groups']
Will be the user later
u = nil
Run through multiple paths in the tree to find where the user is kept
AD_PEOPLE_SETTINGS.each do |entry| settings = { :host => entry['host'], :base => entry['base'], :port => 636, :encryption => :simple_tls, :auth => { :method => :simple, :username => entry['user'], :password => entry['pass'] } }
puts "Trying #{entry['base']}"
ActiveDirectory::Base.setup(settings) u = ActiveDirectory::User.find(:first, :samaccountname => "the_problem_user") break unless u.nil? end
u is a valid user at this point, load the desired group
settings = { :host => AD_GROUPS_SETTINGS['host'], :base => AD_GROUPS_SETTINGS['base'], :port => 636, :encryption => :simple_tls, :auth => { :method => :simple, :username => AD_GROUPS_SETTINGS['user'], :password => AD_GROUPS_SETTINGS['pass'] } }
ActiveDirectory::Base.setup(settings) g = ActiveDirectory::Group.find(:first, :cn => "the_group")
u.member_of? g # throws ArgumentError
It's also an inconsistent error. For instance, in writing this test case using a certain loginid, the problem stopped happening and I had to try another user to recreate the problem.
Any idea how I can debug this?
Reply to this email directly or view it on GitHub: https://github.com/richardun/active_directory/issues/8
I'm getting an ArgumentError ("no id given") when I use member_of? on only certain users.
Here's an example:
require 'active_directory'
Load settings from file in config/
AD_PEOPLE_SETTINGS = YAML.load_file("#{Rails.root.to_s}/config/database.yml")['ad_people'] AD_GROUPS_SETTINGS = YAML.load_file("#{Rails.root.to_s}/config/database.yml")['ad_groups']
Will be the user later
u = nil
Run through multiple paths in the tree to find where the user is kept
AD_PEOPLE_SETTINGS.each do |entry| settings = { :host => entry['host'], :base => entry['base'], :port => 636, :encryption => :simple_tls, :auth => { :method => :simple, :username => entry['user'], :password => entry['pass'] } }
puts "Trying #{entry['base']}"
ActiveDirectory::Base.setup(settings) u = ActiveDirectory::User.find(:first, :samaccountname => "the_problem_user") break unless u.nil? end
u is a valid user at this point, load the desired group
settings = { :host => AD_GROUPS_SETTINGS['host'], :base => AD_GROUPS_SETTINGS['base'], :port => 636, :encryption => :simple_tls, :auth => { :method => :simple, :username => AD_GROUPS_SETTINGS['user'], :password => AD_GROUPS_SETTINGS['pass'] } }
ActiveDirectory::Base.setup(settings) g = ActiveDirectory::Group.find(:first, :cn => "the_group")
u.member_of? g # throws ArgumentError
It's also an inconsistent error. For instance, in writing this test case using a certain loginid, the problem stopped happening and I had to try another user to recreate the problem.
Any idea how I can debug this?