Forum: Ruby problem doing find in ActiveLdap

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Claudio C. (Guest)
on 2007-07-19 17:32
require 'active_ldap'

ActiveLdap::Base.establish_connection(
        :host => 'hostname',
        :bind_dn => 'cn=admin,ou=users,dc=company,dc=it',
        :base => 'ou=addressbooks,dc=company,dc=it',
        :password_block => 'admin'
)

class Addressbook < ActiveLdap::Base
        ldap_mapping :dn_attribute => 'cn', :prefix => 'ou=addressbooks'
end

p Addressbook.find(:all, 'John')
p Addressbook.find(:all, :attribute => 'givenName', :value => 'John')

both find returns []

What am I doing wrong?

thanks
Kouhei S. (Guest)
on 2007-07-20 03:15
(Received via mailing list)
Hi,

2007/7/19, Claudio C. <removed_email_address@domain.invalid>:

> ActiveLdap::Base.establish_connection(
>         :host => 'hostname',
>         :bind_dn => 'cn=admin,ou=users,dc=company,dc=it',
>         :base => 'ou=addressbooks,dc=company,dc=it',
>         :password_block => 'admin'
> )

You need to pass Proc object to :password_block or use :password
with String.

> class Addressbook < ActiveLdap::Base
>         ldap_mapping :dn_attribute => 'cn', :prefix => 'ou=addressbooks'
> end

In your configuration, you need to set :prefix to '' because you already
specify 'ou=addressbooks,dc=company,dc=it' as :base in
establish_connection. Or change :base to 'dc=company,dc=it' and keep
:prefix 'ou=addressbooks'.


Thanks,
Claudio C. (Guest)
on 2007-07-20 11:45
Kouhei S. wrote:
> Hi,
>
> 2007/7/19, Claudio C. <removed_email_address@domain.invalid>:
>
>> ActiveLdap::Base.establish_connection(
>>         :host => 'hostname',
>>         :bind_dn => 'cn=admin,ou=users,dc=company,dc=it',
>>         :base => 'ou=addressbooks,dc=company,dc=it',
>>         :password_block => 'admin'
>> )
>
> You need to pass Proc object to :password_block or use :password
> with String.
>
>> class Addressbook < ActiveLdap::Base
>>         ldap_mapping :dn_attribute => 'cn', :prefix => 'ou=addressbooks'
>> end
>
> In your configuration, you need to set :prefix to '' because you already
> specify 'ou=addressbooks,dc=company,dc=it' as :base in
> establish_connection. Or change :base to 'dc=company,dc=it' and keep
> :prefix 'ou=addressbooks'.
>
>
> Thanks,

I follow your directive and i added this:

pwb = Proc.new do |user|
   ActiveLdap::Command.read_password("[#{user}] Password: ")
end

...and works like a charm!!!!

Thanks a lot!
This topic is locked and can not be replied to.