1
2

More than 5 years have passed since last update.

Ruby で NTLM 認証しろって言われたときのメモ

Posted at

NTLM 認証って言う奴。初めて使った。ruby-ntlm ってやつ使うと簡単にできたよ。


require 'ntlm/http'
require 'active_support'


http = Net::HTTP.new(uri.host, uri.port)
response = http.start do
  request = Net::HTTP::Post.new(uri.path)
  request.add_field('Content-Type', 'text/xml; charset=utf-8')
  request.add_field('SOAPAction', 'http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute')
  request.ntlm_auth('ユーザID', '', 'パスワード')
  request.add_field('open_timeout', 30)
  request.add_field('read_timeout', 30)
  request.body = '投げるXML'
  http.request(request)
end
hash = Hash.from_xml(response.body)

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2