> David's points are quite true, however the Net::LDAP#bind_as method is
> intended to encapsulate the same technique. Now that you have it
> working, I'd be very grateful if you tried #bind_as and see if it also
> works for you.

Hello, I've tried it, although before I read the documentation again more slowly :),
and it worked right. What I don't understand is why whether you try to 'bind_as'
with :method => :anonymous it doesn't work, and you have to put :method => :simple
with blank username and password.

The final code is:

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(:base => AppConfig.ldap_server_tree_base,
                             :filter => "(uid=#{identifier})",
                             :password => password)
           true
         else
           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 => '', :password => '' }
       Net::LDAP.new(setup)
     end
   end

Although I'm going to change it in order to obtain user's information like e-mail or so after authentication.