In article <200103011318.WAA26827 / mailrelay.jaist.ac.jp>,
Takaaki Tateishi  <ttate / jaist.ac.jp> wrote:
> how about Entry#to_hash? (see also test/search3.rb)

Thanks, that works. I've already tried it but it was also outside the scope
of the search... Here my final script:

-=-=-
#! /usr/bin/env ruby
# -*-Ruby-*-
#
## Copyright 2001 Ollivier Robert
#
## Gets the list of mail recipients from the LDAP server and generates
## a mutt compatible alias file.
##
#
## 1.0        28/02/2001    first version
#
require 'ldap'

## Config.
ldap_base   = "ou=EEC, o=EUROCONTROL"
ldap_filter = "(&(objectclass=inetOrgPerson)(objectclass=mailRecipient))"
ldap_attrs  = [
  "sn",
  "givenname",
  "telephonenumber",
  "roomnumber",
  "mail",
  "uid",
  "ou",
]

ldap_server = "ldap.eurocontrol.fr"

users = Hash.new

conn = LDAP::Conn.new (ldap_server, LDAP::LDAP_PORT)
conn.bind {
  conn.perror ("bind")
  begin
    conn.search (ldap_base, 
                 LDAP::LDAP_SCOPE_SUBTREE, 
                 ldap_filter,
                 ldap_attrs) { |e|
      users[e.vals("uid").to_s] = e.to_hash
    }
  rescue LDAP::ResultError => msg
    $stderr.print (msg)
  end

  uids = Array.new
  uids = users.keys

  users.keys.sort.each { |key|
    user = users[key].to_hash
    user["sn"] = user["sn"].to_s.capitalize
    print <<"EOTEXT"
# Acronym: #{user['uid']} / Room: #{user['roomnumber']} / Phone: #{user['telephonenumber']} / COE: #{user['ou']}
alias #{user['uid']} #{user['givenname']} #{user['sn']} <#{user['mail']}>
EOTEXT
  }
}
-=-=-

> but this method is experimental, so I will change the
> name or specification of it in the future.

I'll follow the developpement closely then :-)

Domo arigato.
-- 
Ollivier ROBERT   -=- Eurocontrol EEC/ITM -=-   roberto / eurocontrol.fr
Usenet Canal Historique                   FreeBSD: The Power to Serve!