From MR-Mencel at wiu.edu Fri Apr 2 16:44:30 2010 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Fri, 2 Apr 2010 15:44:30 -0500 (CDT) Subject: [activeldap-discuss] Paging for Search or Find In-Reply-To: <260502167.352791.1266528338351.JavaMail.root@zcs10.wiu.edu> Message-ID: <1463272854.389408.1270241070610.JavaMail.root@zcs10.wiu.edu> Just wondering... Is there a way in ActiveLdap to do paged searches? If a search of Active Directory has more than 1000 results, it won't return anything unless you can do paged results. Thanks, Matt ----- Original Message ----- From: "Matt Mencel" To: ruby-activeldap-discuss at rubyforge.org Sent: Thursday, February 18, 2010 3:25:38 PM Subject: [activeldap-discuss] Paging for Search or Find I'm running a query that returns too many results from Active Directory. groups = AdGroup.find(:all).collect {|group| group.cn} Returns nil very quickly...probably because results are in the 10s of thousands and it fails. How can I page the results so I only get 1000 results at a time? Do I write the paging algorithm myself or is there an ActiveLdap feature that will do it automatically? Thanks, Matt _______________________________________________ ruby-activeldap-discuss mailing list ruby-activeldap-discuss at rubyforge.org http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss From kou at cozmixng.org Fri Apr 2 22:10:26 2010 From: kou at cozmixng.org (Kouhei Sutou) Date: Sat, 03 Apr 2010 11:10:26 +0900 (JST) Subject: [activeldap-discuss] Paging for Search or Find In-Reply-To: <1463272854.389408.1270241070610.JavaMail.root@zcs10.wiu.edu> References: <260502167.352791.1266528338351.JavaMail.root@zcs10.wiu.edu> <1463272854.389408.1270241070610.JavaMail.root@zcs10.wiu.edu> Message-ID: <20100403.111026.46993072188067111.kou@cozmixng.org> Hi, I'm sorry for my late response. In <1463272854.389408.1270241070610.JavaMail.root at zcs10.wiu.edu> "Re: [activeldap-discuss] Paging for Search or Find" on Fri, 2 Apr 2010 15:44:30 -0500 (CDT), Matt Mencel wrote: > Is there a way in ActiveLdap to do paged searches? > > If a search of Active Directory has more than 1000 results, it won't return anything unless you can do paged results. How about using net-ldap backend? net-ldap implements paged search. I want to add paged support but I don't have time for it... Could someone write a patch? Thanks, -- kou From MR-Mencel at wiu.edu Tue Apr 13 15:14:06 2010 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Tue, 13 Apr 2010 14:14:06 -0500 (CDT) Subject: [activeldap-discuss] Moving Objects To New Container In-Reply-To: <410303867.631970.1271185552605.JavaMail.root@zcs10.wiu.edu> Message-ID: <486506111.632396.1271186046765.JavaMail.root@zcs10.wiu.edu> Say I have this object: user.cn = USERA user.dn = CN=USERA,OU=OLDOU ...and I want to move this object to a new ou of OU=NEWOU. I see these two methods... modify_rdn (dn, new_rdn, delete_old_rdn, new_superior, options={}) modify_rdn_entry (dn, new_rdn, delete_old_rdn, new_superior, options={}) Something like this...?? user = User.find("USERA") user.modify_rdn("CN=USERA,OU=OLDOU", "CN=USERA", true, "OU=NEWOU", {}) user.save However... modify_rdn gives me... "undefined method `modify_rdn' for #" ...and modify_rdn_entry gives me... "not implemented: modify RDN with new superior" Looks like this is currently not possible with ActiveLdap....or is there another way? Thanks, Matt ----- Original Message ----- From: "Richard 3 Nicholas" To: ruby-activeldap-discuss at rubyforge.org Sent: Wednesday, July 16, 2008 12:16:20 PM Subject: [Ruby-activeldap-discuss] I'm having fun with ActiveLdap::DistinguishedName class... I want to move an object from its current container into a sub container (ou=toBeDeleted) and this would seem to be the way to do it... modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options={}) now, I have the dn. The new rdn, would be "cn=old cn", so that isn't a problem. delete_old_rdn is true, so that isn't a problem. The issue is new_superior. I need to take the cn off the front of the DN, and replace it with the new OU. I thought it would be great to make use of activeLdap's DistinguishedName handler to save me the problem of rolling my own DistinguishedName parser. ActiveLdap::DistinguishedName.parse( my_object.dn ) does just what I'd expect. I can then look at the .rdns value and use strip to get rid of the cn on the end. I can add { "ou" => "toBeDeleted" } to the start of the array, but then I can't get the resultant array of hashes back into an ActiveLdap::DistinguishedName type and from there back into a string. >> arr => [{"CN"=>"Computers"}, {"dc"=>"ads"}, {"dc"=>"blah"}, {"dc"=>"com"}] >> newdn.rdns = arr NoMethodError: undefined method `rdns=' for # from (irb):74 >> >> ActiveLdap::DistinguishedName.new(arr) => #"Computers"}, {"dc"=>"ads"}, {"dc"=>"blah"}, {"dc"=>"com"}]]> >> ActiveLdap::DistinguishedName.new(arr).to_s NoMethodError: undefined method `upcase' for {"CN"=>"Computers"}:Hash from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:227:in `to_s' from (irb):76:in `sort_by' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:226:in `each' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:226:in `sort_by' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:226:in `to_s' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:225:in `collect' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:225:in `to_s' from (irb):76 >> The reason that the second method fails is rdns ends up wrapped in another array. The following change would fix the problem, but the behaviour of ActiveLdap::DistinguishedName.new( ["cn","anything"] ) would change.... file: distinguished_name.rb def initialize(*rdns) if rdns.size == 1 and rdns[0].is_a?(Array) rdns = rdns[0] end @rdns = rdns.collect do |rdn| if rdn.is_a?(Array) and rdn.size == 2 {rdn[0] => rdn[1]} else rdn end end end Is there any really easy way to make the parser do what I want? Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU _______________________________________________ Ruby-activeldap-discuss mailing list Ruby-activeldap-discuss at rubyforge.org http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss From MR-Mencel at wiu.edu Fri Apr 16 18:29:09 2010 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Fri, 16 Apr 2010 17:29:09 -0500 (CDT) Subject: [activeldap-discuss] Moving Objects To New Container In-Reply-To: <134379404.37561.1271456771516.JavaMail.root@zcs10.wiu.edu> Message-ID: <2130192278.37605.1271456949825.JavaMail.root@zcs10.wiu.edu> I took a look at Alexey's Ruby/LDAP code on github. No idea if this would work....but the PERL examples I've seen put newsuperior before deleteoldrdn in the params list. Just wondering if all it takes is a patch submission? Thanks, Matt # conn.c /* * call-seq: * conn.modrdn(dn, new_rdn, new_superior, delete_old_rdn) => self * * Modify the RDN of the entry with DN, +dn+, giving it the new RDN, * +new_rdn+. Move to a new container if +new_superior+ is given. * If +delete_old_rdn+ is *true*, the old RDN value will be deleted from * the entry. */ VALUE rb_ldap_conn_modrdn_s (VALUE self, VALUE dn, VALUE newrdn, , VALUE newsuperior, VALUE delete_p) { RB_LDAP_DATA *ldapdata; char *c_dn; char *c_newrdn; char *c_newsuperior; int c_delete_p; GET_LDAP_DATA (self, ldapdata); c_dn = StringValueCStr (dn); c_newrdn = StringValueCStr (newrdn); c_newsuperior = StringValueCStr (newsuperior); c_delete_p = (delete_p == Qtrue) ? 1 : 0; ldapdata->err = ldap_modrdn2_s (ldapdata->ldap, c_dn, c_newrdn, c_newsuperior, c_delete_p); Check_LDAP_Result (ldapdata->err); return self; }; # conn.c line 1796 # If the number here specifies the number of required params...then it should be 3 and not 4... # but I wasn't sure exactly what to do except it was related to the number of params. rb_ldap_conn_define_method ("modrdn", rb_ldap_conn_modrdn_s, 4); # win/winldap.h line 286 ULONG ldap_modrdn2_s(LDAP *ld, PCHAR olddn, PCHAR newdn, PCHAR newsuperior, int delold_flag); # rbldap.h line 117 VALUE rb_ldap_conn_modrdn_s (VALUE, VALUE, VALUE, VALUE, VALUE); ----- Original Message ----- From: "Matt Mencel" To: ruby-activeldap-discuss at rubyforge.org Sent: Tuesday, April 13, 2010 2:14:06 PM Subject: [activeldap-discuss] Moving Objects To New Container Say I have this object: user.cn = USERA user.dn = CN=USERA,OU=OLDOU ...and I want to move this object to a new ou of OU=NEWOU. I see these two methods... modify_rdn (dn, new_rdn, delete_old_rdn, new_superior, options={}) modify_rdn_entry (dn, new_rdn, delete_old_rdn, new_superior, options={}) Something like this...?? user = User.find("USERA") user.modify_rdn("CN=USERA,OU=OLDOU", "CN=USERA", true, "OU=NEWOU", {}) user.save However... modify_rdn gives me... "undefined method `modify_rdn' for #" ...and modify_rdn_entry gives me... "not implemented: modify RDN with new superior" Looks like this is currently not possible with ActiveLdap....or is there another way? Thanks, Matt ----- Original Message ----- From: "Richard 3 Nicholas" To: ruby-activeldap-discuss at rubyforge.org Sent: Wednesday, July 16, 2008 12:16:20 PM Subject: [Ruby-activeldap-discuss] I'm having fun with ActiveLdap::DistinguishedName class... I want to move an object from its current container into a sub container (ou=toBeDeleted) and this would seem to be the way to do it... modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options={}) now, I have the dn. The new rdn, would be "cn=old cn", so that isn't a problem. delete_old_rdn is true, so that isn't a problem. The issue is new_superior. I need to take the cn off the front of the DN, and replace it with the new OU. I thought it would be great to make use of activeLdap's DistinguishedName handler to save me the problem of rolling my own DistinguishedName parser. ActiveLdap::DistinguishedName.parse( my_object.dn ) does just what I'd expect. I can then look at the .rdns value and use strip to get rid of the cn on the end. I can add { "ou" => "toBeDeleted" } to the start of the array, but then I can't get the resultant array of hashes back into an ActiveLdap::DistinguishedName type and from there back into a string. >> arr => [{"CN"=>"Computers"}, {"dc"=>"ads"}, {"dc"=>"blah"}, {"dc"=>"com"}] >> newdn.rdns = arr NoMethodError: undefined method `rdns=' for # from (irb):74 >> >> ActiveLdap::DistinguishedName.new(arr) => #"Computers"}, {"dc"=>"ads"}, {"dc"=>"blah"}, {"dc"=>"com"}]]> >> ActiveLdap::DistinguishedName.new(arr).to_s NoMethodError: undefined method `upcase' for {"CN"=>"Computers"}:Hash from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:227:in `to_s' from (irb):76:in `sort_by' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:226:in `each' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:226:in `sort_by' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:226:in `to_s' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:225:in `collect' from c:/ruby/lib/ruby/gems/1.8/gems/activeldap-1.0.1/lib/active_ldap/distinguished_name.rb:225:in `to_s' from (irb):76 >> The reason that the second method fails is rdns ends up wrapped in another array. The following change would fix the problem, but the behaviour of ActiveLdap::DistinguishedName.new( ["cn","anything"] ) would change.... file: distinguished_name.rb def initialize(*rdns) if rdns.size == 1 and rdns[0].is_a?(Array) rdns = rdns[0] end @rdns = rdns.collect do |rdn| if rdn.is_a?(Array) and rdn.size == 2 {rdn[0] => rdn[1]} else rdn end end end Is there any really easy way to make the parser do what I want? Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU _______________________________________________ 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 thermans at gmail.com Thu Apr 22 11:15:26 2010 From: thermans at gmail.com (Tim Hermans) Date: Thu, 22 Apr 2010 11:15:26 -0400 Subject: [activeldap-discuss] is unknown attribute (ActiveLdap::UnknownAttribute) Message-ID: About a year ago we discussed this problem (see thread "unknown objectClass: what am I doing wrong?"). I'm revisiting it now 'cos I'd really like to see this work with my LDAP server. Here's the issue: I get ActiveLdap::UnknownAttribute when I try to find any attribute. The search completes properly on the server, ActiveLdap just doesn't seem to process the results properly. I believe it might be my proprietary schema. Here's what a typical tree item looks like: DSE root: cn=admin root cn=site umpn=1.555.5551234 objectclass: top objectclass: umphone objectclass: umphonenumber umivrflow: orion umivrvariant: testing umpn: 1.555.5551234 umpnstatus: A umpntype: P Here's the code: require 'active_ldap' class Target < ActiveLdap::Base ldap_mapping :dn_attribute => "umpn", :prefix => "", :classes => ['top', 'umphone', 'umphonenumber'] end ActiveLdap::Base.setup_connection :host => 'ldaphost', :base => 'cn=site, cn= admin root', :bind_dn => 'cn=root', :password => 'xxxxxx' @target = Target.find('1.555.5551234').collect And the backtrace: /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/base.rb:1277:in `set_attribute': umpn is unknown attribute (ActiveLdap::UnknownAttribute) from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/base.rb:782:in `dn=' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/base.rb:1155:in `initialize_by_ldap_data' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/base.rb:611:in `instantiate_without_callbacks' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/base.rb:610:in `instance_eval' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/base.rb:610:in `instantiate_without_callbacks' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/callbacks.rb:29:in `instantiate' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/operations.rb:283:in `find_every' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/operations.rb:282:in `collect' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/operations.rb:282:in `find_every' from /home/thermans/.gem/gems/activeldap-1.2.1/lib/active_ldap/operations.rb:226:in `find' from ldap.rb:17 The schema itself is attached. The issue seems to be that "real_name" (in "base.rb") does not get set. I'm not sure what this is: I don't really have the skills to analyse further. Can anyone help? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: schema.rb Type: application/octet-stream Size: 160417 bytes Desc: not available URL: From kou at cozmixng.org Sun Apr 25 03:33:07 2010 From: kou at cozmixng.org (Kouhei Sutou) Date: Sun, 25 Apr 2010 16:33:07 +0900 (JST) Subject: [activeldap-discuss] is unknown attribute (ActiveLdap::UnknownAttribute) In-Reply-To: References: Message-ID: <20100425.163307.1019573468350796102.kou@cozmixng.org> Hi, In "[activeldap-discuss] is unknown attribute (ActiveLdap::UnknownAttribute)" on Thu, 22 Apr 2010 11:15:26 -0400, Tim Hermans wrote: > About a year ago we discussed this problem (see thread "unknown objectClass: > what am I doing wrong?").? I'm revisiting it now 'cos I'd really like to see > this work with my LDAP server. > > Here's the issue: I get ActiveLdap::UnknownAttribute when I try to find any > attribute.? The search completes properly on the server, ActiveLdap just > doesn't seem to process the results properly. > > I believe it might be my proprietary schema.? Here's what a typical tree item > looks like: ... > The schema itself is attached. Thanks for providing your schema. I've fixed this problem in trunk. Thanks, -- kou From thermans at gmail.com Mon Apr 26 10:35:54 2010 From: thermans at gmail.com (Tim Hermans) Date: Mon, 26 Apr 2010 10:35:54 -0400 Subject: [activeldap-discuss] is unknown attribute (ActiveLdap::UnknownAttribute) In-Reply-To: <20100425.163307.1019573468350796102.kou@cozmixng.org> References: <20100425.163307.1019573468350796102.kou@cozmixng.org> Message-ID: On Sun, Apr 25, 2010 at 3:33 AM, Kouhei Sutou wrote: > Hi, > > In > "[activeldap-discuss] is unknown attribute > (ActiveLdap::UnknownAttribute)" on Thu, 22 Apr 2010 11:15:26 -0400, > Tim Hermans wrote: > > > About a year ago we discussed this problem (see thread "unknown > objectClass: > > what am I doing wrong?"). I'm revisiting it now 'cos I'd really like to > see > > this work with my LDAP server. > > > > Here's the issue: I get ActiveLdap::UnknownAttribute when I try to find > any > > attribute. The search completes properly on the server, ActiveLdap just > > doesn't seem to process the results properly. > > > > I believe it might be my proprietary schema. Here's what a typical tree > item > > looks like: > ... > > The schema itself is attached. > > Thanks for providing your schema. > I've fixed this problem in trunk. > > Thanks, > -- > kou Woohoo!! Works now. Thank you very much! Tim -------------- next part -------------- An HTML attachment was scrubbed... URL: