From MR-Mencel at wiu.edu Fri Jan 8 00:14:37 2010 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Thu, 7 Jan 2010 23:14:37 -0600 (CST) Subject: [activeldap-discuss] Groups are created in the wrong location In-Reply-To: <458a4ba50912181628t49f8b3efj79aa1f938f67e17a@mail.gmail.com> Message-ID: <922800866.826541262927676968.JavaMail.root@zcs10.wiu.edu> Hi, I've got a code snippet below. I am trying to create group objects in the following location... OU=CLASSES,OU=STUDENTS,OU=WIU,DC=AD,DC=WIU,DC=EDU But they are getting created here instead... OU=WIU,DC=AD,DC=WIU,DC=EDU ...not deeper in the tree where I want them. I have the prefix in my ldap_mapping set at the root OU=WIU, but I was hoping that by defining the full group.dn and group.distinguishedName when I save the group....that it would create it where I specified with the distinguishedName attribute. Apparently that is not the case. Can anyone tell me what I'm doing wrong? Thanks, Matt class AdGroup < AdBase ldap_mapping :dn_attribute => "cn", :prefix => "ou=wiu", :classes => ['top','group'] has_many :members, :class_name => "AdUser", :wrap => "member", :primary_key => 'distinguishedName' def self.add_course_group(starnum) group = AdGroup.new(starnum) group.dn = "cn=#{starnum},OU=CLASSES,OU=STUDENTS,ou=wiu,dc=ad,dc=wiu,dc=edu" group.cn = starnum group.distinguishedName = "CN=#{starnum},OU=CLASSES,OU=STUDENTS,OU=WIU,DC=ad,DC=wiu,DC=edu" group.name = starnum group.objectCategory = "CN=Group,CN=Schema,CN=Configuration,DC=ad,DC=wiu,DC=edu" group.groupType = "-2147483646" group.add_class('group') group.sAMAccountName = starnum unless group.save puts "save failed" puts group.errors.full_messages exit 1 end return group end From bruce.mcintyre at gmail.com Fri Jan 8 02:25:51 2010 From: bruce.mcintyre at gmail.com (Bruce McIntyre) Date: Fri, 8 Jan 2010 09:25:51 +0200 Subject: [activeldap-discuss] Using ActiveLdap to talk to Active Directory Message-ID: Hi All, I have posted a new HowTo on using ActiveLdap to talk to Active Directory. It is located at: http://code.google.com/p/ruby-activeldap/wiki/ActiveDirectoryHowTo Comments welcome. Enjoy. Bruce From MR-Mencel at wiu.edu Fri Jan 8 09:15:22 2010 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Fri, 8 Jan 2010 08:15:22 -0600 (CST) Subject: [activeldap-discuss] Groups are created in the wrong location In-Reply-To: <922800866.826541262927676968.JavaMail.root@zcs10.wiu.edu> Message-ID: <942816391.837431262960122250.JavaMail.root@zcs10.wiu.edu> This is going to be a bigger problem when I start to create users as they are all over the place in our directory. Can I override ldap_mapping at the moment that I save a group or user object? Matt ----- Original Message ----- From: "Matt Mencel" To: ruby-activeldap-discuss at rubyforge.org Sent: Thursday, January 7, 2010 11:14:37 PM GMT -06:00 US/Canada Central Subject: [activeldap-discuss] Groups are created in the wrong location Hi, I've got a code snippet below. I am trying to create group objects in the following location... OU=CLASSES,OU=STUDENTS,OU=WIU,DC=AD,DC=WIU,DC=EDU But they are getting created here instead... OU=WIU,DC=AD,DC=WIU,DC=EDU ...not deeper in the tree where I want them. I have the prefix in my ldap_mapping set at the root OU=WIU, but I was hoping that by defining the full group.dn and group.distinguishedName when I save the group....that it would create it where I specified with the distinguishedName attribute. Apparently that is not the case. Can anyone tell me what I'm doing wrong? Thanks, Matt class AdGroup < AdBase ldap_mapping :dn_attribute => "cn", :prefix => "ou=wiu", :classes => ['top','group'] has_many :members, :class_name => "AdUser", :wrap => "member", :primary_key => 'distinguishedName' def self.add_course_group(starnum) group = AdGroup.new(starnum) group.dn = "cn=#{starnum},OU=CLASSES,OU=STUDENTS,ou=wiu,dc=ad,dc=wiu,dc=edu" group.cn = starnum group.distinguishedName = "CN=#{starnum},OU=CLASSES,OU=STUDENTS,OU=WIU,DC=ad,DC=wiu,DC=edu" group.name = starnum group.objectCategory = "CN=Group,CN=Schema,CN=Configuration,DC=ad,DC=wiu,DC=edu" group.groupType = "-2147483646" group.add_class('group') group.sAMAccountName = starnum unless group.save puts "save failed" puts group.errors.full_messages exit 1 end return group end _______________________________________________ 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 Jan 8 09:56:53 2010 From: MR-Mencel at wiu.edu (MR-Mencel at wiu.edu) Date: Fri, 8 Jan 2010 08:56:53 -0600 (CST) Subject: [activeldap-discuss] Groups are created in the wrong location In-Reply-To: <329162188.849201262962514256.JavaMail.root@zcs10.wiu.edu> Message-ID: <70768225.849901262962613535.JavaMail.root@zcs10.wiu.edu> Yes....looks like I can override ldap_mapping in the method....as this example works... class AdGroup < AdBase ldap_mapping :dn_attribute => "cn", :prefix => "ou=wiu", :classes => ['top','group'] has_many :members, :class_name => "AdUser", :wrap => "member", :primary_key => 'distinguishedName' def self.add_course_group(starnum) ldap_mapping :dn_attribute => "cn", :prefix => "OU=CLASSES,OU=STUDENTS,ou=wiu", :classes => ['top','group'] group = AdGroup.new(starnum) group.dn = "cn=#{starnum},OU=CLASSES,OU=STUDENTS,ou=wiu,dc=ad,dc=wiu,dc=edu" group.cn = starnum group.distinguishedName = "CN=#{starnum},OU=CLASSES,OU=STUDENTS,OU=WIU,DC=ad,DC=wiu,DC=edu" group.name = starnum group.objectCategory = "CN=Group,CN=Schema,CN=Configuration,DC=ad,DC=wiu,DC=edu" group.groupType = "-2147483646" group.add_class('group') group.sAMAccountName = starnum unless group.save puts "save failed" puts group.errors.full_messages exit 1 end return group end If there is an easier or better way....let me know. Thanks, Matt ----- Original Message ----- From: "Matt Mencel" To: ruby-activeldap-discuss at rubyforge.org Sent: Friday, January 8, 2010 8:15:22 AM GMT -06:00 US/Canada Central Subject: Re: [activeldap-discuss] Groups are created in the wrong location This is going to be a bigger problem when I start to create users as they are all over the place in our directory. Can I override ldap_mapping at the moment that I save a group or user object? Matt ----- Original Message ----- From: "Matt Mencel" To: ruby-activeldap-discuss at rubyforge.org Sent: Thursday, January 7, 2010 11:14:37 PM GMT -06:00 US/Canada Central Subject: [activeldap-discuss] Groups are created in the wrong location Hi, I've got a code snippet below. I am trying to create group objects in the following location... OU=CLASSES,OU=STUDENTS,OU=WIU,DC=AD,DC=WIU,DC=EDU But they are getting created here instead... OU=WIU,DC=AD,DC=WIU,DC=EDU ...not deeper in the tree where I want them. I have the prefix in my ldap_mapping set at the root OU=WIU, but I was hoping that by defining the full group.dn and group.distinguishedName when I save the group....that it would create it where I specified with the distinguishedName attribute. Apparently that is not the case. Can anyone tell me what I'm doing wrong? Thanks, Matt class AdGroup < AdBase ldap_mapping :dn_attribute => "cn", :prefix => "ou=wiu", :classes => ['top','group'] has_many :members, :class_name => "AdUser", :wrap => "member", :primary_key => 'distinguishedName' def self.add_course_group(starnum) group = AdGroup.new(starnum) group.dn = "cn=#{starnum},OU=CLASSES,OU=STUDENTS,ou=wiu,dc=ad,dc=wiu,dc=edu" group.cn = starnum group.distinguishedName = "CN=#{starnum},OU=CLASSES,OU=STUDENTS,OU=WIU,DC=ad,DC=wiu,DC=edu" group.name = starnum group.objectCategory = "CN=Group,CN=Schema,CN=Configuration,DC=ad,DC=wiu,DC=edu" group.groupType = "-2147483646" group.add_class('group') group.sAMAccountName = starnum unless group.save puts "save failed" puts group.errors.full_messages exit 1 end return group end _______________________________________________ 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 MR-Mencel at wiu.edu Fri Jan 8 10:09:40 2010 From: MR-Mencel at wiu.edu (MR-Mencel at wiu.edu) Date: Fri, 8 Jan 2010 09:09:40 -0600 (CST) Subject: [activeldap-discuss] ActiveLdap and moddn In-Reply-To: <1466745952.853201262963321023.JavaMail.root@zcs10.wiu.edu> Message-ID: <1863712036.853641262963380062.JavaMail.root@zcs10.wiu.edu> How do I do a moddn in ActiveLdap? Just change the distiguishedName attribute and save the object? Say I have a user... cn=Joe,ou=users,dc=here,dc=com ...and I want to move this object to... cn=Joe,ou=admins,dc=here,dc=com Something like this? def user = User.find("Joe") user.distinguishedName = "cn=Joe,ou=admins,dc=here,dc=com" user.save end Is it that simple or do I have to do something else? Thanks, Matt From MR-Mencel at wiu.edu Mon Jan 18 23:29:42 2010 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Mon, 18 Jan 2010 22:29:42 -0600 (CST) Subject: [activeldap-discuss] Bug in ActiveLdap::Ldif.new() ??? Message-ID: <86744122.101226.1263875382317.JavaMail.root@zcs10.wiu.edu> This code below used to work fine in 1.0.9. It does not work in the latest ActiveLdap version however, and the issue is down in the second to last line of this snippet. I'm not sure if it's a bug or if something is just different in 1.2.1 and it's expecting different parameters....or it's building the records object differently? I think for now I'll just roll back to 1.0.9 until I figure this out. records = active_students.collect do |student| if student.attribute_present?('mycourses') ActiveLdap::Ldif::Record.new(student.dn, student.attributes) else nil end end.compact #puts records.class ## returns an Array object $logger.info("Users With Classes: #{records.size}") ## 11000+ in show in the logs ldif_file.puts ActiveLdap::Ldif.new(records).to_s ldif_file.close The error I get is below. /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:50:in `[]': wrong number of arguments (2 for 1) (ArgumentError) from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:50:in `encode' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:15:in `encode' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:14:in `each' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:14:in `encode' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:13:in `each' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:13:in `encode' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:660:in `to_s_content' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:643:in `to_s' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:618:in `to_s' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:617:in `collect' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:617:in `to_s' from ./course_cal.rb:93:in `create_ldif_files' from ./course_cal.rb:80:in `open' from ./course_cal.rb:80:in `create_ldif_files' from ./course_cal.rb:670 Thanks, Matt From kou at cozmixng.org Sun Jan 24 06:37:18 2010 From: kou at cozmixng.org (Kouhei Sutou) Date: Sun, 24 Jan 2010 20:37:18 +0900 (JST) Subject: [activeldap-discuss] Bug in ActiveLdap::Ldif.new() ??? In-Reply-To: <86744122.101226.1263875382317.JavaMail.root@zcs10.wiu.edu> References: <86744122.101226.1263875382317.JavaMail.root@zcs10.wiu.edu> Message-ID: <20100124.203718.389567058286599968.kou@cozmixng.org> Hi, In <86744122.101226.1263875382317.JavaMail.root at zcs10.wiu.edu> "[activeldap-discuss] Bug in ActiveLdap::Ldif.new() ???" on Mon, 18 Jan 2010 22:29:42 -0600 (CST), Matt Mencel wrote: > This code below used to work fine in 1.0.9. It does not work in the latest ActiveLdap version however, and the issue is down in the second to last line of this snippet. I'm not sure if it's a bug or if something is just different in 1.2.1 and it's expecting different parameters....or it's building the records object differently? I think for now I'll just roll back to 1.0.9 until I figure this out. > > > > records = active_students.collect do |student| > if student.attribute_present?('mycourses') > ActiveLdap::Ldif::Record.new(student.dn, student.attributes) > else > nil > end > end.compact > #puts records.class ## returns an Array object > $logger.info("Users With Classes: #{records.size}") ## 11000+ in show in the logs > ldif_file.puts ActiveLdap::Ldif.new(records).to_s > ldif_file.close Could you show a result of the following script? active_students.each do |student| next unless student.attribute_present?('mycourses') record = ActiveLdap::Ldif::Record.new(student.dn, student.attributes) begin record.to_s rescue Exception p record puts "#{$!.class}: #{$!}" puts $@ break end end Thanks, -- kou From MR-Mencel at wiu.edu Mon Jan 25 12:52:20 2010 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Mon, 25 Jan 2010 11:52:20 -0600 (CST) Subject: [activeldap-discuss] Bug in ActiveLdap::Ldif.new() ??? In-Reply-To: <1424238699.16151.1264441880900.JavaMail.root@zcs10.wiu.edu> Message-ID: <1743813590.16203.1264441940587.JavaMail.root@zcs10.wiu.edu> I cleaned it up a bit for privacy reasons, but this is the result of your code. #"USERNAME"}, {"ou"=>"People"}, {"dc"=>"wiu"}, {"dc"=>"edu"}]>, @attributes={"mycourses"=>[44851, 47979], "mail"=>"MAIL", "uid"=>"USERNAME", "objectClass"=>["top", "person", "wiuPerson", "wiuCCmail", "wiuAccount", "inetLocalMailRecipient", "posixAccount", "shadowaccount", "wiuWebCT", "wiuMail", "organizationalPerson", "inetOrgPerson", "icsCalendarUser", "sambaSamAccount", "sunUCPreferences", "ipUser", "wiuEmployee", "wiuStudent", "wiuRegistered"]}> ArgumentError: wrong number of arguments (2 for 1) /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:50:in `[]' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:50:in `encode' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:15:in `encode' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:14:in `each' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:14:in `encode' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:13:in `each' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:13:in `encode' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:660:in `to_s_content' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activeldap-1.2.1/lib/active_ldap/ldif.rb:643:in `to_s' ./course_cal.rb:92:in `create_ldif_files' ./course_cal.rb:88:in `each' ./course_cal.rb:88:in `create_ldif_files' ./course_cal.rb:81:in `open' ./course_cal.rb:81:in `create_ldif_files' ./course_cal.rb:609 Matt ----- Original Message ----- From: "Kouhei Sutou" To: ruby-activeldap-discuss at rubyforge.org Sent: Sunday, January 24, 2010 5:37:18 AM Subject: Re: [activeldap-discuss] Bug in ActiveLdap::Ldif.new() ??? Hi, In <86744122.101226.1263875382317.JavaMail.root at zcs10.wiu.edu> "[activeldap-discuss] Bug in ActiveLdap::Ldif.new() ???" on Mon, 18 Jan 2010 22:29:42 -0600 (CST), Matt Mencel wrote: > This code below used to work fine in 1.0.9. It does not work in the latest ActiveLdap version however, and the issue is down in the second to last line of this snippet. I'm not sure if it's a bug or if something is just different in 1.2.1 and it's expecting different parameters....or it's building the records object differently? I think for now I'll just roll back to 1.0.9 until I figure this out. > > > > records = active_students.collect do |student| > if student.attribute_present?('mycourses') > ActiveLdap::Ldif::Record.new(student.dn, student.attributes) > else > nil > end > end.compact > #puts records.class ## returns an Array object > $logger.info("Users With Classes: #{records.size}") ## 11000+ in show in the logs > ldif_file.puts ActiveLdap::Ldif.new(records).to_s > ldif_file.close Could you show a result of the following script? active_students.each do |student| next unless student.attribute_present?('mycourses') record = ActiveLdap::Ldif::Record.new(student.dn, student.attributes) begin record.to_s rescue Exception p record puts "#{$!.class}: #{$!}" puts $@ break end end Thanks, -- kou _______________________________________________ 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 Mon Jan 25 12:54:06 2010 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Mon, 25 Jan 2010 11:54:06 -0600 (CST) Subject: [activeldap-discuss] Bug in ActiveLdap::Ldif.new() ??? In-Reply-To: <20100124.203718.389567058286599968.kou@cozmixng.org> Message-ID: <544446455.16290.1264442046066.JavaMail.root@zcs10.wiu.edu> Line 92 in the code is ... record.to_s Matt ----- Original Message ----- From: "Kouhei Sutou" To: ruby-activeldap-discuss at rubyforge.org Sent: Sunday, January 24, 2010 5:37:18 AM Subject: Re: [activeldap-discuss] Bug in ActiveLdap::Ldif.new() ??? Hi, In <86744122.101226.1263875382317.JavaMail.root at zcs10.wiu.edu> "[activeldap-discuss] Bug in ActiveLdap::Ldif.new() ???" on Mon, 18 Jan 2010 22:29:42 -0600 (CST), Matt Mencel wrote: > This code below used to work fine in 1.0.9. It does not work in the latest ActiveLdap version however, and the issue is down in the second to last line of this snippet. I'm not sure if it's a bug or if something is just different in 1.2.1 and it's expecting different parameters....or it's building the records object differently? I think for now I'll just roll back to 1.0.9 until I figure this out. > > > > records = active_students.collect do |student| > if student.attribute_present?('mycourses') > ActiveLdap::Ldif::Record.new(student.dn, student.attributes) > else > nil > end > end.compact > #puts records.class ## returns an Array object > $logger.info("Users With Classes: #{records.size}") ## 11000+ in show in the logs > ldif_file.puts ActiveLdap::Ldif.new(records).to_s > ldif_file.close Could you show a result of the following script? active_students.each do |student| next unless student.attribute_present?('mycourses') record = ActiveLdap::Ldif::Record.new(student.dn, student.attributes) begin record.to_s rescue Exception p record puts "#{$!.class}: #{$!}" puts $@ break end end 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 Tue Jan 26 08:17:10 2010 From: kou at cozmixng.org (Kouhei Sutou) Date: Tue, 26 Jan 2010 22:17:10 +0900 (JST) Subject: [activeldap-discuss] Bug in ActiveLdap::Ldif.new() ??? In-Reply-To: <1743813590.16203.1264441940587.JavaMail.root@zcs10.wiu.edu> References: <1424238699.16151.1264441880900.JavaMail.root@zcs10.wiu.edu> <1743813590.16203.1264441940587.JavaMail.root@zcs10.wiu.edu> Message-ID: <20100126.221710.206997487005793063.kou@cozmixng.org> Hi, In <1743813590.16203.1264441940587.JavaMail.root at zcs10.wiu.edu> "Re: [activeldap-discuss] Bug in ActiveLdap::Ldif.new() ???" on Mon, 25 Jan 2010 11:52:20 -0600 (CST), Matt Mencel wrote: > I cleaned it up a bit for privacy reasons, but this is the result of your code. Thanks for the information. I've fixed it in trunk. BTW, you should use ActiveLdap::Base#to_ldif_record instead of ActiveLdap::Ldif::Record.new(entry.dn, entry.attributes). records = active_students.collect do |student| if student.attribute_present?('mycourses') student.to_ldif_record else nil end end.compact Thanks, -- kou