From kou at cozmixng.org Sun Jan 14 09:00:14 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Sun, 14 Jan 2007 23:00:14 +0900 (JST) Subject: [Ruby-activeldap-discuss] Licence Message-ID: <20070114.230014.25092496.kou@cozmixng.org> Hi, README says licence of ActiveLdap is GPL2 or later: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. Please see the file LICENSE for the terms of the licence. But LICENSE says licence of ActiveLdap is dual licence of GPL2 and Ruby Licence: Ruby is copyrighted free software by Yukihiro Matsumoto . You can redistribute it and/or modify it under either the terms of the GPL (see COPYING file), or the conditions below: ... I think (and I'm happy) that README is wrong. (ActiveLdap is dual licence.) Could you fix README? Thanks, -- kou From paul.hendrick at gmail.com Mon Jan 22 17:31:03 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Mon, 22 Jan 2007 22:31:03 +0000 Subject: [Ruby-activeldap-discuss] Using ActiveLdap 0.8 Message-ID: Hi all, i'm just starting an application and it'll be using active ldap. So just to learn the ropes I've started writing code to try and figure out how it all works. I have the following code: 1 require 'rubygems' 2 require_gem 'log4r' 3 require_gem 'ruby-activeldap' 4 5 class User < ActiveLdap::Base 6 ldap_mapping :dn_attribute=>"uid",:prefix=>"dc=city,dc=office,dc=com", :classes=>["officeAccount"] 7 end 8 9 ActiveLdap::Base.establish_connection( 10 :host=>"192.168.1.27", 11 :port=>389, 12 :bind_dn=>"cn=root,dc=office,dc=com", 13 :password=>"my_secret") 14 15 user = User.find("admin at office*") 16 puts user.cn 17 user.cn = "Testing MOD" 18 user.save it all works fine up until line 18, where I try to save the record. I can print the original cn attribute, but altering it causes all of the barf below. I've attached the ldap logs also. Any ideas what I might be doing wrong? /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/adaptor/ldap.rb:289:in `operation': No such object (LDAP::NoSuchObject) from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/timeout.rb:15:in `call' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/timeout.rb:15:in `alarm' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/adaptor/base.rb:19:in `with_timeout' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/adaptor/ldap.rb:297:in `with_timeout' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/adaptor/ldap.rb:285:in `operation' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/adaptor/ldap.rb:270:in `modify' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/base.rb:394:in `modify' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/base.rb:1339:in `update_without_callbacks' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/base.rb:1300:in `prepare_data_for_saving' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/base.rb:1335:in `update_without_callbacks' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/callbacks.rb:267:in `update' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/base.rb:1281:in `create_or_update_without_callbacks' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/callbacks.rb:242:in `create_or_update' from /usr/lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/base.rb:767:in `save_without_validation' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/validations.rb:752:in `save' from test.rb:18 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070122/b69d2913/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: ldap_log.log Type: text/x-log Size: 3757 bytes Desc: not available Url : http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070122/b69d2913/attachment-0001.bin From kou at cozmixng.org Mon Jan 22 22:30:27 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Tue, 23 Jan 2007 12:30:27 +0900 Subject: [Ruby-activeldap-discuss] Using ActiveLdap 0.8 In-Reply-To: References: Message-ID: Hi, 2007/1/23, paul hendrick : > 6 ldap_mapping > :dn_attribute=>"uid",:prefix=>"dc=city,dc=office,dc=com", > > :classes=>["officeAccount"] > I've attached the ldap logs also. Any ideas what I might be doing wrong? It seems that your dn_attribute is "uniqueIdentifier" not "uid". Thanks, -- kou From kou at cozmixng.org Tue Jan 23 02:06:54 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Tue, 23 Jan 2007 16:06:54 +0900 Subject: [Ruby-activeldap-discuss] Using ActiveLdap 0.8 In-Reply-To: <45B5B020.2040806@googlemail.com> References: <45B5B020.2040806@googlemail.com> Message-ID: Hi, 2007/1/23, Paul Hendrick : > thanks for the reply. I've tried changing the dn_attribute to > uniqueIdentifier, however when I call User.find("admin at office*"), the > ldap logs show that the search filter is: > filter=("uniqueIdentifier=admin at office*"), which won't work as I'm > looking up the email addresses(uid). > Can I specify the attribute to use as the filter somehow? Does the following work? User.find(:first, :attribute => "uid", :value => "admin at office*") Thanks, -- kou From paul.hendrick at gmail.com Tue Jan 23 11:06:30 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Tue, 23 Jan 2007 16:06:30 +0000 Subject: [Ruby-activeldap-discuss] another active-ldap query Message-ID: Hi again folks, I have gotten lookups working now for users using an active ldap class, but i've hit a snag when trying to create a user. I have the following code: class User < ActiveLdap::Base ldap_mapping :dn_attribute=>"uniqueIdentifier",:prefix=>"dc=stockport,dc=bsfbh,dc=com", :classes=>["bsfbhAccount"] end ActiveLdap::Base.establish_connection(:host=>"192.168.111.27 ",:port=>389,:bind_dn=>"cn=root,dc=office",:password=>"secret") user = User.find(:attribute=>"uid",:value=>"admin at office*") #this works puts user.cn me = User.new('phendrick') me.cn = "Testing MOD" me.save the save method raises the following error: /usr//lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/base.rb:819:in `method_missing': undefined method `cn=' for # (NoMethodError) from test2.rb:14 my ldap schema and user records have the cn attribute - do i have to define this in the activeldap class somewhere? -- cheers, paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070123/d06ee61f/attachment.html From kou at cozmixng.org Tue Jan 23 20:09:00 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Wed, 24 Jan 2007 10:09:00 +0900 Subject: [Ruby-activeldap-discuss] another active-ldap query In-Reply-To: References: Message-ID: Hi, 2007/1/24, paul hendrick : :dn_attribute=>"uniqueIdentifier",:prefix=>"dc=stockport,dc=bsfbh,dc=com", > :classes=>["bsfbhAccount"] > my ldap schema and user records have the cn attribute - do i have to define > this in the activeldap class somewhere? Does bsfbhAccount objectClass have cn attribute? You'll need to add another objectClass to :classes. The following code may help you: user = User.find(:attribute=>"uid",:value=>" admin at office*") p user.classes Thanks, -- kou From paul.hendrick at gmail.com Wed Jan 24 04:20:37 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Wed, 24 Jan 2007 09:20:37 +0000 Subject: [Ruby-activeldap-discuss] another active-ldap query In-Reply-To: References: Message-ID: Hi Kouhei, thanks for your help - printing the classes of an existing user showed me what i needed to use for my :classes=>[...] argument, and it works now. thanks again. On 24/01/07, Kouhei Sutou wrote: > > Hi, > > 2007/1/24, paul hendrick : > > :dn_attribute=>"uniqueIdentifier",:prefix=>"dc=stockport,dc=bsfbh,dc=com", > > :classes=>["bsfbhAccount"] > > > my ldap schema and user records have the cn attribute - do i have to > define > > this in the activeldap class somewhere? > > Does bsfbhAccount objectClass have cn attribute? You'll need to add > another objectClass to :classes. > > The following code may help you: > user = User.find(:attribute=>"uid",:value=>" admin at office*") > p user.classes > > > Thanks, > -- > kou > _______________________________________________ > Ruby-activeldap-discuss mailing list > Ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss > -- cheers, paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070124/740b67d2/attachment.html From kou at cozmixng.org Wed Jan 24 21:07:12 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 25 Jan 2007 11:07:12 +0900 Subject: [Ruby-activeldap-discuss] 0.8.1? Message-ID: Hi, I committed codes that support ActiveSupport 1.4.0. It seems that we should release new version of ActiveLdap to work with Rails 1.2.1. Now, difference with 0.8.0 are only bug fixes and ActiveSupport 1.4.0 support. So, it seems that we use 0.8.1 to next release. Any opinion? Will, if you have a little time, could you release new version? If you don't have any time, I'll do. Thanks, -- kou From paul.hendrick at gmail.com Fri Jan 26 08:10:58 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Fri, 26 Jan 2007 13:10:58 +0000 Subject: [Ruby-activeldap-discuss] activeldap with rails Message-ID: Hi all, I have the following user_model: class LdapUser < ActiveLdap::Base ldap_mapping :dn_attribute=>"uniqueIdentifier",:prefix=>"dc=offce",:classes=>["inetOrgPerson"] def self.login begin ActiveLdap::Base.establish_connection( :host=>"192.168.111.27", :port=>389, :bind_dn=>"uniqueIdentifier=a001,ou=people,uniqueIdentifier=0001,dc=office", :password=>"password") rescue return nil end end end which is used in my controller like this: if LdapUser.login flash[:notice]="Logged in" else flash[:notice]="Not Logged in" end the problem is, it always returns true, even when i put an invalid password. in the logs, when i do this using the wrong password, i get this: Jan 26 02:31:45 linux slapd[3333]: conn=189 op=0 BIND dn="uniqueIdentifier=a001,ou=people,uniqueIdentifier=0001,dc=office" method=128Jan 26 02:31:45 linux slapd[3333]: conn=189 op=0 RESULT tag=97 err=49 text= Jan 26 02:31:45 linux slapd[3333]: conn=189 op=1 BIND dn="" method=128 Jan 26 02:31:45 linux slapd[3333]: conn=189 op=1 RESULT tag=97 err=0 text= i see there are two binds, and the second one doesn't return an error - perhaps that's why i'm always getting true? but i'm not sure where the second bind is coming from. any ideas? thanks for reading. -- cheers, paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070126/847a5831/attachment.html From paul.hendrick at gmail.com Fri Jan 26 08:20:47 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Fri, 26 Jan 2007 13:20:47 +0000 Subject: [Ruby-activeldap-discuss] activeldap with rails In-Reply-To: References: Message-ID: solved this, sorry. added ":allow_anonymous=>false" to the establish_connection method. On 26/01/07, paul hendrick wrote: > > Hi all, > I have the following user_model: > > class LdapUser < ActiveLdap::Base > ldap_mapping > :dn_attribute=>"uniqueIdentifier",:prefix=>"dc=offce",:classes=>["inetOrgPerson"] > > def self.login > begin > ActiveLdap::Base.establish_connection( > :host=>"192.168.111.27", > :port=>389, > > :bind_dn=>"uniqueIdentifier=a001,ou=people,uniqueIdentifier=0001,dc=office", > > :password=>"password") > rescue > return nil > end > end > end > > which is used in my controller like this: > if LdapUser.login > flash[:notice]="Logged in" > else > flash[:notice]="Not Logged in" > end > > the problem is, it always returns true, even when i put an invalid > password. > in the logs, when i do this using the wrong password, i get this: > Jan 26 02:31:45 linux slapd[3333]: conn=189 op=0 BIND > dn="uniqueIdentifier=a001,ou=people,uniqueIdentifier=0001,dc=office" > method=128Jan 26 02:31:45 linux slapd[3333]: conn=189 op=0 RESULT tag=97 > err=49 text= > Jan 26 02:31:45 linux slapd[3333]: conn=189 op=1 BIND dn="" method=128 > Jan 26 02:31:45 linux slapd[3333]: conn=189 op=1 RESULT tag=97 err=0 text= > > > i see there are two binds, and the second one doesn't return an error - > perhaps that's why i'm always getting true? but i'm not sure where the > second bind is coming from. > > any ideas? > thanks for reading. > -- > cheers, > paul -- cheers, paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070126/b9ba6f5f/attachment-0001.html From paul.hendrick at gmail.com Fri Jan 26 09:17:16 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Fri, 26 Jan 2007 14:17:16 +0000 Subject: [Ruby-activeldap-discuss] activeldap with rails In-Reply-To: References: Message-ID: sorry for replying to myself again, but i'm still having problems. (code is pasted below for reference). My ldap setup has one top level admin user (root) and sub-admins for each department they're in. so root | useradmin1,useradmin2.... my login_form submits a useradmin at office username to the login_authenticate controller, which then looks up the dn for the corresponding "uid" in ldap and then it should try to bind as that user using those credentials. At the moment, I have the root level bind working, but when i try to fetch the dn of the username at office address that is entered, i get this error: "Can't remove required objectClass: officePerson, inetOrgPerson" (these are two of the classes i map to) my ldap_user model: class LdapUser < ActiveLdap::Base ldap_mapping :dn_attribute=>"uniqueIdentifier",:prefix=>"dc=office", :classes=>["offceAccount","officePerson","inetOrgPerson"] def self.login(user_dn,user_pw) puts "\n\n::connecting with #{user_dn} and #{user_pw} \n\n" begin ActiveLdap::Base.establish_connection( :host=>" 192.168.111.27", :port=>389, :bind_dn=>user_dn, :password=>user_pw, :allow_anonymous=>false) rescue return nil end end def self.find_first(attribute,value) self.find(:attribute=>attribute,:value=>value) end end ----------------------------------- controller: class LoginController < ApplicationController def login_form @admin_dn = "cn=root,dc=office" @admin_pw = "secret" begin LdapUser.login(@admin_dn, at admin_pw) flash[:notice] = "Logged In As Admin" rescue flash[:notice] = "Not Logged In Ad Admin" @found = nil end end def login_authenticate @username = params['login']['username'] @password = params['login']['password'] @info = LdapUser.find_first ("uid", at username) #this causes the error end def logged_in end end if i take out officePerson and inetOrgPerson, i can do the .find_first method and get the dn, however i then lose my other attributes that i need, like .cn i've just noticed that if i do User.find, the object returned DOES have a .cn method, but if i use User.search, the results in there do NOT have all of the require methods. any ideas where I'm going wrong? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070126/1087b472/attachment.html From kou at cozmixng.org Fri Jan 26 23:28:32 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Sat, 27 Jan 2007 13:28:32 +0900 (JST) Subject: [Ruby-activeldap-discuss] 0.8.1? In-Reply-To: References: Message-ID: <20070127.132832.51054899.kou@cozmixng.org> Hi Will, In "Re: [Ruby-activeldap-discuss] 0.8.1?" on Fri, 26 Jan 2007 14:55:59 +0000, "Will_Drewry" wrote: > A new release sounds good to me. I should be able to pull it together > this weekend if that's soon enough for you? No problem. Thanks!!! -- kou From kou at cozmixng.org Fri Jan 26 23:43:41 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Sat, 27 Jan 2007 13:43:41 +0900 (JST) Subject: [Ruby-activeldap-discuss] activeldap with rails In-Reply-To: References: Message-ID: <20070127.134341.87096002.kou@cozmixng.org> Hi, In "Re: [Ruby-activeldap-discuss] activeldap with rails" on Fri, 26 Jan 2007 14:17:16 +0000, "paul hendrick" wrote: > At the moment, I have the root level bind working, but when i try to fetch the > dn of the username at office address that is entered, i get this error: > > "Can't remove required objectClass: officePerson, inetOrgPerson" (these are two of the classes i map to) > if i take out officePerson and inetOrgPerson, i can do the .find_first method > and get the dn, however i then lose my other attributes that i need, like .cn > i've just noticed that if i do User.find, the object returned DOES have a .cn > method, but if i use User.search, the results in there do NOT have all of the > require methods. # I assume that User means LdapUser. I think the user doesn't have officePerson and inetOrgPerson objectClasses. Could you confirm that? ActiveLdap::Base.search returns an Array of attributes Hash. The result must not have the methods what you want. It seems good that your dynamically login approach if you want to use a connection per user. But it's better that you make a connection on start-up if you want to use establish_connection only for authentication. For the propose, you can use ActiveLdap plugin. And you can use anonymous class and establish_connection for authentication: def login(...) class_only_for_authentication = Class.new(ActiveLdap::Base) begin class_only_for_authentication.establish_connection(...) true rescue ActiveLdap::Base::AuthenticationError false end end Thanks, -- kou From paul.hendrick at gmail.com Sat Jan 27 12:20:57 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Sat, 27 Jan 2007 17:20:57 +0000 Subject: [Ruby-activeldap-discuss] activeldap with rails In-Reply-To: <20070127.134341.87096002.kou@cozmixng.org> References: <20070127.134341.87096002.kou@cozmixng.org> Message-ID: Hi there, On 27/01/07, Kouhei Sutou wrote: > # I assume that User means LdapUser. > > I think the user doesn't have officePerson and inetOrgPerson > objectClasses. Could you confirm that? > > ActiveLdap::Base.search returns an Array of attributes > Hash. The result must not have the methods what you want. when doing LdapUser.find(...) and get my user back, i can print its classes and get: ["officePerson", "inetOrgPerson"] if .search returns an array of users without the required methods, what method should i use to do a search for multiple users and get all the required methods? I guess i could do user_array = ...search(...) and then do a .find on each one, but that seems very wasteful? i'm not sure i can see the 'right' way to do it. -- cheers, paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070127/46bb82a8/attachment.html From kou at cozmixng.org Sat Jan 27 20:06:08 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Sun, 28 Jan 2007 10:06:08 +0900 (JST) Subject: [Ruby-activeldap-discuss] activeldap with rails In-Reply-To: References: <20070127.134341.87096002.kou@cozmixng.org> Message-ID: <20070128.100608.203183023.kou@cozmixng.org> Hi, In "Re: [Ruby-activeldap-discuss] activeldap with rails" on Sat, 27 Jan 2007 17:20:57 +0000, "paul hendrick" wrote: > if .search returns an array of users without the required methods, what method > should i use to do a search for multiple users and get all the required > methods? > I guess i could do user_array = ...search(...) and then do a .find on each one, > but that seems very wasteful? i'm not sure i can see the 'right' way to do it. You can use find(:all, ...) for the propose. Thanks, -- kou From paul.hendrick at gmail.com Mon Jan 29 17:28:24 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Mon, 29 Jan 2007 22:28:24 +0000 Subject: [Ruby-activeldap-discuss] binding at different levels Message-ID: Hi all, I have the basics of my application working now. it works by binding as root and looking up the dn of the username entered, and then binds as that user's dn. the problem is, when this logged in user tries to create a new object, ldap complains that it doesn't have permissions to modify the parent. modifying objects works ok though. assuming this is due to the level i am binding at, i've looked at changing my ldap_mapping arguments. at the moment, I have a bind dn that looks like this: uniqueIdentifier=user0001,ou=people,uniqueIdentifier=office0001,dc=office,dc=com my ldap_mapping :prefix is =>"dc=office,dc=com" Looking at the examples, It seems i should have my prefix as "ou=people", and supply a :base? but how do I bind with the first and second uniqueIdentifier parts of my dn? thanks for reading, i hope i've given enough info... -- cheers, paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070129/730ed334/attachment.html From kou at cozmixng.org Mon Jan 29 19:46:54 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Tue, 30 Jan 2007 09:46:54 +0900 Subject: [Ruby-activeldap-discuss] 0.8.1? In-Reply-To: References: <20070127.132832.51054899.kou@cozmixng.org> Message-ID: Hi Will, 2007/1/28, Will Drewry? : > I've partially released 0.8.1. The packages are up on code.google.com > and the tagged release is in svn. I confirmed. Thanks very much! > However, rubyforge appears to be > down right now. When I can access it again, I'll put the files up > there too and then announce. Feel free to pull down the gem and make > sure I didn't mis-package anything! OK. Thanks!!! -- kou From kou at cozmixng.org Mon Jan 29 20:01:39 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Tue, 30 Jan 2007 10:01:39 +0900 Subject: [Ruby-activeldap-discuss] binding at different levels In-Reply-To: References: Message-ID: Hi, 2007/1/30, paul hendrick : > I have the basics of my application working now. Congratulations. :) > assuming this is due to the level i am binding at, i've looked at changing > my ldap_mapping arguments. > at the moment, I have a bind dn that looks like this: > uniqueIdentifier=user0001,ou=people,uniqueIdentifier=office0001,dc=office,dc=com > my ldap_mapping :prefix is =>"dc=office,dc=com" > > Looking at the examples, It seems i should have my prefix as "ou=people", > and supply a :base? but how do I bind with the first and second > uniqueIdentifier parts of my dn? It seems that I don'tt understand your request correctly but does the following code work? user = User.new("user0001,ou=people,uniqueIdentifier=office0001") ... user.save! Thanks, -- kou From kou at cozmixng.org Tue Jan 30 06:44:59 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Tue, 30 Jan 2007 20:44:59 +0900 (JST) Subject: [Ruby-activeldap-discuss] 0.8.1? In-Reply-To: References: Message-ID: <20070130.204459.239090162.kou@cozmixng.org> Hi, In "Re: [Ruby-activeldap-discuss] 0.8.1?" on Tue, 30 Jan 2007 10:19:53 +0000, "Will_Drewry?" wrote: > > > However, rubyforge appears to be > > > down right now. When I can access it again, I'll put the files up > > > there too and then announce. Feel free to pull down the gem and make > > > sure I didn't mis-package anything! > > > > OK. Thanks!!! > > Rubyforge updated! Thanks! I upgraded my gem to 0.8.1. :) -- kou From paul.hendrick at gmail.com Tue Jan 30 06:55:46 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Tue, 30 Jan 2007 11:55:46 +0000 Subject: [Ruby-activeldap-discuss] binding at different levels In-Reply-To: References: Message-ID: Hi again, I've scrapped the stuff i've done so far, as I now think I was going about it in the wrong way :) I'll re-cap my set up here. in my task, there's one office, with 2 departments, each department has many users. the office("dc=office") primary key is "uniqueIdentifier=0001", the department is "uniqueIdentifier=0001", and each user has something like "uniqueIdentifier=123.123.123", and each office has an admin user with a dn like: "uniqueIdentifier=admin0001,ou=people,uniqueIdentifier=0001,dc=office,dc=com" (the base_dn is dc=office,dc=com). So, I need 3 ActiveLdap objects (office,dept,user). I'm just trying to get Department -> Users working initially then I can go from there. So I have this department class: class Department < ActiveLdap::Base ldap_mapping :dn_attribute=>"uniqueIdentifier",:prefix=>"dc=office,dc=com",classes["department"] has_many :users,:class=>"User",:wrap=>"uniqueIdentifier" end this User class: class User < ActiveLdap::Base ldap_mapping :dn_attribute=>"uniqueIdentifier",:prefix=>"ou=people",:classes=>["officePerson"] belongs_to :department end I can establish_connection with my dn seen above, but not much more than that. If u do User.find(:all), ldap returns err=32, as it cant find the object base (it just uses ou=people from my User class), if I try Office.find(:all), I get my office object and all user objects(is that correct?). What I want to get, is something like: office = Office.find(:first) office.address, office.phone_number etc etc. Then users = Office.users, and that will return an array of user objects, so i can do user.first_name, user.role etc etc. Sorry about the long post, it's all getting very confusing :) thanks very much for reading. paul On 30/01/07, Kouhei Sutou wrote: > > Hi, > > 2007/1/30, paul hendrick : > > > I have the basics of my application working now. > > Congratulations. :) > > > assuming this is due to the level i am binding at, i've looked at > changing > > my ldap_mapping arguments. > > at the moment, I have a bind dn that looks like this: > > > uniqueIdentifier=user0001,ou=people,uniqueIdentifier=office0001,dc=office,dc=com > > my ldap_mapping :prefix is =>"dc=office,dc=com" > > > > Looking at the examples, It seems i should have my prefix as > "ou=people", > > and supply a :base? but how do I bind with the first and second > > uniqueIdentifier parts of my dn? > > It seems that I don'tt understand your request correctly but does the > following > code work? > > user = User.new("user0001,ou=people,uniqueIdentifier=office0001") > ... > user.save! > > > Thanks, > -- > kou > _______________________________________________ > Ruby-activeldap-discuss mailing list > Ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss > -- cheers, paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070130/8506f39e/attachment.html From kou at cozmixng.org Tue Jan 30 08:14:13 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Tue, 30 Jan 2007 22:14:13 +0900 (JST) Subject: [Ruby-activeldap-discuss] binding at different levels In-Reply-To: References: Message-ID: <20070130.221413.112119012.kou@cozmixng.org> Hi, In "Re: [Ruby-activeldap-discuss] binding at different levels" on Tue, 30 Jan 2007 11:55:46 +0000, "paul hendrick" wrote: > if I try Office.find(:all), I get my office object and all user objects(is that > correct?). You'll get results what you need if you add :scope => :one option to Department's ldap_mapping. > What I want to get, is something like: > office = Office.find(:first) > office.address, office.phone_number etc etc. > Then users = Office.users, and that will return an array of user objects, so i > can do > user.first_name, user.role etc etc. You can't do the above. Because the current ActiveLdap is a prefix per class. So, you need to create a user class per department. And you can't use has_many and belongs_to for your propose. They are for connecting LDAP objects. You can't use them for accessing sub-tree. What about the following code: class Department < ActiveLdap::Base ldap_mapping :dn_attribute => "uniqueIdentifier", :prefix => "dc=office,dc=com", :classes => ["department"], :scope => :one def users "UserDepartment#{id}".constantize.find(:all) end end class UserDepartment0001 < ActiveLdap::Base ldap_mapping :dn_attribute=>"uniqueIdentifier", :prefix=> "ou=people,uniqueIdentifier=0001,dc=office,dc=com", :classes => ["officePerson"] class << self def department /,uniqueIdentifier=([^,]+),/ =~ prefix Department.find($1) end end end You can do the following: dept = Department.find(:first) dept.users.each do |user| p user.first_name, user.role, ... p user.department end Thanks, -- kou From paul.hendrick at gmail.com Wed Jan 31 13:54:21 2007 From: paul.hendrick at gmail.com (paul hendrick) Date: Wed, 31 Jan 2007 18:54:21 +0000 Subject: [Ruby-activeldap-discuss] assert_have_all_required_classes query Message-ID: Hi all, in lib/object_classes.rb, this method removes classes from an array (I don't understand it very well). As it is, my application won't run unless I comment out the body of this method. With that commented out, everything works perfectly(so far). Obviously though, I'm worried that i've coded something wrong somewhere, and thats why it works without this method. Any ideas why this might be? the call that is throwing the exception is: required_classes = self.class.required_classes - new_classes i've put a debug print in it and self.class.required_classes - new_classes resolves to: [organization, domainRelatedObject, officeDomain, officeMailDomain] - [organizationalRole, officeAccount] -- cheers, paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ruby-activeldap-discuss/attachments/20070131/76d83b60/attachment.html From kou at cozmixng.org Wed Jan 31 20:24:44 2007 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 1 Feb 2007 10:24:44 +0900 Subject: [Ruby-activeldap-discuss] assert_have_all_required_classes query In-Reply-To: References: Message-ID: Hi, 2007/2/1, paul hendrick : > i've put a debug print in it and self.class.required_classes - new_classes > resolves to: > [organization, domainRelatedObject, officeDomain, officeMailDomain] - > [organizationalRole, officeAccount] It seems that you need to change your ldap_mapping's :classes to [organizationalRole, officeAccount] from [organization, domainRelatedObject, officeDomain, officeMailDomain] Or your LDAP entry is invalid. Thanks, -- kou