Stuck on NTLM authentication - working with EWS SOAP using native code

closed account (L8kjE3v7)
Hi,

I am fairly new with C++, a lot of my code currently is from snippets, however i am an intermediate programmer in (VB and C# .NET).

Is anyone here familiar with working with EWS via C++ native code? Connecting with SOAP without using any libs, manually sending HTTP SOAP messages? I am stuck with the HTTP NTLM authentication and send/receiving SOAP messages...

Can anyone here help me with it?

I have connected via Windows Sock, and SSL using open SSL lib. I am trying to use a NTLM lib for the NTLM authentication. I am able to send and receive HTTP.

This is the HTTP i am getting so far:
Attempting to connect and open TCP socket for exchange server...
Connected

Attempting to connect via SSL...
SSL is connected. Ready to authenticate...
Sending "GET /EWS/Services.wsdl HTTP/1.1\r\nHost: srv-dcilab-ex01:443\r\nConnection: Keep-Alive\r\nAuthorization: NTLM %s\r\n\r\n"
---------------------http received------------
HTTP/1.1 401 Unauthorized
Server: Microsoft-IIS/7.5
Set-Cookie: exchangecookie=3b87c03eef124046a43bef50fe63309f; expires=Tue, 23-Jul
-2013 14:44:24 GMT; path=/; HttpOnly
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Mon, 23 Jul 2012 14:44:24 GMT
Content-Length: 0
------------------end http-----------------

attempting authentication

sending .."GET /EWS/Services.wsdl HTTP/1.1\r\nHost: srv-dcilab-ex01:443\r\nConnection: Keep-Alive\r\nAuthorization: NTLM %s\r\n\r\n"
---------------------http received------------
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 23 Jul 2012 14:44:24 GMT
Connection: close
Content-Length: 326

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/str
ict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Verb</h2>
<hr><p>HTTP Error 400. The request verb is invalid.</p>
Closing Connection and Socket...
------------------end http-----------------


I have been stuck on this part for over a day or two, i would really appreciate it if someone can help.
Thanks.
Use libcurl library, it supports NTLM authentication.
http://curl.haxx.se/

Do not forget to compile and link OpenSSL library too.
closed account (L8kjE3v7)
Thank you! I will try that...

So I am using libcurl for the NTLM auth and the HTTP communication right? Btw, is the messages that i am sending correct? I am not too familiar with HTTP and Sockets...

"GET /EWS/Services.wsdl HTTP/1.1\r\nHost: srv-dcilab-ex01:443\r\nConnection: Keep-Alive\r\nAuthorization: NTLM %s\r\n\r\n"


Also, what do you mean by compile OpenSSL lib? I already have a lib and dll file, did you mean compile as in creating the dll?

I am linking using
1
2
3
4
5
6
7
8
9
10
#pragma comment(lib, "openssl/libeay32.lib" )
#pragma comment(lib, "openssl/ssleay32.lib" )

#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/bio.h>

//I think the openssl works fine, i am able to connect without any trouble
//other code in between ...
SSL_connect(ssl);
OpenSSl have a readme file with instructions how to build the library with Visual Studio. Then to build libcurl with ssl support you need to specify the path to openssl libraries to link successfully.

Or you can get precompiled libcurl binaries for your compiler from libcurl website and you don't need to compile anything (except your program, of course).

You need to supply libeay32, libssl32.dll and libcurl.dll with your application.
Topic archived. No new replies allowed.