class Net::LDAP::AuthAdapers::GSS_SPNEGO

Public Instance Methods

bind(auth) click to toggle source
# File lib/net/ldap/auth_adapter/gss_spnego.rb, line 19
def bind(auth)
  require 'ntlm'

  user, psw = [auth[:username] || auth[:dn], auth[:password]]
  raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless (user && psw)

  nego = proc do |challenge|
    t2_msg = NTLM::Message.parse(challenge)
    t3_msg = t2_msg.response({ :user => user, :password => psw },
                             { :ntlmv2 => true })
    t3_msg.serialize
  end

  Net::LDAP::AuthAdapter::Sasl.new(@connection).bind \
    :method             => :sasl,
    :mechanism          => "GSS-SPNEGO",
    :initial_credential => NTLM::Message::Type1.new.serialize,
    :challenge_response => nego
end