From kou at cozmixng.org Wed Aug 29 03:39:50 2012 From: kou at cozmixng.org (Kouhei Sutou) Date: Wed, 29 Aug 2012 12:39:50 +0900 (JST) Subject: [activeldap-discuss] [ANN] ActiveLdap 3.2.0 Message-ID: <20120829.123950.1326674700870843590.kou@cozmixng.org> Hi, ActiveLdap 3.2.0 has been released! Site: http://ruby-activeldap.rubyforge.org/ Install: gem install activeldap Tutorial: http://ruby-activeldap.rubyforge.org/activeldap/en/file.tutorial.html Here is a document about Rails 3 with ActiveLdap: http://ruby-activeldap.rubyforge.org/activeldap/en/file.rails.html ActiveLdap provides an object oriented interface to LDAP. It maps LDAP entries to Ruby objects with LDAP attribute accessors based on your LDAP server's schema and each object's objectClasses. This release supports Rails 3.2.8. If you want to use LDAP in your Rails application, please try it. Here are changes since 3.2.0: http://ruby-activeldap.rubyforge.org/activeldap/en/file.news.html#3-2.0 h2(#3-2-0). 3.2.0: 2012-08-29 * [GitHub:#39] Supported Rails 3.2.8. [Reported by Ben Langfeld] * [GitHub:#13] Don't use deprecated Gem.available?. [Patch by sailesh] * [GitHub:#19] Supported new entry by @ha_many :wrap at . [Patch by Alex Tomlins] * Supported @:only@ option in XML output. * [GitHub:#14] Supported nil as single value. [Reported by n3llyb0y] * [GitHub:#20] Supported ActiveModel::MassAssignmentSecurity. [Reported by mihu] * [GitHub:#24] Supported Ruby 1.9 style Hash syntax in generator. [Patch by ursm] * [GitHub:#25][GitHub:#39] Supported ActiveModel::Dirty. [Patch by mihu][Reported by Ben Langfeld] * [GitHub:#26] Improved speed for dirty. [Patch by mihu] * [GitHub:#28] Improved speed for initialization. [Patch by mihu] * [GitHub:#29] Added .gemspec. [Suggested by mklappstuhl] * [GitHub:#34] Removed an unused method. [Patch by mihu] * [GitHub:#37] Improved will_paginate support. [Patch by Craig White] * [GitHub:#40] Added missing test files to .gemspec. [Reported by V?t Ondruch] * [GitHub:#41] Improved speed for find. [Patch by unixmechanic] * Changed i18n backend to gettext from fast_gettext again. * [GitHub:#42] Fixed a bug that optional second is required for GeneralizedTime. [Reported by masche842] h3. Thanks * sailesh * Alex Tomlins * n3llyb0y * mihu * ursm * Ben Langfeld * mklappstuhl * Craig White * V?t Ondruch * unixmechanic * masche842 Thanks, -- kou From craig.white at ttiltd.com Thu Aug 30 20:38:18 2012 From: craig.white at ttiltd.com (Craig White) Date: Thu, 30 Aug 2012 13:38:18 -0700 Subject: [activeldap-discuss] [ANN] ActiveLdap 3.2.0 In-Reply-To: <20120829.123950.1326674700870843590.kou@cozmixng.org> References: <20120829.123950.1326674700870843590.kou@cozmixng.org> Message-ID: <171F6E37-0F4C-4868-9641-1EF539718694@ttiltd.com> On Aug 28, 2012, at 8:39 PM, Kouhei Sutou wrote: > Hi, > > ActiveLdap 3.2.0 has been released! > > Site: > http://ruby-activeldap.rubyforge.org/ > Install: > gem install activeldap > Tutorial: > http://ruby-activeldap.rubyforge.org/activeldap/en/file.tutorial.html > Here is a document about Rails 3 with ActiveLdap: > http://ruby-activeldap.rubyforge.org/activeldap/en/file.rails.html > > > ActiveLdap provides an object oriented interface to LDAP. It > maps LDAP entries to Ruby objects with LDAP attribute > accessors based on your LDAP server's schema and each > object's objectClasses. > > > This release supports Rails 3.2.8. If you want to use LDAP > in your Rails application, please try it. ---- trying it but I ran into failures on my functional tests so I went to the console which I think shows what I am facing here (not just hosts but also people & groups but hosts here for the example). irb(main):028:0> host = Host.find(:first) => #, must:, may:, cn: ["unittest1"], commonName: ["unittest1"], description: ["Description of unittest1"], ipHostNumber: ["1.1.1.1", "9.9.9.1"], l: ["Location1"], localityName: ["Location1"], manager: [], o: [], objectClass: ["top", "device", "ipHost"], organizationName: [], organizationalUnitName: [], ou: [], owner: [], seeAlso: [], serialNumber: []> irb(main):029:0> host.cn => "unittest1" irb(main):030:0> host.delete NoMethodError: super: no superclass method `delete' for # from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activemodel-3.2.8/lib/active_model/attribute_methods.rb:404:in `method_missing' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activeldap-3.2.0/lib/active_ldap/persistence.rb:24:in `delete' from (irb):30 from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `' from script/rails:6:in `require' from script/rails:6:in `
' ? Craig for completeness... $ cat app/models/host.rb require 'will_paginate_array_helper' class Host < ActiveLdap::Base ldap_mapping :dn_attribute => "cn", :prefix => "ou=Hosts", :classes => ["top", "device", "ipHost"] has_many :people, :class_name => 'Person', :foreign_key => 'host', :primary_key => 'cn' attr_accessor :hostipnumbers_columnized def host_extra HostExtra.find(:first, :conditions => {:cn => self.cn}) end def puppetmanaged host_extra.puppetmanaged end def hbac host_extra.hbac end def status host_extra.status end def last_update host_extra.last_update end def os host_extra.lsbdistdescription end def validate errors.add(:base, "You must enter a value for the 'Common name'") unless self.cn.to_s != '' errors.add(:base, "You should enter a value for the 'Description'") unless self.description.to_s != '' errors.add(:base, "You must enter a value for the 'Location'") unless self.localityName.to_s != '' errors.add(:base, "You must enter at least 1 IP Address for each host") unless self.ipHostNumber.to_s != '' return errors end def validate? self.validate['base'] == [] end def hostipnumbers if self.ipHostNumber == nil then results = [] else results = self.ipHostNumber.to_a.sort {|a,b| a <=> b }.collect { |ipnumber| ipnumber } end return results end def hostipnumbers_columnized if self.ipHostNumber == nil then results = [] else results = self.ipHostNumber.to_a.sort {|a,b| a <=> b }.collect { |ipnumber| ipnumber }.join("\n") end return results end def hostpeople if self.people != nil then self.people.map{|person| person.uid}.sort{|a,b| a <=>b } else '' end end def self.allhosts results = Array.new hosts = Host.find(:all, '*').sort {|a,b| a.cn <=> b.cn} for host in hosts results << host.cn end return results end end From kou at cozmixng.org Fri Aug 31 13:26:46 2012 From: kou at cozmixng.org (Kouhei Sutou) Date: Fri, 31 Aug 2012 22:26:46 +0900 (JST) Subject: [activeldap-discuss] [ANN] ActiveLdap 3.2.0 In-Reply-To: <171F6E37-0F4C-4868-9641-1EF539718694@ttiltd.com> References: <20120829.123950.1326674700870843590.kou@cozmixng.org> <171F6E37-0F4C-4868-9641-1EF539718694@ttiltd.com> Message-ID: <20120831.222645.1144403639782606839.kou@cozmixng.org> Hi, In <171F6E37-0F4C-4868-9641-1EF539718694 at ttiltd.com> "Re: [activeldap-discuss] [ANN] ActiveLdap 3.2.0" on Thu, 30 Aug 2012 13:38:18 -0700, Craig White wrote: > trying it but I ran into failures on my functional tests so I went to the console which I think shows what I am facing here (not just hosts but also people & groups but hosts here for the example). Thanks for your report. I've fixed it and released a new version. Could you try ActiveLdap 3.2.1? Thanks, -- kou From craig.white at ttiltd.com Fri Aug 31 16:57:50 2012 From: craig.white at ttiltd.com (Craig White) Date: Fri, 31 Aug 2012 09:57:50 -0700 Subject: [activeldap-discuss] [ANN] ActiveLdap 3.2.0 In-Reply-To: <20120831.222645.1144403639782606839.kou@cozmixng.org> References: <20120829.123950.1326674700870843590.kou@cozmixng.org> <171F6E37-0F4C-4868-9641-1EF539718694@ttiltd.com> <20120831.222645.1144403639782606839.kou@cozmixng.org> Message-ID: On Aug 31, 2012, at 6:26 AM, Kouhei Sutou wrote: > Hi, > > In <171F6E37-0F4C-4868-9641-1EF539718694 at ttiltd.com> > "Re: [activeldap-discuss] [ANN] ActiveLdap 3.2.0" on Thu, 30 Aug 2012 13:38:18 -0700, > Craig White wrote: > >> trying it but I ran into failures on my functional tests so I went to the console which I think shows what I am facing here (not just hosts but also people & groups but hosts here for the example). > > Thanks for your report. > I've fixed it and released a new version. > Could you try ActiveLdap 3.2.1? ---- that indeed fixed the issue - thanks. I only have one issue left with 3.2.1 (and probably 3.2.0 but I couldn't get this far with 3.2.0 to know) but I think something changed when using 'leaf' This console session in test environment I think demonstrates the problem: irb(main):160:0> @person = Person.new ... much snipped here ... irb(main):161:0> @person.gidNumber = 513 => 513 irb(main):162:0> @person.sambaSID = "S-1-5-21" => "S-1-5-21" irb(main):163:0> @person.givenName = "first_name" => "first_name" irb(main):164:0> @person.sn = "unittest_100" => "unittest_100" irb(main):165:0> @person.uid = "unittest_100" => "unittest_100" irb(main):166:0> @person.cn = "unittest_100" => "unittest_100" irb(main):167:0> @person.uidNumber = 50050 => 50050 irb(main):168:0> @person.homeDirectory = "/home/users/unittest_100" => "/home/users/unittest_100" irb(main):169:0> @person.valid? => true irb(main):170:0> @person.save => true So I'm good through this point, I've created a new LDAP Person and saved the record but now I need to add an 'addressbook' ou to this person and here's where the problem starts... irb(main):171:0> @leaf = ActiveLdap::Base.create => #, must:, may:<>, objectClass: ["top"]> irb(main):172:0> @leaf.add_class('organizationalUnit') => nil irb(main):173:0> @leaf.dn = "ou=addressbook," + @person.dn => "ou=addressbook,uid=unittest_100,ou=People,ou=test,dc=tti,dc=local" irb(main):174:0> @leaf.save TypeError: nil is not a symbol from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activemodel-3.2.8/lib/active_model/dirty.rb:143:in `attribute_change' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activemodel-3.2.8/lib/active_model/dirty.rb:117:in `block in changes' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activemodel-3.2.8/lib/active_model/dirty.rb:117:in `map' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activemodel-3.2.8/lib/active_model/dirty.rb:117:in `changes' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activeldap-3.2.1/lib/active_ldap/attribute_methods/dirty.rb:12:in `save' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/activeldap-3.2.1/lib/active_ldap/validations.rb:44:in `save' from (irb):174 from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start' from /usr/local/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `' from script/rails:6:in `require' from script/rails:6:in `
' Now the strange thing is that the 'leaf' is definitely created in LDAP because ldapsearch returns the entry... # addressbook, unittest_100, People, test, tti.local dn: ou=addressbook,uid=unittest_100,ou=People,ou=test,dc=tti,dc=local ou: addressbook objectClass: top objectClass: organizationalUnit but the error pretty much kills the running engine (or in this case, the test). Thanks Craig