Created
October 26, 2011 08:08
-
-
Save alkesh/1315755 to your computer and use it in GitHub Desktop.
Authentication using EWS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'curb' | |
require 'uri' | |
#uri = URI.parse("https://oa.bt.com/ews/Services.wsdl") | |
c = Curl::Easy.new("https://oa.bt.com/ews/Exchange.asmx") | |
#c = Curl::Easy.new("https://oa.bt.com/ews/Services.wsdl") | |
c.http_auth_types = :ntlm | |
c.username = '700618819' | |
c.password = 'foo' | |
#c.perform | |
#puts c.body_str | |
#puts c.response_code | |
get_folder_xml ='<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" | |
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> | |
<soap:Body> | |
<GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" | |
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> | |
<FolderShape> | |
<t:BaseShape>Default</t:BaseShape> | |
</FolderShape> | |
<FolderIds> | |
<t:DistinguishedFolderId Id="inbox"/> | |
</FolderIds> | |
</GetFolder> | |
</soap:Body> | |
</soap:Envelope>' | |
resolve_names_xml = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" | |
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> | |
<soap:Body> | |
<ResolveNames xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" | |
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" | |
ReturnFullContactData="true"> | |
<UnresolvedEntry>700618819</UnresolvedEntry> | |
</ResolveNames> | |
</soap:Body> | |
</soap:Envelope>' | |
#c.post_body=URI.encode_www_form_component(get_folder_xml) | |
#c.post_body=get_folder_xml | |
c.post_body=resolve_names_xml | |
c.headers = "Content-Type:text/xml" | |
c.perform | |
puts c.response_code | |
puts c.body_str | |
=begin | |
curl --ntlm -u 700618819 -d '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t=microsoft.com/exchange/services/2006/types"> <soap:Body> <GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <FolderShape> <t:BaseShape>Default</t:BaseShape> </FolderShape> <FolderIds> <t:DistinguishedFolderId Id="inbox"/> </FolderIds> </GetFolder> </soap:Body> </soap:Envelope>' -H "Content-Type:text/xml" -L https://oa.bt.com/ews/Exchange.asmx -k | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment