From codesite-noreply at google.com Thu Jan 7 03:52:44 2010 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Thu, 07 Jan 2010 08:52:44 +0000 Subject: [activeldap-commit] [ruby-activeldap] r1123 committed - Created wiki page through web user interface. Message-ID: <001636b2b0cacb6819047c8f31ef@google.com> Revision: 1123 Author: bruce.mcintyre Date: Thu Jan 7 00:51:39 2010 Log: Created wiki page through web user interface. http://code.google.com/p/ruby-activeldap/source/detail?r=1123 Added: /wiki/ActiveDirectoryHowTo.wiki ======================================= --- /dev/null +++ /wiki/ActiveDirectoryHowTo.wiki Thu Jan 7 00:51:39 2010 @@ -0,0 +1,168 @@ +#summary How to connect to Active Directory + += Introduction = + +At it's core, Active Directory is just another LDAP Server. +Connecting to it is as easy. + +This tutorial shows you how. + += Details = + +== Active Directory Requirements == + +=== Locating the Domain Controller or Global Address List Server === + +You might have to poke around your network a bit, but you need to find a server listening on TCP port 389. + +You can do this by telnetting to the suspected server and see if you get this response: + +{{{ +~$ telnet 172.31.0.8 389 +Trying 172.31.0.8... +Connected to 172.31.0.8. +Escape character is '^]'. + + +}}} + +If the socket opens, you are in business. +This will be the LDAP server you will configure later on. + +You need to keep looking if you get the following error: + +{{{ +~$ telnet 172.31.0.7 389 +Trying 172.31.0.7... +telnet: Unable to connect to remote host: Connection refused + +}}} + +=== Determining the BaseDN for Active Directory === + +Active Directory requires DNS, and this provides a handy clue on reverse engineering the BaseDN for LDAP. + +If my FQDN for my domain is: + +{{{ + contorso.com + +}}} + +Then my BaseDN will be as follows: + +{{{ + DC=contorso,DC=com +}}} + +== Required Gems == + +Make sure you have the activeldap gem installed by issuing the following command: + +{{{ + sudo gem install activeldap +}}} + +== Connect to Active Directory == + +Create a new Rails project: + +{{{ +~/rails/$ rails activedirectory + create + create app/controllers + create app/helpers + create app/models + create app/views/layouts + create config/environments + create config/initializers + create config/locales + create db + create doc + create lib + create lib/tasks + create log + create public/images + .. +}}} + +Change to the directory: + +{{{ +~/rails$ cd activedirectory +}}} + +Generate a new activeldap scaffold: + +{{{ +~/rails/activedirectory$ ./script/generate scaffold_active_ldap + create config/ldap.yml +}}} + +Edit your *config/environment.rb* file and *`require 'active_ldap'`*. Here is an example config: + +{{{ +RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION +require File.join(File.dirname(__FILE__), 'boot') +Rails::Initializer.run do |config| + require 'active_ldap' + config.time_zone = 'UTC' +end + +}}} + +Edit your *config/ldap.yml* script and fill in the relevant details: + +{{{ +development: + host: 172.31.0.8 + base: DC=contorso,DC=com + bind_dn: 'CONTORSO\joe.blogs' + password: + + +}}} + +That's it. We now move on to creating the model. + +== Creating a Users Model == + +As we are going to be using LDAP as a backend and not ActiveRecord, we can use the `generate` script, without a migration: + +{{{ +~/rails/activedirectory$ ./script/generate model --skip-migration user + exists app/models/ + exists test/unit/ + exists test/fixtures/ + create app/models/user.rb + create test/unit/user_test.rb + create test/fixtures/users.yml +~/rails/activedirectory$ + +}}} + +Next, we have to edit the users model and tell it about ActiveLDAP. +An example is provided: + +{{{ +class User < ActiveLdap::Base + ldap_mapping :dn_attribute => 'cn' +end + +}}} + +Done! + +You should be able to instantiate your User object. + +=== Running the app === + +Test your newly created Rails / Active Directory integration by: + +{{{ +~/rails/activedirectory$ ./script/console +Loading development environment (Rails 2.3.5) +>> User.all("joe*") + + +}}} From codesite-noreply at google.com Fri Jan 8 02:14:37 2010 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 08 Jan 2010 07:14:37 +0000 Subject: [activeldap-commit] [ruby-activeldap] r1124 committed - Edited wiki page through web user interface. Message-ID: <0016361641fdbafac2047ca1f02e@google.com> Revision: 1124 Author: bruce.mcintyre Date: Thu Jan 7 23:13:48 2010 Log: Edited wiki page through web user interface. http://code.google.com/p/ruby-activeldap/source/detail?r=1124 Modified: /wiki/ActiveDirectoryHowTo.wiki ======================================= --- /wiki/ActiveDirectoryHowTo.wiki Thu Jan 7 00:51:39 2010 +++ /wiki/ActiveDirectoryHowTo.wiki Thu Jan 7 23:13:48 2010 @@ -23,7 +23,6 @@ Connected to 172.31.0.8. Escape character is '^]'. - }}} If the socket opens, you are in business. @@ -105,7 +104,7 @@ RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION require File.join(File.dirname(__FILE__), 'boot') Rails::Initializer.run do |config| - require 'active_ldap' + require 'activeldap', :lib => 'active_ldap' config.time_zone = 'UTC' end @@ -130,7 +129,7 @@ As we are going to be using LDAP as a backend and not ActiveRecord, we can use the `generate` script, without a migration: {{{ -~/rails/activedirectory$ ./script/generate model --skip-migration user +~/rails/activedirectory$ ./script/generate model_active_ldap user exists app/models/ exists test/unit/ exists test/fixtures/ From codesite-noreply at google.com Tue Jan 26 08:15:53 2010 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 26 Jan 2010 13:15:53 +0000 Subject: [activeldap-commit] [ruby-activeldap] r1125 committed - * accept not-String attribute value as LDIF value.... Message-ID: <0016e68ef437e114b4047e111594@google.com> Revision: 1125 Author: koutou Date: Tue Jan 26 05:15:11 2010 Log: * accept not-String attribute value as LDIF value. Reported by Matt Mencel. Thanks!!! http://code.google.com/p/ruby-activeldap/source/detail?r=1125 Modified: /trunk/CHANGES /trunk/README /trunk/lib/active_ldap/ldif.rb /trunk/test/test_ldif.rb ======================================= --- /trunk/CHANGES Fri Dec 18 03:53:08 2009 +++ /trunk/CHANGES Tue Jan 26 05:15:11 2010 @@ -4,6 +4,7 @@ * [#37] Fixed gem dependencies in Rakefile. [zachwily] * Fixed a bug that setting 'false' but 'nil' is returned. [Hideyuki Yasuda] +* Supported non-String attribute value as LDIF value. [Matt Mencel] == 1.2.1: 2009-12-15 ======================================= --- /trunk/README Wed Dec 16 03:35:11 2009 +++ /trunk/README Tue Jan 26 05:15:11 2010 @@ -113,7 +113,7 @@ * Bug reports. * Lennon Day-Reynolds: Bug reports. * Tilo: A bug report. -* Matt Mencel: A bug report. +* Matt Mencel: Bug reports. * CultureSpy: * Bug reports. * Bug fixes. ======================================= --- /trunk/lib/active_ldap/ldif.rb Sun Aug 16 00:41:04 2009 +++ /trunk/lib/active_ldap/ldif.rb Tue Jan 26 05:15:11 2010 @@ -46,7 +46,7 @@ return "#{name}:\n" if value.blank? result = "#{name}:" - value = value.to_s if value.is_a?(DN) + value = value.to_s unless value.is_a?(String) if value[-1, 1] == ' ' or binary_value?(value) result << ":" value = [value].pack("m").gsub(/\n/, '') ======================================= --- /trunk/test/test_ldif.rb Sat Mar 7 01:38:42 2009 +++ /trunk/test/test_ldif.rb Tue Jan 26 05:15:11 2010 @@ -9,6 +9,16 @@ include AlTestUtils::ExampleFile priority :must + def test_integer_attribute_value_to_s + dn = ActiveLdap::DN.parse("uid=user,ou=People,dc=example,dc=com") + record = ActiveLdap::Ldif::Record.new(dn, {"uidNumber" => [100]}) + assert_equal(<<-EOL, record.to_s) +dn: uid=user,ou=People,dc=example,dc=com +uidNumber: 100 +EOL + end + + priority :normal def test_accept_empty_lines_after_content ldif_source = <<-EOL version: 1 @@ -65,7 +75,6 @@ EOL end - priority :normal def test_comments_and_empty_lines_before_content ldif_source = <<-EOL version: 1