On 12/14/06, Eduardo Yez Parareda <eduardo.yanezNOSPAM / nospamgmail.com> wrote:
> The LDAP server is from Netscape, don't know exactly which version is it.
>
> > the Size limit exceeded error. Can you show an example of the bind_as
> > call that you are using?
>
> Yes, of course. This is the module I use to authenticate with bind_as:
>
>    require 'net/ldap'
>
>    module LDAP
>      # If login succeeds returns true
>      # If login fails returns false
>      def self.authenticate(identifier, password)
>        if identifier.to_s.length > 0 and password.to_s.length > 0
>          ldap_con = initialize_ldap_con(identifier, password)
>          if ldap_con.bind_as
>            true
>          else
>            p "ERROR => #{ldap_con.get_operation_result}"
>            false
>          end
>        end
>      end
>
>      private
>
>      def self.initialize_ldap_con(identifier, password)
>        setup = {:host => AppConfig.ldap_server_host,
>                 :port => AppConfig.ldap_server_port,
>                 :base =>AppConfig.ldap_server_tree_base }
>        setup[:auth] = { :method => :simple, :username => identifier, :password => password }
>        Net::LDAP.new(setup)
>      end
>    end
>
> However, this doesn't work when I use bind, first I had to make the DN.
>
>
>
>

You may have misunderstood how Net::LDAP#bind_as works. Go back and
re-read the rdocs. You have to first supply a known account
(identified by a DN), perhaps that of an administrator. What #bind_as
does is to call #bind as the admin account, and then query the
#bind_as username's DN. It then rebinds as the #bind_as user's DN.
This is more or less the standard way to authenticate users against
LDAP directories.