Sha256: 92c1c6f773dc92e67546531436bf5ecc8a4f38bc78d7bb8e68b28a2e8ffc4b0a
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
#!/usr/local/bin/ruby -w # This is a trivial LDAP server which just stores directory entries in RAM. # It does no validation or authentication. This is intended just to # demonstrate the API, it's not for real-world use!! require 'rubygems' require 'ldap/server' # We subclass the Operation class, overriding the methods to do what we need class HashOperation < LDAP::Server::Operation def initialize(connection, messageID, hash) super(connection, messageID) @hash = hash # an object reference to our directory data end def search(basedn, scope, deref, filter) basedn.downcase! case scope when LDAP::Server::BaseObject # client asked for single object by DN obj = @hash[basedn] raise LDAP::ResultError::NoSuchObject unless obj send_SearchResultEntry(basedn, obj) if LDAP::Server::Filter.run(filter, obj) when LDAP::Server::WholeSubtree @hash.each do |dn, av| next unless dn.index(basedn, -basedn.length) # under basedn? next unless LDAP::Server::Filter.run(filter, av) # attribute filter? send_SearchResultEntry(dn, av) end else raise LDAP::ResultError::UnwillingToPerform, "OneLevel not implemented" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pg-ldap-sync-0.1.1 | test/ldap_server.rb |
pg-ldap-sync-0.1.0 | test/ldap_server.rb |