You'll need ActiveLdap models configured:
http://ruby-activeldap.rubyforge.org/doc/
Here's the textile for the Readme for ambitious-activeldap that I
haven't gotten posted to the docs site yet.
---
h2. An Ambitious ActiveLdap Adapter
Write LDAP search filters in Ruby. Awesomeness courtesy of Chris
Wanstrath's Ambition library.
You must be using ActiveLdap 0.9 or greater.
h2. Get It
@$ sudo gem install ambitious-activeldap@
<pre>
require 'rubygems'
require 'ambition/adapters/active_ldap'
</pre>
h2. Examples
Let @User@ be a subclass of @ActiveLdap::Base@
<ruby>
User.select { |u| u.givenName == 'Severian' }.each do |user|
puts user.name
end
</ruby>
Queries don't run until you kick them. This adapter supports only the
basic kicker methods: @each@, @each_with_index@, @map@, @entries@,
@to_a@.
This adapter also doesn't support the methods that require sorting,
slicing, or counting, because ActiveLdap effectively doesn't support
such things. ActiveLdap lets you _request_ sorted and sliced result
sets, but it does the work in Ruby, so you might as well do it yourself.
You can call @to_s@, but not @to_hash@ on a query. @to_s@ returns
the LDAP search filter as a string.
<ruby>
>> User.select { |m| m.givenName == 'Jonas' }.to_s
=> "(givenName=Jonas)"
</ruby>
h2. Issues.find(:all, :filter => "(type=bug)")
Bug me: "http://rubyforge.org/users/automatthew/":http://
rubyforge.org/users/automatthew/
More information on Ambition:
* "http://ambition.rubyforge.org":http://ambition.rubyforge.org
* "http://groups.google.com/group/ambition-rb/":http://
groups.google.com/group/ambition-rb/
>
> Ok, I've tried to get a plain-jane install of ActiveLdap working with
> no success.
>
> I first tried to just 'gem install activeldap'. That didn't appear to
> work, when I tried to execute a search, it starts complaining about
> "`gem_original_require': no such file to load -- ldap
> (MissingSourceFile)".
The ActiveLdap gem name has changed from when I began the ambition
adapter. I have some projects using the old version, and I couldn't
immediately get the new version to work with Ambition.
gem install ruby-activeldap
ActiveLdap depends on either Net::LDAP or Ruby/LDAP. There's a gem
for the former, but not the latter:
gem install ruby-net-ldap.
I had less trouble with the one you have to compile, however. Source
at:
http://sourceforge.net/project/showfiles.php?group_id=66444
> Does anyone have any tips about
> installing activeldap? Why isn't it as simple as every other gem?
External dependencies, for one. Also, in general, the more I use
LDAP, the more I dislike it.
> (matthew, I'd be happy to take this offline if you like; you seemed
> willing to take questions based on your bug me statement in your post
> above, but I figured it might be useful for someone else if the
> discussion takes place in the open)
If we don't do it in the open, how shall I make a fool of myself?
Matthew
> You said ActiveLDAP depends on either NET::LDAP or Ruby/LDAP. Since I
> have Net::LDAP working, is there info anywhere on getting ActiveLDAP
> to "depend" on that? I hadn't seen that anywhere yet.
I can't seem to find this in the official docs, but I think you
specify :adapter => 'net_ldap' in the connection options.