Ambition and ActiveLDAP

62 views
Skip to first unread message

tobinibot

unread,
Feb 18, 2008, 2:19:57 PM2/18/08
to ambition.rb
Hi all, I'm interested in trying out the LDAP support in Ambition,
however, I can't seem to find any help or sample code. Is there
anything out there that I can look at to figure out how to setup and
use activeldap with Ambition?
Thanks.

Note: I'm not a current activeldap user, I've been using the ruby-net-
ldap gem

Tobin

Matthew King

unread,
Feb 18, 2008, 2:42:44 PM2/18/08
to ambit...@googlegroups.com


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/

tobinibot

unread,
Feb 19, 2008, 5:42:20 PM2/19/08
to 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)".

I then thought about trying the instructions on the ActiveLdap site,
which also don't work, failing with the following error:

C:\ruby-activeldap-0.9.0>rake install
(in C:/ruby-activeldap-0.9.0)
rake aborted!
No such file or directory - History.txt
C:/ruby-activeldap-0.9.0/rakefile:47:in `new'
(See full trace by running task with --trace)

I'm sort of out of ideas here. Does anyone have any tips about
installing activeldap? Why isn't it as simple as every other gem?

Thanks,
Tobin

(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)

Matthew King

unread,
Feb 19, 2008, 5:53:14 PM2/19/08
to ambit...@googlegroups.com
On Feb 19, 2008, at 4:42 PM, tobinibot wrote:

>
> 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

tobinibot

unread,
Feb 20, 2008, 9:57:51 AM2/20/08
to ambition.rb
I have ruby-net-ldap installed and working already. I was interested
in trying Ambition's LDAP piece, but I'm not sure it's worth the
effort of trying to get everything working. I'm not great at
compiling from source, a problem compounded by the fact that I'm
working on Windows right now.

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.

Tobin

Matthew King

unread,
Feb 20, 2008, 11:38:35 AM2/20/08
to ambit...@googlegroups.com
On Feb 20, 2008, at 8:57 AM, tobinibot wrote:

> 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.

Reply all
Reply to author
Forward
0 new messages