From mortonda at dgrmm.net Fri May 1 19:04:48 2009 From: mortonda at dgrmm.net (David Morton) Date: Fri, 1 May 2009 18:04:48 -0500 Subject: [activeldap-discuss] I get the best errors... Input/Output error Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 When running in production mode in rails, I started to get a error raised: Input/Output error It works fine for a while, and then mysteriously stops. Resetting the mongrel server makes it work again. I wonder if has to do with recent bugs we found together with the base,prefix, or user not being who I think it is. It gets raised by this code: class UidNext < ActiveLdap::Base ldap_mapping :dn_attribute => 'cn', :prefix => '', :scope => :sub, :classes => ['uidNext'] require 'ldap' def self.uidNext tries = 0 begin result = search(:filter=>"(cn=uidNext)", :prefix=>"cn=uidNext", :attributes=>["uidNumber"]) if result.empty? raise "Can't find UidNext #$!" end currentuid = result.first[1]['uidNumber'].first.to_i nextuid = currentuid + 1 puts "nextuid = #{nextuid}" UidNext.connection.modify("cn=uidNext,dc=example,dc=com", [ [:delete, 'uidNumber' , {'uidNumber' => [currentuid.to_s]}] , [:add, 'uidNumber' , {'uidNumber' => [nextuid.to_s]}] ]) return currentuid rescue LDAP::ResultError => err if tries < 3 tries += 1 retry else raise end end end end One question, I see that I have a puts in there, which should probably be a logger. assuming this is run from a terminal that is later backgrounded and disconnected, could that be the error? David Morton Maia Mailguard http://www.maiamailguard.com mortonda at dgrmm.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iD8DBQFJ+4AQUy30ODPkzl0RAkjdAJ43MrvFMndfIY01FWPhnMWWtAG3xwCg1UJi NClsMM/Rndg4f1LD0yPzZUo= =spdS -----END PGP SIGNATURE----- From kou at cozmixng.org Fri May 1 23:24:59 2009 From: kou at cozmixng.org (Kouhei Sutou) Date: Sat, 02 May 2009 12:24:59 +0900 (JST) Subject: [activeldap-discuss] I get the best errors... Input/Output error In-Reply-To: References: Message-ID: <20090502.122459.195066307663380724.kou@cozmixng.org> Hi, In "[activeldap-discuss] I get the best errors... Input/Output error" on Fri, 1 May 2009 18:04:48 -0500, David Morton wrote: > When running in production mode in rails, I started to get a > error raised: > > Input/Output error > > > It works fine for a while, and then mysteriously stops. > Resetting the mongrel server makes it work again. > I wonder if has to do with recent bugs we found together > with the base,prefix, or user not being who I think it is. It seems that your LDAP server disconnects a connection from your Rails application. Could you tell us your LDAP backend (Ruby/LDAP or Net::LDAP) and ActiveLdap version? In ActiveLdap trunk, auto reconnection has been improved. trunk may have been fixed your problem. > One question, I see that I have a puts in there, which > should probably be a logger. assuming this is run from a > terminal that is later backgrounded and disconnected, could > that be the error? I'm sorry but I can't understand the sentences. (I'm not a native English speaker. :<) Could you explain it in more easy English? Thanks, -- kou From MR-Mencel at wiu.edu Thu May 7 12:11:43 2009 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Thu, 7 May 2009 11:11:43 -0500 (CDT) Subject: [activeldap-discuss] Return all attributes in a .find Message-ID: <253092172.2900151241712703892.JavaMail.root@zcs10> Is there a was to tell .find to return all attributes without specifying each one individually? User.find(:all, :attribute=> SOMEATTR, :value=> SOMEVAL, :attributes=>['attr1','attr2','attr3',etc...]) is how I do it now... Like this...? User.find(:all, :attribute=> SOMEATTR, :value=> SOMEVAL, :attributes=> :all) Thanks, Matt From tashen.hatena at gmail.com Sun May 10 05:10:54 2009 From: tashen.hatena at gmail.com (tashen) Date: Sun, 10 May 2009 18:10:54 +0900 Subject: [activeldap-discuss] Return all attributes in a .find In-Reply-To: <253092172.2900151241712703892.JavaMail.root@zcs10> References: <253092172.2900151241712703892.JavaMail.root@zcs10> Message-ID: <4A069A1E.1090803@gmail.com> Hi > User.find(:all, :attribute=> SOMEATTR, :value=> SOMEVAL, :attributes=> :all) You'll get all attributes by just removing the :attributes key. >> User.find(:all, :attribute => 'uid', :value => 'foo')[0].attribute_names => ["gidNumber", "cn", "userCertificate", "gecos", ...] Matt Mencel ????????: > Is there a was to tell .find to return all attributes without specifying each one individually? > > User.find(:all, :attribute=> SOMEATTR, :value=> SOMEVAL, :attributes=>['attr1','attr2','attr3',etc...]) is how I do it now... > > Like this...? > User.find(:all, :attribute=> SOMEATTR, :value=> SOMEVAL, :attributes=> :all) > > Thanks, > Matt > _______________________________________________ > ruby-activeldap-discuss mailing list > ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss -- tashen (Kazuaki Takase) http://d.hatena.ne.jp/tashen From alexey.chebotar at gmail.com Wed May 27 11:24:10 2009 From: alexey.chebotar at gmail.com (Alexey Chebotar) Date: Wed, 27 May 2009 18:24:10 +0300 Subject: [activeldap-discuss] Question about children with different objectClass Message-ID: <4A1D5B1A.5000404@gmail.com> Hello All. I have problem. I don't know how I can destroy entry from ldap with children when children have different objectClass. When children has the same objectClass as parent I can make some like this: org_unit.rb --- class OrgUnit < ActiveLdap::Base ldap_mapping :dn_attribute => "ou", :prefix => "", :classes => ['organizationalUnit'] end --- Create small tree: test_root = OrgUnit.create("test_root") test_child1 = OrgUnit.create(:ou => "test_child1", :parent => test_root) test_child2 = OrgUnit.create(:ou => "test_child2", :parent => test_root) test_child1_child1 = OrgUnit.create(:ou => "test_child1_child1", :parent => test_child1) test_root2 = OrgUnit.create("test_root2") Result: --- ou=test_root |-- ou=test_child1 | |-- ou=test_child1_child1 |-- ou=test_child2 ou=test_root2 --- >> test_root = OrgUnit.find "test_root" >> test_root.children => #, must:, may:<....>, ..., ou: ["test_root"], ...>, @options={}, @target=[], @loaded=false> >> test_root.children.reload >> test_root.children.target.each{|ch| p ch.ou};nil "test_child1" "test_child2" >> test_root.delete ActiveLdap::LdapError::NotAllowedOnNonleaf: Operation not allowed on non-leaf >> test_root.delete_all ... Removed all my tree with credentials. (I can't connect to LDAP if I close console :) ) >> ?> OrgUnit.find :all => [] Why test_root.delete_all removes all my tree 'ou=test_root' and 'ou=test_root2' and other children of parent (root) ? To remove entry with children I have wrote new method reverse_destroy: def reverse_destroy unless self.new_entry? self.find(:all, :base => self.dn, :scope => :sub).sort_by{|target| target.dn.reverse}.reverse.each{|target| target.destroy} end end >> test_child1 = OrgUnit.find "test_child1" >> test_child1.reverse_destroy => [#, must:, may:<...>, ..., ou: ["test_child1_child1"], ...>, #, must:, may:<...>, ..., ou: ["test_child1"], ..] >> test_root = OrgUnit.find "test_root" >> test_root.reverse_destroy => [#, must:, may:<...>, ..., ou: ["test_child2"], ...>, #, must:, may:<...>, ..., ou: ["test_root"], ...] This method works perfectly. But I don't know how to make deleting children with different objectClass. For examlple: test_domain.rb --- class TestDomain < ActiveLdap::Base ldap_mapping :dn_attribute => "dc", :prefix => "", :classes => ['domain'] end --- test_root = OrgUnit.create("test_root") test_child1 = OrgUnit.create(:ou => "test_child1", :parent => test_root) test_child2 = OrgUnit.create(:ou => "test_child2", :parent => test_root) test_child1_child1 = OrgUnit.create(:ou => "test_child1_child1", :parent => test_child1) test_root2 = OrgUnit.create("test_root2") test_domain1 = TestDomain.create(:dc => "test_domain1", :parent => test_child1) test_domain2 = TestDomain.create(:dc => "test_domain2", :parent => test_child2) Result: --- ou=test_root |-- ou=test_child1 | |-- dc=test_domain1 | |-- ou=test_child1_child1 |-- ou=test_child2 | |-- dc=test_domain2 ou=test_root2 --- Trying to destroy test_child2 child with children: >> test_child2 = OrgUnit.find "test_child2" >> test_child2.children => #, must:, may:<...>, ..., ou: ["test_child2"], ...>, @options={}, @target=[], @loaded=false> >> test_child2.children.reload => [] >> test_child2.children.target => [] >> test_child2.reverse_destroy ActiveLdap::DeleteError: Failed to delete LDAP entry: ou=test_child2,ou=test_root,dc=SLLR7-5N63N-EC3GV-RVS80-SGI4V,dc=i2pack,dc=ivocs,dc=com from /var/onm/vendor/plugins/activeldap-trunk/lib/active_ldap/base.rb:764:in `rescue in destroy' from /var/onm/vendor/plugins/activeldap-trunk/lib/active_ldap/base.rb:760:in `destroy' from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/callbacks.rb:337:in `destroy_with_callbacks' from /var/onm/app/models/org_unit.rb:6:in `block in reverse_destroy' from /var/onm/app/models/org_unit.rb:6:in `each' from /var/onm/app/models/org_unit.rb:6:in `reverse_destroy' from (irb):23 from /usr/bin/irb:12:in `
' >> test_domain1 = TestDomain.find("test_domain1") => #, must:, may:<..., dc: ["test_domain1"],..., objectClass: ["domain"], ...> >> test_domain1.parent => nil Hope, I wrote all what I want and don't forgot anything. Can somebody help me? :) From mrsanna1 at gmail.com Fri May 29 05:03:45 2009 From: mrsanna1 at gmail.com (Mauro) Date: Fri, 29 May 2009 11:03:45 +0200 Subject: [activeldap-discuss] problems with rails 2.3.2 and active_ldap. Message-ID: Hallo. First of all sorry for my bad english. I have really problems trying to use active_ldap. I have to use active_ldap gem or active_ldap plugin? Trying to use the plugin my steps were: /script/generate scaffold_active_ldap /script/generate model_active_ldap user /script/generate controller user I have my ldap.yml and the parameters are correct.? Then I launch script/server and try to connect to localhost:3000/user and my log says: /!\ FAILSAFE /!\ Fri May 29 11:03:09 +0200 2009 Status: 500 Internal Server Error could not open database: unable to open database file What I am wrong? From mrsanna1 at gmail.com Fri May 29 05:53:27 2009 From: mrsanna1 at gmail.com (Mauro) Date: Fri, 29 May 2009 11:53:27 +0200 Subject: [activeldap-discuss] test. Message-ID: sorry From kou at cozmixng.org Sun May 31 10:55:45 2009 From: kou at cozmixng.org (Kouhei Sutou) Date: Sun, 31 May 2009 23:55:45 +0900 (JST) Subject: [activeldap-discuss] Question about children with different objectClass In-Reply-To: <4A1D5B1A.5000404@gmail.com> References: <4A1D5B1A.5000404@gmail.com> Message-ID: <20090531.235545.338122493853641384.kou@cozmixng.org> Hi, In <4A1D5B1A.5000404 at gmail.com> "[activeldap-discuss] Question about children with different objectClass" on Wed, 27 May 2009 18:24:10 +0300, Alexey Chebotar wrote: >>> test_root.delete_all > ... Removed all my tree with credentials. (I can't connect > to LDAP if I close console :) ) >>> > ?> OrgUnit.find :all > => [] > > Why test_root.delete_all removes all my tree 'ou=test_root' > and 'ou=test_root2' and other children of parent (root) ? It seems that AcitveLdap's default value isn't good. What about the code? test_root.delete_all(nil, :base => nil) > Trying to destroy test_child2 child with children: > >>> test_child2 = OrgUnit.find "test_child2" >>> test_child2.children > => # @owner=#, > must:, may:<...>, ..., ou: ["test_child2"], > ...>, @options={}, @target=[], @loaded=false> >>> test_child2.children.reload > => [] >>> test_child2.children.target > => [] >>> test_child2.reverse_destroy > ActiveLdap::DeleteError: Failed to delete LDAP entry: > ou=test_child2,ou=test_root,dc=SLLR7-5N63N-EC3GV-RVS80-SGI4V,dc=i2pack,dc=ivocs,dc=com > from > /var/onm/vendor/plugins/activeldap-trunk/lib/active_ldap/base.rb:764:in > `rescue in destroy' > from > /var/onm/vendor/plugins/activeldap-trunk/lib/active_ldap/base.rb:760:in > `destroy' > from > /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/callbacks.rb:337:in > `destroy_with_callbacks' > from /var/onm/app/models/org_unit.rb:6:in `block in > reverse_destroy' > from /var/onm/app/models/org_unit.rb:6:in `each' > from /var/onm/app/models/org_unit.rb:6:in `reverse_destroy' > from (irb):23 > from /usr/bin/irb:12:in `
' >>> test_domain1 = TestDomain.find("test_domain1") > => #, must: objectClass>, may:<..., dc: ["test_domain1"],..., > objectClass: ["domain"], ...> >>> test_domain1.parent > => nil What about creating generic entry class? class Entry < ActiveLdap::Base ldap_mapping :prefix => "", :classes => ["top"], :scope => :sub end Entry.delete_all(:dn => test_child2.dn) I'm sorry but I didn't try the above suggestions. I don't have enough time for it... Thanks, -- kou From kou at cozmixng.org Sun May 31 11:00:24 2009 From: kou at cozmixng.org (Kouhei Sutou) Date: Mon, 01 Jun 2009 00:00:24 +0900 (JST) Subject: [activeldap-discuss] problems with rails 2.3.2 and active_ldap. In-Reply-To: References: Message-ID: <20090601.000024.507490017563662995.kou@cozmixng.org> Hi, In "[activeldap-discuss] problems with rails 2.3.2 and active_ldap." on Fri, 29 May 2009 11:03:45 +0200, Mauro wrote: > I have really problems trying to use active_ldap. > I have to use active_ldap gem or active_ldap plugin? You just need active_ldap gem. ActiveLdap plugin is included in the gem. > Trying to use the plugin my steps were: > > /script/generate scaffold_active_ldap > /script/generate model_active_ldap user > /script/generate controller user > > I have my ldap.yml and the parameters are correct.? > Then I launch script/server and try to connect to localhost:3000/user > and my log says: > > /!\ FAILSAFE /!\ Fri May 29 11:03:09 +0200 2009 > Status: 500 Internal Server Error > could not open database: unable to open database file > > What I am wrong? What ActiveLdap version are you using? We didn't release Rails 2.3.2 supported ActiveLdap yet. # Yes. We need to release it. You can't remove ActiveRecord from your Rails application for now. So you need to create config/database.yml. Thanks, -- kou From mrsanna1 at gmail.com Sun May 31 15:07:07 2009 From: mrsanna1 at gmail.com (Mauro) Date: Sun, 31 May 2009 21:07:07 +0200 Subject: [activeldap-discuss] problems with rails 2.3.2 and active_ldap. In-Reply-To: <20090601.000024.507490017563662995.kou@cozmixng.org> References: <20090601.000024.507490017563662995.kou@cozmixng.org> Message-ID: 2009/5/31 Kouhei Sutou : > Hi, > > In > ?"[activeldap-discuss] problems with rails 2.3.2 and active_ldap." on Fri, 29 May 2009 11:03:45 +0200, > ?Mauro wrote: > >> I have really problems trying to use active_ldap. >> I have to use active_ldap gem or active_ldap plugin? > > You just need active_ldap gem. ActiveLdap plugin is included > in the gem. Yes but....I have to use the plugin? The plugin alone can be donwloaded and installed so there is no need of the gem.