class RBMK::Operation

Attributes

orig[R]

Okay, now the actual code

server[R]

Okay, now the actual code

transformed[R]

Okay, now the actual code

Public Class Methods

new(conn, mid, worker) click to toggle source
Calls superclass method
# File lib/rbmk/operation.rb, line 150
def initialize conn, mid, worker
        super conn, mid
        @orig = {}
        @transformed = {}
        @worker = worker
end

Public Instance Methods

send_SearchResultEntry(dn, avs, opt={}) click to toggle source

First some patches

# File lib/rbmk/operation.rb, line 66
def send_SearchResultEntry(dn, avs, opt={})
        @rescount += 1
        if @sizelimit
                raise LDAP::ResultError::SizeLimitExceeded if @rescount > @sizelimit
        end

        if @schema
                @attributes = @attributes.map { |a| (['*', '+'].include? a) ? a : @schema.find_attrtype(a).to_s }
        end

        avseq = []

        avs.each do |attr, vals|

                send = if @attributes.include? '+' then
                        true
                elsif @attributes.include? '*' then
                        if @schema then
                                a = @schema.find_attrtype(attr) rescue nil
                                a and (a.usage.nil? or a.usage == :userApplications)
                        else
                                true
                        end
                else
                        @attributes.include? attr
                end

                next unless send

                if @typesOnly
                        vals = []
                else
                        vals = [vals] unless vals.kind_of?(Array)
                end
                avseq << OpenSSL::ASN1::Sequence([OpenSSL::ASN1::OctetString(attr), OpenSSL::ASN1::Set(vals.collect { |v| OpenSSL::ASN1::OctetString(v.to_s) })])
        end

        send_LDAPMessage(OpenSSL::ASN1::Sequence([OpenSSL::ASN1::OctetString(dn), OpenSSL::ASN1::Sequence(avseq)], 4, :IMPLICIT, :APPLICATION), opt)
end
simple_bind(version, dn, password) click to toggle source
# File lib/rbmk/operation.rb, line 157
def simple_bind version, dn, password
        orig = {version: version, dn: dn, password: password}
        opts = transformed __method__, orig.clone
        $log.info sprintf('Bind version: %s, dn: %s',
                log_chunk(orig, opts, '%i', :version),
                log_chunk(orig, opts, '%p', :dn)
        )
        @server.bind *opts.values_at(:version, :dn, :password)
rescue LDAP::ResultError
        $!.log_debug
        raise $!
end

Protected Instance Methods

log_chunk(orig, transformed, format, key) click to toggle source
# File lib/rbmk/operation.rb, line 192
def log_chunk orig, transformed, format, key
        if orig[key] === transformed[key] then
                sprintf format, orig[key]
        else
                sprintf "(#{format} -> #{format})", orig[key], transformed[key]
        end
rescue
        debug "orig: #{orig.inspect}"
        debug "transformed: #{transformed.inspect}"
        debug "format: #{format.inspect}"
        debug "key: #{key.inspect}"
        raise $!
end
transformed_entries(entries) click to toggle source

Patch this method to transform outbound found entries. Expect an array of hashes, each of which MUST have a 'dn' key

# File lib/rbmk/operation.rb, line 238
def transformed_entries entries
        entries
end
transformed_simple_bind(opts) click to toggle source

Patch this method to transform incoming bind data. Expect a hash with these keys: :version LDAP protocol version; should probably be 3 :dn Bind DN; like a “username” :password Cleartext! Verrrry sensitive!

# File lib/rbmk/operation.rb, line 219
def transformed_simple_bind opts
        opts
end