From travis.dunn at intersigncorp.com Thu May 1 08:57:23 2008 From: travis.dunn at intersigncorp.com (Travis Dunn) Date: Thu, 1 May 2008 08:57:23 -0400 Subject: [Ruby-activeldap-discuss] unbinding a connection In-Reply-To: References: Message-ID: <30DC3E23-4D5C-4200-96A1-AD817DD5573E@intersigncorp.com> I have read through the discussions, the problem is things have changed a lot in the previous versions, methods that used to be there are no longer available. Unless I missed it somewhere. Just searched through the rdoc and saw no method for authenticate. On Apr 30, 2008, at 6:36 PM, Bodaniel Jeanes wrote: > Save the anonymous bind connection object and re-assign it after the > authentication bind... there have been 3 or 4 discussions about this > on this mailing list. have you tried reading through them to see if it > solves your problem? You don't need to bind to authenticate a user > anyway, there is an authenticate method to handle this, and i believe > it doesn't touch the currently bound connection > > Bo > > On Thu, May 1, 2008 at 1:02 AM, Travis Dunn > wrote: >> I have an anonymous bind setup, but I am also using bind to >> authenticate >> users. I don't want the user authenticated to stay bound. I want >> it to try >> the bind, if it is success I want it to disconnect and the next >> time ldap is >> hit it should use the anonymous bind. How is the best way to >> handle this? >> I cannot get unbind to work, not sure what else to try. >> >> Thanks, >> >> Travis >> _______________________________________________ >> Ruby-activeldap-discuss mailing list >> Ruby-activeldap-discuss at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss >> > _______________________________________________ > Ruby-activeldap-discuss mailing list > Ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss From me at bjeanes.com Thu May 1 18:52:16 2008 From: me at bjeanes.com (Bodaniel Jeanes) Date: Fri, 2 May 2008 08:52:16 +1000 Subject: [Ruby-activeldap-discuss] unbinding a connection In-Reply-To: <30DC3E23-4D5C-4200-96A1-AD817DD5573E@intersigncorp.com> References: <30DC3E23-4D5C-4200-96A1-AD817DD5573E@intersigncorp.com> Message-ID: > I have read through the discussions, the problem is things have changed a > lot in the previous versions, methods that used to be there are no longer > available. Unless I missed it somewhere. Just searched through the rdoc > and saw no method for authenticate. No you are completely right. I haven't used this library for about a month and forgot I wrote my own wrapper. def authenticate(user, password) user = find_by_login(user) if user.is_a? String user if user.bind(password) rescue false end That doesn't solve your problem though because it stays binded as `user` ... I remember seeing something in the mailing lists that was vaguely something like this (i am typing it and haven't tested it though) def authenticate(user, password) user = find_by_login(user) if user.is_a? String @connection = user.connection user if user.bind(password) rescue false ensure user.connection = @connection end consider that pseudo code cuz i don't think that will work but i think i remember seeing a solution based around that concept (saving the existing connection, then restoring it post-authenticate). Nonetheless you could play around with that in irb and see what you come up with... Bo From kou at cozmixng.org Fri May 2 06:52:05 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Fri, 02 May 2008 19:52:05 +0900 (JST) Subject: [Ruby-activeldap-discuss] problem building trunk In-Reply-To: <278DBFEA-55EC-4BFA-8A03-08E00F976528@unimelb.edu.au> References: <278DBFEA-55EC-4BFA-8A03-08E00F976528@unimelb.edu.au> Message-ID: <20080502.195205.552167422295473940.kou@cozmixng.org> Hi, In <278DBFEA-55EC-4BFA-8A03-08E00F976528 at unimelb.edu.au> "[Ruby-activeldap-discuss] problem building trunk" on Wed, 30 Apr 2008 13:39:42 +1000, Iain Pople wrote: > I am having trouble builiding the latest version from the SVN > repository on google code: > > # rake install > (in /home/usr/its/ipople/src/activeldap/ruby-activeldap-read-only) > rake aborted! > No such file or directory - README.txt > /home/usr/its/ipople/src/activeldap/ruby-activeldap-read-only/Rakefile: > 48:in `new' > (See full trace by running task with --trace) I've fixed in trunk. Thanks for reporting. -- kou From ipople at unimelb.edu.au Tue May 6 20:10:55 2008 From: ipople at unimelb.edu.au (Iain Pople) Date: Wed, 07 May 2008 10:10:55 +1000 Subject: [Ruby-activeldap-discuss] error with DN In-Reply-To: References: Message-ID: I am still getting the same issue, using the latest version from trunk. On 22/04/2008, at 10:59 AM, Kouhei Sutou wrote: > Hi, > > 2008/4/21 Iain Pople : > >> I am getting some strange results with the latest version of >> Activeldap (0.10.0). For some entries the DN is getting mixed up. For >> example we have a schema for representing subnets: > >>>> s1 = Subnet.find("172.22.153.192/26") >>>> s1.unimelbipregsubnetcidr >> => "172.22.153.192/26" >>>> s1.dn >> => "unimelbipregsubnetcidr=172.22.153.192/26,ou=Resources,o=The >> University of Melbourne, c=AU" >> >> This is correct. However some entries have started displaying >> incorrectly: >> >>>> s2 = Subnet.find("128.250.161.192/26") >>>> s2.unimelbipregsubnetcidr >> => "unimelbIPREGsubnetcidr=128.250.161.192/26, ou=Resources, o=The >> University of Melbourne, c=AU" >>>> s2.dn >> => "unimelbipregsubnetcidr=unimelbIPREGsubnetcidr=128.250.161.192/26, >> ou=Resources, o=The University of Melbourne, c=AU,ou=Resources,o=The >> University of Melbourne, c=AU" > > > Thanks for reporting. > I've fixed in trunk. > > Thanks, > -- > kou > _______________________________________________ > Ruby-activeldap-discuss mailing list > Ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss -- Iain Pople Systems Interface Technical Lead University of Melbourne (p) 8344 3522 From kou at cozmixng.org Wed May 7 19:40:51 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 8 May 2008 08:40:51 +0900 Subject: [Ruby-activeldap-discuss] error with DN In-Reply-To: References: Message-ID: Hi, 2008/5/7 Iain Pople : > I am still getting the same issue, using the latest version from trunk. Does test script work on your environment? % cp test/config.yaml{.sample,} % vim test/config.yaml % test/run-test.rb -n test_normalize_dn_attribute Thanks, -- kou From kou at cozmixng.org Sun May 11 06:08:41 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Sun, 11 May 2008 19:08:41 +0900 (JST) Subject: [Ruby-activeldap-discuss] 1.0.0? Message-ID: <20080511.190841.860686987889279900.kou@cozmixng.org> Hi Will, It seems that ActiveLdap became stable for releasing 1.0.0. What do you think about this? Thanks, -- kou From atapiador at dit.upm.es Thu May 22 04:53:24 2008 From: atapiador at dit.upm.es (Antonio Tapiador del Dujo) Date: Thu, 22 May 2008 10:53:24 +0200 Subject: [Ruby-activeldap-discuss] ActiveLdap and ActiveRecord compatibility Message-ID: <200805221053.24361.atapiador@dit.upm.es> Hi there! I'm playing with ActiveLdap in Rails I'm fetching Users from a LDAP directory. I'll wish to set up relations with ActiveRecord models, for example Users Profile: class User < ActiveLdap::Base ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=users', :classes => ['uidObject','inetOrgPerson','top'] end class Profile < ActiveRecord::Base belongs_to :user end But I get errors related to the user_id foreign key in profiles table ** Using an Integer user_id: TypeError: can't convert Fixnum into String ** User a String user_id, the id is correctly saved but I get: >> profile.user ArgumentError: Unknown key(s): conditions, include from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/hash/keys.rb:49:in `assert_valid_keys' from /usr/lib/ruby/1.8/active_ldap/operations.rb:107:in `validate_search_options' from /usr/lib/ruby/1.8/active_ldap/operations.rb:28:in `search' from /usr/lib/ruby/1.8/active_ldap/operations.rb:211:in `find_every' from /usr/lib/ruby/1.8/active_ldap/operations.rb:191:in `find_initial' from /usr/lib/ruby/1.8/active_ldap/operations.rb:251:in `find_one' from /usr/lib/ruby/1.8/active_ldap/operations.rb:238:in `find_from_dns' from /usr/lib/ruby/1.8/active_ldap/operations.rb:185:in `find' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/belongs_to_association.rb:44:in `find_target' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_proxy.rb:133:in `load_target' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_proxy.rb:55:in `reload' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations.rb:992:in `user' Is there any way to set relations between ActiveLdap and ActiveRecord models? From kou at cozmixng.org Sun May 25 02:12:12 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Sun, 25 May 2008 15:12:12 +0900 (JST) Subject: [Ruby-activeldap-discuss] ActiveLdap and ActiveRecord compatibility In-Reply-To: <200805221053.24361.atapiador@dit.upm.es> References: <200805221053.24361.atapiador@dit.upm.es> Message-ID: <20080525.151212.60114407179262768.kou@cozmixng.org> Hi, In <200805221053.24361.atapiador at dit.upm.es> "[Ruby-activeldap-discuss] ActiveLdap and ActiveRecord compatibility" on Thu, 22 May 2008 10:53:24 +0200, Antonio Tapiador del Dujo wrote: > I'm fetching Users from a LDAP directory. I'll wish to set up relations with > ActiveRecord models, for example Users Profile: > > class User < ActiveLdap::Base > ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=users', :classes => > ['uidObject','inetOrgPerson','top'] > end > > class Profile < ActiveRecord::Base > belongs_to :user > end > > But I get errors related to the user_id foreign key in profiles table > > ** Using an Integer user_id: > TypeError: can't convert Fixnum into String > > ** User a String user_id, the id is correctly saved but I get: > >> profile.user > ArgumentError: Unknown key(s): conditions, include There are no idea to integrate ActiveRecord's associations because they use SQL to associate objects. ActiveLdap can't process SQL because it's a library for LDAP. > Is there any way to set relations between ActiveLdap and ActiveRecord models? Just define a method for now: class Profile < ActiveRecord::Base def user User.find(user_id) end end Thanks, -- kou From kou at cozmixng.org Sun May 25 02:12:56 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Sun, 25 May 2008 15:12:56 +0900 (JST) Subject: [Ruby-activeldap-discuss] 1.0.0? In-Reply-To: <20080511.190841.860686987889279900.kou@cozmixng.org> References: <20080511.190841.860686987889279900.kou@cozmixng.org> Message-ID: <20080525.151256.17016428418609130.kou@cozmixng.org> Hi Will, Are you busy? What do you think about this? Thanks, -- kou In <20080511.190841.860686987889279900.kou at cozmixng.org> "[Ruby-activeldap-discuss] 1.0.0?" on Sun, 11 May 2008 19:08:41 +0900 (JST), Kouhei Sutou wrote: > Hi Will, > > It seems that ActiveLdap became stable for releasing 1.0.0. > What do you think about this? > > > Thanks, > -- > kou > _______________________________________________ > Ruby-activeldap-discuss mailing list > Ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss From kou at cozmixng.org Mon May 26 09:37:18 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Mon, 26 May 2008 22:37:18 +0900 (JST) Subject: [Ruby-activeldap-discuss] 1.0.0? In-Reply-To: References: <20080511.190841.860686987889279900.kou@cozmixng.org> <20080525.151256.17016428418609130.kou@cozmixng.org> Message-ID: <20080526.223718.489000832292460857.kou@cozmixng.org> Hi Will, In "Re: [Ruby-activeldap-discuss] 1.0.0?" on Sun, 25 May 2008 18:34:05 -0700, "Will_Drewry?" wrote: > Sorry for the delay! I was swamped, and I lost track of the first > message. I think a 1.0.0 release sounds awesome! Let me know if your > happy with trunk, and I'll tag and release (unless you'd like to) - > then maybe go buy a nice bottle of wine :) I've already updated CHANGES. Some bugs reported after 0.10.0 are fixed in trunk. It's ready to release 1.0.0. Please do. :) Your ActiveLdap library will get a precious day. Thanks, -- kou From graf0 at post.pl Tue May 27 04:19:31 2008 From: graf0 at post.pl (=?ISO-8859-2?Q?Grzegorz_Marsza=B3ek?=) Date: Tue, 27 May 2008 10:19:31 +0200 Subject: [Ruby-activeldap-discuss] 1.0.0? In-Reply-To: <20080525.151256.17016428418609130.kou@cozmixng.org> References: <20080511.190841.860686987889279900.kou@cozmixng.org> <20080525.151256.17016428418609130.kou@cozmixng.org> Message-ID: <2428C1CC-F025-406D-BA94-BD947A823B78@post.pl> Wiadomo?? napisana w dniu 2008-05-25, o godz 08:12, przez Kouhei Sutou: > Hi Will, > > Are you busy? > What do you think about this? > I think it's ok. Now I'm trying to migrate my whole application to ldap (it's kind of computer management app - and it's much cleaner to use ldap and replication, than fight with sql and sync'ing all those settings via files on each server and workstation), and I really like activeldap :) --- Grzegorz Marsza?ek graf0 at post.pl From kou at cozmixng.org Tue May 27 07:40:10 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Tue, 27 May 2008 20:40:10 +0900 (JST) Subject: [Ruby-activeldap-discuss] 1.0.0? In-Reply-To: References: <20080526.223718.489000832292460857.kou@cozmixng.org> Message-ID: <20080527.204010.821754431954581335.kou@cozmixng.org> Hi, In "Re: [Ruby-activeldap-discuss] 1.0.0?" on Mon, 26 May 2008 09:29:13 -0700, "Will_Drewry?" wrote: > > I've already updated CHANGES. Some bugs reported after > > 0.10.0 are fixed in trunk. It's ready to release 1.0.0. > > Please do. :) Your ActiveLdap library will get a precious > > day. > > I've posted the gem and the tarball to rubyforge. If anyone can give > 'em a quick test, that'd be great! If everything looks good, I'll post > a news item as well. Unfortunately, I found a GetText related bug that had been fixed in trunk... But it's OK for me to announce 1.0.0 if others don't have a problem. The fix will be shipped in the next release. Thanks, -- kou From jeremypruitt at mac.com Tue May 27 15:36:26 2008 From: jeremypruitt at mac.com (Jeremy Pruitt) Date: Tue, 27 May 2008 12:36:26 -0700 Subject: [Ruby-activeldap-discuss] Can't get has_many to work... Message-ID: I posed a similar question to the list back in January, and Kou applied something to trunk and I never went back to verify. Now that the 1.0 release is out I?m assuming that change made it into the 1.0 release. I am trying once again to make has_many work by returning the members of a group. Here is my model info: class User < ActiveLdap::Base ldap_mapping :dn_attribute => "uid", :prefix => "ou=people", :classes => ["top"] belongs_to :groups, :class => 'Group', :many => 'member', :foreign_key => 'dn' end class Group < ActiveLdap::Base ldap_mapping :dn_attribute => 'cn', :prefix => "ou=authorizationgroups,ou=groups", :classes => ["authorizationGroup"] has_many :users, :class => 'User', :wrap => 'member', :primary_key => 'dn' end ?Member? is a dn, by the way. This works: user = User.find('jpruitt') user.groups.each{|a| puts "USER.GROUPS: #{a.id}"} And prints out the fact that jpruitt is in the it-people group, but this doesn?t group = Group.find('it-people') group.users.each{|a| puts "GROUP.USERS: #{a.id}"} No error, it just doesn't return anything. Also, I can print out the list of attributes for the given group, so it does successfully find the group, just not the users in the group. So, my belongs_to always seems to work, but my has_many never does. Any ideas? - Thanks for your help! :) From kou at cozmixng.org Tue May 27 20:36:42 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Wed, 28 May 2008 09:36:42 +0900 Subject: [Ruby-activeldap-discuss] Can't get has_many to work... In-Reply-To: References: Message-ID: Hi, 2008/5/28 Jeremy Pruitt : > class Group < ActiveLdap::Base > ldap_mapping :dn_attribute => 'cn', > :prefix => "ou=authorizationgroups,ou=groups", > :classes => ["authorizationGroup"] > has_many :users, > :class => 'User', > :wrap => 'member', > :primary_key => 'dn' > end > > ?Member? is a dn, by the way. > > This works: > user = User.find('jpruitt') > user.groups.each{|a| puts "USER.GROUPS: #{a.id}"} > > And prints out the fact that jpruitt is in the it-people group, but this doesn?t > group = Group.find('it-people') > group.users.each{|a| puts "GROUP.USERS: #{a.id}"} > > No error, it just doesn't return anything. Could you show us a your group entry? e.g.: group = Group.find('it-people') puts group.to_ldif Thanks, -- kou From jeremypruitt at mac.com Wed May 28 02:31:37 2008 From: jeremypruitt at mac.com (Jeremy Pruitt) Date: Tue, 27 May 2008 23:31:37 -0700 Subject: [Ruby-activeldap-discuss] Can't get has_many to work... In-Reply-To: References: Message-ID: Here it is. Perhaps the authGroupName in the dn is causing problems? version: 1 dn: authGroupName=it-people,ou=authorizationgroups,ou=groups,dc=,dc= authGroupAdmin: jpruitt authGroupAdmin: jpruitt authGroupDelegate: juser authGroupName: it-people authGroupOwner: jpruitt cn: it-people contributingImportedGroup: it-people@ description: IT People member: uid=jpruitt,ou=people,dc=,dc= member: uid=juser,ou=people,dc=,dc= ... objectClass: authorizationGroup objectClass: groupOfNames ou: authorizationgroups ou: groups - Thanks again! On Tuesday, May 27, 2008, at 05:36PM, "Kouhei Sutou" wrote: >Hi, > >2008/5/28 Jeremy Pruitt : > >> class Group < ActiveLdap::Base >> ldap_mapping :dn_attribute => 'cn', >> :prefix => "ou=authorizationgroups,ou=groups", >> :classes => ["authorizationGroup"] >> has_many :users, >> :class => 'User', >> :wrap => 'member', >> :primary_key => 'dn' >> end >> >> ?Member? is a dn, by the way. >> >> This works: >> user = User.find('jpruitt') >> user.groups.each{|a| puts "USER.GROUPS: #{a.id}"} >> >> And prints out the fact that jpruitt is in the it-people group, but this doesn?t >> group = Group.find('it-people') >> group.users.each{|a| puts "GROUP.USERS: #{a.id}"} >> >> No error, it just doesn't return anything. > >Could you show us a your group entry? e.g.: > > group = Group.find('it-people') > puts group.to_ldif > > >Thanks, >-- >kou >_______________________________________________ >Ruby-activeldap-discuss mailing list >Ruby-activeldap-discuss at rubyforge.org >http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss > > From kou at cozmixng.org Wed May 28 02:57:15 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Wed, 28 May 2008 15:57:15 +0900 Subject: [Ruby-activeldap-discuss] Can't get has_many to work... In-Reply-To: References: Message-ID: Hi, 2008/5/28 Jeremy Pruitt : > Here it is. Perhaps the authGroupName in the dn is causing problems? Thanks. > member: uid=jpruitt,ou=people,dc=,dc= > member: uid=juser,ou=people,dc=,dc= Uhm... Does this work? User.find("uid=jpruitt,ou=people,dc=,dc=") And this? Group.find('it-people').member.each do |member| p [member, User.find(member).dn] end -- kou From dpierce at redhat.com Wed May 28 09:14:08 2008 From: dpierce at redhat.com (Darryl L. Pierce) Date: Wed, 28 May 2008 09:14:08 -0400 Subject: [Ruby-activeldap-discuss] Making :prefix configurable... Message-ID: <483D5AA0.6090409@redhat.com> On my project we're using ActiveLdap and extending ActiveLdap::Base to represent a user account. However, we need to make the :prefix in the ldap_mapping configurable, placing the value into our ldap.yml file. I'm fairly new to Ruby and am having an issue getting this to be configurable. When I try the following, I get an error that the key "prefix" is invalid: ---8<[config/ldap.yml]--- development: prefix: cn=users,cn=accounts ---8<[end]--- ---8<[app/models/account.rb]--- class Account < ActiveLdap::Base @@config = YAML::load(File.open("/usr/share/ovirt-wui/config/ldap.yml")) ldap_mapping :dn_attribute => 'cn', :scope => :one, :prefix => @@config[ENV['RAILS_ENV']]['prefix'] end ---8<[snip]--- Any help would be appreciated. -- Darryl L. Pierce, Sr. Software Engineer Red Hat, Inc. - http://www.redhat.com/ oVirt - Virtual Machine Management - http://www.ovirt.org/ "What do you care what other people think, Mr. Feynman?" -------------- next part -------------- A non-text attachment was scrubbed... Name: dpierce.vcf Type: text/x-vcard Size: 298 bytes Desc: not available URL: From jeremypruitt at mac.com Wed May 28 17:33:29 2008 From: jeremypruitt at mac.com (Jeremy Pruitt) Date: Wed, 28 May 2008 14:33:29 -0700 Subject: [Ruby-activeldap-discuss] Can't get has_many to work... In-Reply-To: References: Message-ID: The first one works, but the Group.find results in this: /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:283:in `find_one': Couldn't find User: DN: uid=jpruitt,ou=people,dc=,dc=: filter: ["uid", "uid=jpruitt,ou=people,dc=,dc="] (ActiveLdap::EntryNotFound) from /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:258:in `find_from_dns' from /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:204:in `find' from ./getpup.rb:189:in `process_command' from ./getpup.rb:187:in `each' from ./getpup.rb:187:in `process_command' from ./getpup.rb:61:in `run' from ./getpup.rb:269 Perhaps that "uid" in the filter is causing problems? - Thank you! :) On Tuesday, May 27, 2008, at 11:57PM, "Kouhei Sutou" wrote: >Hi, > >2008/5/28 Jeremy Pruitt : >> Here it is. Perhaps the authGroupName in the dn is causing problems? > >Thanks. > >> member: uid=jpruitt,ou=people,dc=,dc= >> member: uid=juser,ou=people,dc=,dc= > >Uhm... > >Does this work? > User.find("uid=jpruitt,ou=people,dc=,dc=") > >And this? > Group.find('it-people').member.each do |member| > p [member, User.find(member).dn] > end > >-- >kou >_______________________________________________ >Ruby-activeldap-discuss mailing list >Ruby-activeldap-discuss at rubyforge.org >http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss > > From kou at cozmixng.org Wed May 28 20:01:23 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 29 May 2008 09:01:23 +0900 Subject: [Ruby-activeldap-discuss] Can't get has_many to work... In-Reply-To: References: Message-ID: Hi, 2008/5/29 Jeremy Pruitt : > The first one works, but the Group.find results in this: > > /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:283:in `find_one': Couldn't find User: DN: uid=jpruitt,ou=people,dc=,dc=: filter: ["uid", "uid=jpruitt,ou=people,dc=,dc="] (ActiveLdap::EntryNotFound) > from /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:258:in `find_from_dns' > from /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:204:in `find' > from ./getpup.rb:189:in `process_command' > from ./getpup.rb:187:in `each' > from ./getpup.rb:187:in `process_command' > from ./getpup.rb:61:in `run' > from ./getpup.rb:269 Thanks. I've fixed in trunk. -- kou From jeremypruitt at mac.com Thu May 29 04:15:30 2008 From: jeremypruitt at mac.com (Jeremy Pruitt) Date: Thu, 29 May 2008 01:15:30 -0700 Subject: [Ruby-activeldap-discuss] Can't get has_many to work... In-Reply-To: <20040210001224.31925.qmail@moses.com> References: <20040210001224.31925.qmail@moses.com> Message-ID: First of all, thank you for your prompt assistance. :) I'll try to list the steps I took. # I installed from trunk: svn checkout http://ruby-activeldap.googlecode.com/svn/trunk/ ruby-activeldap-read-only cd ruby-activeldap-read-only rake install # And verified with this command: ruby -r active_ldap -e 'p ActiveLdap::VERSION' # Which returns: "1.0.1" # Your Group.find works: Group.find('it-people').member.each do |member| p [member, User.find(member).dn] end # And returns things like this: [#"jpruitt"}, {"ou"=>"people"}, {"dc"=>""}, {"dc"=>""}]>, "uid=jpruitt,ou=people,dc=,dc="] # But shouldn't this work as well? Group.find('it-people').users.each do |user| p user end # That is giving me the following error: /usr/lib/ruby/site_ruby/1.8/active_ldap/base.rb:1076:in `set_attribute': uid is unknown attribute (ActiveLdap::UnknownAttribute) from /usr/lib/ruby/site_ruby/1.8/active_ldap/base.rb:614:in `dn=' from /usr/lib/ruby/site_ruby/1.8/active_ldap/base.rb:520:in `initialize_without_callbacks' from /usr/lib/ruby/site_ruby/1.8/active_ldap/callbacks.rb:44:in `initialize' from /usr/lib/ruby/site_ruby/1.8/active_ldap/association/has_many_wrap.rb:41:in `new' from /usr/lib/ruby/site_ruby/1.8/active_ldap/association/has_many_wrap.rb:41:in `find_target' from /usr/lib/ruby/site_ruby/1.8/active_ldap/association/has_many_wrap.rb:40:in `collect' from /usr/lib/ruby/site_ruby/1.8/active_ldap/association/has_many_wrap.rb:40:in `find_target' from /usr/lib/ruby/site_ruby/1.8/active_ldap/association/proxy.rb:78:in `load_target' from /usr/lib/ruby/site_ruby/1.8/active_ldap/association/collection.rb:9:in `to_ary' from /usr/lib/ruby/site_ruby/1.8/active_ldap/association/collection.rb:25:in `each' from ./getpup.rb:185:in `process_command' from ./getpup.rb:61:in `run' from ./getpup.rb:269 - Jeremy On Wednesday, May 28, 2008, at 05:01PM, "Kouhei Sutou" wrote: >Hi, > >2008/5/29 Jeremy Pruitt : >> The first one works, but the Group.find results in this: >> >> /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:283:in `find_one': Couldn't find User: DN: uid=jpruitt,ou=people,dc=,dc=: filter: ["uid", "uid=jpruitt,ou=people,dc=,dc="] (ActiveLdap::EntryNotFound) >> from /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:258:in `find_from_dns' >> from /usr/lib/ruby/gems/1.8/gems/activeldap-1.0.0/lib/active_ldap/operations.rb:204:in `find' >> from ./getpup.rb:189:in `process_command' >> from ./getpup.rb:187:in `each' >> from ./getpup.rb:187:in `process_command' >> from ./getpup.rb:61:in `run' >> from ./getpup.rb:269 > >Thanks. >I've fixed in trunk. > >-- >kou >_______________________________________________ >Ruby-activeldap-discuss mailing list >Ruby-activeldap-discuss at rubyforge.org >http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss > > From kou at cozmixng.org Thu May 29 04:47:02 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 29 May 2008 17:47:02 +0900 Subject: [Ruby-activeldap-discuss] Can't get has_many to work... In-Reply-To: References: <20040210001224.31925.qmail@moses.com> Message-ID: Hi, 2008/5/29 Jeremy Pruitt : > # But shouldn't this work as well? > > Group.find('it-people').users.each do |user| > p user > end Yes. I've fixed this. > # That is giving me the following error: > > /usr/lib/ruby/site_ruby/1.8/active_ldap/base.rb:1076:in `set_attribute': uid is unknown attribute (ActiveLdap::UnknownAttribute) This is an another problem. It's better that you add suitable objectClasses into your User.ldap_mapping's :classes option. Thanks, -- kou From kou at cozmixng.org Thu May 29 07:21:35 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 29 May 2008 20:21:35 +0900 (JST) Subject: [Ruby-activeldap-discuss] Making :prefix configurable... In-Reply-To: <483D5AA0.6090409@redhat.com> References: <483D5AA0.6090409@redhat.com> Message-ID: <20080529.202135.336837271500224037.kou@cozmixng.org> Hi, In <483D5AA0.6090409 at redhat.com> "[Ruby-activeldap-discuss] Making :prefix configurable..." on Wed, 28 May 2008 09:14:08 -0400, "Darryl L. Pierce" wrote: > On my project we're using ActiveLdap and extending ActiveLdap::Base to > represent a user account. However, we need to make the :prefix in the > ldap_mapping configurable, placing the value into our ldap.yml file. > > I'm fairly new to Ruby and am having an issue getting this to be > configurable. When I try the following, I get an error that the key > "prefix" is invalid: > > ---8<[config/ldap.yml]--- > development: > prefix: cn=users,cn=accounts > ---8<[end]--- > > ---8<[app/models/account.rb]--- > class Account < ActiveLdap::Base > @@config = YAML::load(File.open("/usr/share/ovirt-wui/config/ldap.yml")) > > ldap_mapping :dn_attribute => 'cn', :scope => :one, :prefix => > @@config[ENV['RAILS_ENV']]['prefix'] > end > ---8<[snip]--- > > Any help would be appreciated. What about this? development: base: cn=accounts class Account < ActiveLdap::Base ldap_mapping :dn_attribute => 'cn', :scope => :one, :prefix => "cn=users" end Thanks, -- kou From kou at cozmixng.org Thu May 29 07:35:37 2008 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 29 May 2008 20:35:37 +0900 (JST) Subject: [Ruby-activeldap-discuss] Making :prefix configurable... In-Reply-To: <20080529.202135.336837271500224037.kou@cozmixng.org> References: <483D5AA0.6090409@redhat.com> <20080529.202135.336837271500224037.kou@cozmixng.org> Message-ID: <20080529.203537.445736152630579918.kou@cozmixng.org> In <20080529.202135.336837271500224037.kou at cozmixng.org> "Re: [Ruby-activeldap-discuss] Making :prefix configurable..." on Thu, 29 May 2008 20:21:35 +0900 (JST), Kouhei Sutou wrote: > In <483D5AA0.6090409 at redhat.com> > "[Ruby-activeldap-discuss] Making :prefix configurable..." on Wed, 28 May 2008 09:14:08 -0400, > "Darryl L. Pierce" wrote: > > > On my project we're using ActiveLdap and extending ActiveLdap::Base to > > represent a user account. However, we need to make the :prefix in the > > ldap_mapping configurable, placing the value into our ldap.yml file. > > > > I'm fairly new to Ruby and am having an issue getting this to be > > configurable. When I try the following, I get an error that the key > > "prefix" is invalid: > > > > ---8<[config/ldap.yml]--- > > development: > > prefix: cn=users,cn=accounts > > ---8<[end]--- > > > > ---8<[app/models/account.rb]--- > > class Account < ActiveLdap::Base > > @@config = YAML::load(File.open("/usr/share/ovirt-wui/config/ldap.yml")) > > > > ldap_mapping :dn_attribute => 'cn', :scope => :one, :prefix => > > @@config[ENV['RAILS_ENV']]['prefix'] > > end > > ---8<[snip]--- > > > > Any help would be appreciated. > > What about this? > > development: > base: cn=accounts > > class Account < ActiveLdap::Base > ldap_mapping :dn_attribute => 'cn', :scope => :one, :prefix => "cn=users" > end Or development: base: cn=users,cn=accounts class Account < ActiveLdap::Base ldap_mapping :dn_attribute => 'cn', :scope => :one, :prefix => "" end BTW, you can access the current configuration by ActiveLdap::Base.configurations[RAILS_ENV]. If you really want to change config/ldap.yml validation behavior, do the following: ActiveLdap::Configuration::ClassMethods::CONNECTION_CONFIGURATION_KEYS << :prefix Thanks, -- kou From MR-Mencel at wiu.edu Thu May 29 18:04:42 2008 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Thu, 29 May 2008 17:04:42 -0500 (CDT) Subject: [Ruby-activeldap-discuss] Retrieving all users with the same attribute value? In-Reply-To: <437044841.121461212098177581.JavaMail.root@zcs8.wiu.edu> Message-ID: <433618205.121691212098682328.JavaMail.root@zcs8.wiu.edu> So I've started a separate file with my ldap queries in it that I include in my main program(listed below). What I'm trying to figure out is how to make the in_department? function work. All our users have an attribute of 'department'. How can I use ActiveLDAP to query and return every user who has a department attribute value of "Some Department"? Would it be something like this? users_in_dept = User.find(:all, :attribute => 'department', :value => 'Some Department').collect {|user| user.uid} By the way...in my functions below...do I have to put 'user = User.find(username)' to return the data? Or will it return the data from the function if I just leave out the 'user =' part and just make it 'User.find(username)'. Just trying to clean my code up a little if I'm being too redundant for Ruby. Thanks, Matt >>>>> wiuldap.rb require 'wiuconstants' class User < ActiveLdap::Base ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=People', :classes => ['top','wiuPerson'] end class Course < ActiveLdap::Base ldap_mapping :dn_attribute => 'wiuStarNumber', :prefix => 'ou=Courses', :classes => ['top','wiuCourse'] end ActiveLdap::Base.establish_connection(:host => 'ldap.wiu.edu', :port => 389, :base => 'dc=wiu,dc=com', :bind_dn => LdapUser, :password_block => Proc.new { LdapPW } ) # Retrieve the LDAP record for a user def ldapuser?(username) user = User.find(username) end # Retrieve the LDAP record for a course def ldapcourse?(starnum) course = Course.find(starnum) end # Retrieve users who are in a department def in_department?(department) users_in_dept = User.find(department) end <<<<< From lennon at reed.edu Thu May 29 18:48:50 2008 From: lennon at reed.edu (Lennon Day-Reynolds) Date: Thu, 29 May 2008 15:48:50 -0700 Subject: [Ruby-activeldap-discuss] Retrieving all users with the same attribute value? In-Reply-To: <433618205.121691212098682328.JavaMail.root@zcs8.wiu.edu> References: <433618205.121691212098682328.JavaMail.root@zcs8.wiu.edu> Message-ID: <1212101330.13328.14.camel@firefly.reed.edu> On Thu, 2008-05-29 at 17:04 -0500, Matt Mencel wrote: > So I've started a separate file with my ldap queries in it that I include in my main program(listed below). What I'm trying to figure out is how to make the in_department? function work. All our users have an attribute of 'department'. How can I use ActiveLDAP to query and return every user who has a department attribute value of "Some Department"? > > Would it be something like this? > > users_in_dept = User.find(:all, :attribute => 'department', :value => 'Some Department').collect {|user| user.uid} That will work, although you can also skip the last block and just return the User instances directly. So, your example could be restated like this: users_in_some_dept = User.find( :all, :attribute => 'department', :value => 'Some Department' ) ...and the resulting array of results would contain instances of the User class, rather than simply the username strings. > By the way...in my functions below...do I have to put 'user = User.find(username)' to return the data? Or will it return the data from the function if I just leave out the 'user =' part and just make it 'User.find(username)'. Just trying to clean my code up a little if I'm being too redundant for Ruby. You don't have to do the assignment; having the User.find(...) call as the last expression of your method definition will implicitly return the results. Finally, the use of the question-mark at the end of a method name has a fairly precise meaning in most Ruby code: it generally indicates that the method is a boolean predicate or test, rather than a general query or attribute accessor. So, reading 'in_department?("Foo")', I would expect the result to test whether some object was in the department named "Foo", and return true/false, not an array of matching objects. If you want to have really idiomatic Ruby code, though, you might consider making more of your top-level functions methods of the Course and User classes. Hope that helps, Lennon -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From MR-Mencel at wiu.edu Fri May 30 10:08:52 2008 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Fri, 30 May 2008 09:08:52 -0500 (CDT) Subject: [Ruby-activeldap-discuss] Retrieving all users with the same attribute value? In-Reply-To: <1212101330.13328.14.camel@firefly.reed.edu> Message-ID: <272819506.137651212156532033.JavaMail.root@zcs8.wiu.edu> Lennon, Thanks...that helped a lot. As far as restructuring my classes and such...are you saying I should put the methods that use each Class....inside the class? Sorry if it's a stupid question, but I'm still trying to figure out the "right" way to do object oriented programming in Ruby. Each Class might be in it's own file too? Something like this below? Thanks, Matt >>>>> require 'wiuconstants' class User < ActiveLdap::Base ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=People', :classes => ['top','wiuPerson'] # Retrieve the LDAP record for a user def user_info_from_ldap(username) User.find(username) end # Retrieve users who are in a department def users_in_department(dept_name) User.find( :all, :attribute => 'department', :value => 'dept_name' ) end end class Course < ActiveLdap::Base ldap_mapping :dn_attribute => 'wiuStarNumber', :prefix => 'ou=Courses', :classes => ['top','wiuCourse'] # Retrieve the LDAP record for a course def course_info_from_ldap(starnum) Course.find(starnum) end end ActiveLdap::Base.establish_connection(:host => 'ldap1.wiu.edu', :port => 389, :base => 'dc=wiu,dc=edu', :bind_dn => LdapUser, :password_block => Proc.new { LdapPW } ) <<<<< From MR-Mencel at wiu.edu Fri May 30 11:57:01 2008 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Fri, 30 May 2008 10:57:01 -0500 (CDT) Subject: [Ruby-activeldap-discuss] Using attribute_present? In-Reply-To: <1099228161.143811212162837173.JavaMail.root@zcs8.wiu.edu> Message-ID: <1478862946.144031212163021900.JavaMail.root@zcs8.wiu.edu> Here's a bit of my code. I'm trying to figure out how to use 'attribute_present?'. The 'users_in_department' query is returning a list of all users who's department name in LDAP is "Some Department". user_list = users_in_department("Some Department") user_list.each do |user| #puts user.dn if user.attribute_present?(wiuRegisteredStar) puts "Name: #{user.cn}" puts "COURSES: #{get_user_starnums(user)}" end end If I uncomment the first 'puts' line, I get the full dn of every user in the department...as soon as I try to check for the existence of the 'wiuRegisteredStar' attribute however my code bombs on the first user it finds who does not have that attribute...or so it seems. Here's the error I get. ./course_cal.rb:228: undefined local variable or method `wiuRegisteredStar' for main:Object (NameError) from ./course_cal.rb:224:in `each' from ./course_cal.rb:224 What am I doing wrong? Matt