From carl.bourne at mac.com Tue Apr 3 14:18:59 2012 From: carl.bourne at mac.com (Carl Bourne) Date: Tue, 03 Apr 2012 15:18:59 +0100 Subject: [activeldap-discuss] Active Directory Example Message-ID: <8947E9FC-CED5-4216-A198-F51039FBCBBF@mac.com> Hi, Are there any Active Directory examples - I've been trying this: require 'rubygems' require 'active_ldap' ActiveLdap::Base.setup_connection( :host => '172.16.221.180', :port => 389, :base => 'DC=demo,DC=abc,DC=com', :bind_dn => "Administrator", :password => 'password' ) class Group < ActiveLdap::Base ldap_mapping end all_groups = Group.find(:all, '*').collect {|group| group.cn} But I just keep getting this: ActiveLdap::LdapError::OperationsError: 000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db1 Best Regards, Carl From MR-Mencel at wiu.edu Wed Apr 25 16:39:11 2012 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Wed, 25 Apr 2012 11:39:11 -0500 (CDT) Subject: [activeldap-discuss] Comparing LDIF Records In-Reply-To: <8947E9FC-CED5-4216-A198-F51039FBCBBF@mac.com> Message-ID: <8510e4a3-723e-44ac-b8d4-3ce4a1892049@zcs10.wiu.edu> I'm writing some code to compare LDIF records. I have two different objects with the same DN and about a dozen attributes. I can do this to compare them... The .class on these objects is..... ActiveLdap::Ldif::ContentRecord < ActiveLdap::Ldif::Record ldif_obj_A == ldif_obj_B This returns TRUE if all attributes match, otherwise FALSE. If it's false I would like be able to get the attribute or attributes (and their values) that are different between the two. Is there an easy way to do this or do I have to manually traverse each attribute list and compare them to each other one by one? Thanks, Matt From MR-Mencel at wiu.edu Wed Apr 25 16:59:45 2012 From: MR-Mencel at wiu.edu (Matt Mencel) Date: Wed, 25 Apr 2012 11:59:45 -0500 (CDT) Subject: [activeldap-discuss] Comparing LDIF Records In-Reply-To: <8510e4a3-723e-44ac-b8d4-3ce4a1892049@zcs10.wiu.edu> Message-ID: So since ldif_obj_A.attributes is a Hash, I found this bit of code (http://stackoverflow.com/questions/1766741/comparing-ruby-hashes). class Hash def diff(other) (self.keys + other.keys).uniq.inject({}) do |memo, key| unless self[key] == other[key] if self[key].kind_of?(Hash) && other[key].kind_of?(Hash) memo[key] = self[key].diff(other[key]) else memo[key] = [self[key], other[key]] end end memo end end end When I do this... ldif_obj_A.attributes.diff(ldif_obj_B.attributes) I get this... { "some_attribute" => [ [0] [ [0] "ValueA" ], [1] [ [0] "ValueB" ] ] } So that seems to work nicely. If there is an easier or better way to do this let me know. Thanks, Matt ----- Original Message ----- From: "Matt Mencel" To: ruby-activeldap-discuss at rubyforge.org Sent: Wednesday, April 25, 2012 11:39:11 AM Subject: Comparing LDIF Records I'm writing some code to compare LDIF records. I have two different objects with the same DN and about a dozen attributes. I can do this to compare them... The .class on these objects is..... ActiveLdap::Ldif::ContentRecord < ActiveLdap::Ldif::Record ldif_obj_A == ldif_obj_B This returns TRUE if all attributes match, otherwise FALSE. If it's false I would like be able to get the attribute or attributes (and their values) that are different between the two. Is there an easy way to do this or do I have to manually traverse each attribute list and compare them to each other one by one? Thanks, Matt