README.txt in dm-ldap-adapter-0.3.5 vs README.txt in dm-ldap-adapter-0.4.0.alpha2
- old
+ new
@@ -2,11 +2,11 @@
*Homepage*: [http://dm-ldap-adapter.rubyforge.org]
*Git*: [http://github.com/mkristian/dm-ldap-adapter]
-*Author*: Kristian Meier
+*Author*: Kristian Meier
*Copyright*: 2008-2009
== DESCRIPTION:
@@ -19,18 +19,18 @@
the ldap library which does the actual ldap protocol stuff is [http://rubyforge.org/projects/net-ldap] which is the default. the other ldap library is [http://rubyforge.org/projects/ruby-ldap]. just add a facade parameter when setting up DataMapper
DataMapper.setup(:ldap, {
:adapter => 'ldap',
:facade => :ruby_ldap,
- .... })
+ .... })
or
DataMapper.setup(:ldap, {
:adapter => 'ldap',
:facade => :net_ldap,
- .... })
+ .... })
=== setup DataMapper
DataMapper.setup(:ldap, {
:adapter => 'ldap',
@@ -38,11 +38,11 @@
:port => '389',
:base => "dc=example,dc=com",
:facade => :ruby_ldap,
:bind_name => "cn=admin,dc=example,dc=com",
:password => "behappy"
- })
+ })
=== examples
see 'example/posix.rb' for user/group setup works with default installation of openldap on ubuntu (just change your password as needed in the code)
@@ -90,12 +90,12 @@
this uses the underlying bind of a ldap connection. so on any model where you have the `dn_prefix` and the `treebase` configured, you can call the method `authenticate(password)`. this will forward the request to the ldap server.
=== queries
-conditions in ldap depend on the attributes definition in the ldap schema. here is the list of what is working with that ldap adapter side and the usual AND between the conditions:
-
+conditions in ldap depend on the attributes definition in the ldap schema. here is the list of what is working with that ldap adapter side and the usual AND between the conditions:
+
* :eql
* :not
* :like
* :in
* Range
@@ -121,44 +121,44 @@
=== multiple repositories
most probably you have to work with ldap as one repository and a database as a second repository. for me it worked best to define the `default_repository` for each model in the model itself:
class User
- . . .
+ . . .
def self.default_repository_name
:ldap
end
end
class Config
- . . .
+ . . .
def self.default_repository_name
:db
end
end
if you want to benefit from the advantages of the identidy maps you need to wrap your actions for *merb* see http://www.datamapper.org/doku.php?id=docs:identity_map or for *rails* put an `around_filter` inside application.rb
around_filter :repositories
-
+
def repositories
DataMapper.repository(:ldap) do
DataMapper.repository(:db) do
yield
- end
- end
+ end
+ end
end
and to let the ldap resources use the ldap respository it is best to bind it to that repository like this
class User
. . .
def self.repository_name
:ldap
end
end
-
+
=== transactions
the adapter offers a noop transaction, i.e. you can wrap everything into a transaction but the ldap part has no functionality.
*note*: the ldap protocol does not know transactions
@@ -166,20 +166,20 @@
=== many-to-many associations
staying with posix example there the groups has a memberuid attribute BUT unlike with relational databases it can have multiple values. to achieve a relationship with these values the underlying adapter needs to know that this specific attribute needs to be handled differently. for this `multivalue_field` comes into play. the ldap adapter clones the model and places the each memberuid in its own clone.
class GroupUser
- include DataMapper::Resource
+ include DataMapper::Resource
property :memberuid, String, :key => true
property :gidnumber, Integer, :key => true
dn_prefix { |group_user| "cn=#{group_user.group.name}" }
treebase "ou=groups"
ldap_properties do |group_user|
{:cn=>"#{group_user.group.name}", :objectclass => "posixGroup"}
end
-
+
multivalue_field :memberuid
-
+
end
=== ldap attributes with many values
let's say your LDAP has multiple email values for a users then you can define your resource class like that using the type *LdapArray* for such multivalue fields