class LdapAdmin
  def initialize()
    @LDAP_SERVER = 'ldap.lse.ac.uk'
    @LDAP_BASE_DN = 'dc=linux,dc=lse,dc=ac,dc=uk'
  end

  def login_connect?(login, password)
    # test whether the login can connect to ldap with password
    # -> true - yes
    # -> false - no
    require 'ldap'
    flag = false
    con = LDAP::Conn.new(@LDAP_SERVER)
    con.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
    begin
      con.bind("cn=#{login},#{@LDAP_BASE_DN}", password)
      con.unbind()
      flag = true
    rescue LDAP::ResultError
      flag = false
    end
    return flag
  end
end

the above chunk of code works for me. the #{login} is admin and the password
is the one specified in /etc/ldap/slapd.conf file (basically, i use it to
log in to ldap admin account).

hope this helps,

vlad