9. Querying Oak LDAP from Ruby

The instructions in this section assume that you have configured your system according to Common Client Configuration.

9.1. Synchronisation to SQL Database

Christopher Hoskin (St Antony's College) has developed some Ruby code to synchronise a local database with unit data in Oak LDAP. As with other examples, this will need access to a suitable Kerberos credentials cache so would typically be run under k5start. Heavily trimmed example code:

# main.rb
# Extremely trimmed example to retrieve and print attributes of a person entry
# Supplied by Christopher Hoskin, St Antony's College, 22nd July 2010

require 'ldap'

conn = LDAP::SSLConn.new(host='ldap.oak.ox.ac.uk', port=636)

conn.search('ou=people,dc=oak,dc=ox,dc=ac,dc=uk', LDAP::LDAP_SCOPE_ONELEVEL, "(sn=Howes)", nil) { |entry|
    entry.to_hash.each { |key, value| puts "%s : %s" % [key, value[0]]}


Up: Contents Previous: 8. Querying Oak LDAP from Java Next: 10. Performance