devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Ruby Source Code Warehouse" project. The intent of this project is to help you "Learn Ruby by Example" TM.

Other links

The source code

# $Id: apopfilter_ldap.rb,v 1.2 2004/04/04 02:10:14 tommy Exp $
#
# Copyright (C) 2003-2004 TOMITA Masahiro
# tommy@tmtm.org
#

require "ldap"

$ldap_method = LDAP::LDAP_AUTH_SIMPLE
$ldap_scope = LDAP::LDAP_SCOPE_SUBTREE

class POPS
  def get_passwd(user)
    ldap = LDAP::Conn.new($ldap_server, $ldap_port)
    ldap.bind($ldap_dn, $ldap_passwd, $ldap_method) if $ldap_dn
    pw = nil
    filter = sprintf($ldap_filter, user)
    ldap.search($ldap_base, $ldap_scope, filter) do |e|
      pw = e.to_hash[$ldap_passwd_attribute][0]
      break
    end
    ldap.unbind if $ldap_dn
    pw
  end
end




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com