473,396 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Web Service Authentication Problem

class CSampleBasicAuth : public CBasicAuthObject, public IAuthInfo
{
public :
void setUserName()
{
username = L"foo";
password = L"bar";
}

void Init(CAtlHttpClient *pSocket, IAuthInfo *pAuthInfo)
{
CBasicAuthObject::Init( pSocket, pAuthInfo );
}
bool Authenticate(LPCTSTR szAuthTypes, bool bProxy)
{
return CBasicAuthObject::Authenticate( szAuthTypes, bProxy );
}

HRESULT GetPassword(LPTSTR szPwd, DWORD* dwBuffSize)
{
if (CopyCString( password, szPwd, dwBuffSize ))
return S_OK;

return E_FAIL;
}

HRESULT GetUsername(LPTSTR szUid, DWORD* dwBuffSize)
{
if (CopyCString( username, szUid, dwBuffSize ))
return S_OK;

return E_FAIL;
}
HRESULT GetDomain(LPTSTR szDomain, DWORD* dwBuffSize)
{
ATLASSERT(false);
return S_OK;
}

CString username;
CString password;
};
....
void CWSdenemeDlg::OnBnClickedOk()
{
CString strMessage;

CoInitialize(NULL);

CWebService *ws = new CWebService();

ws->CleanupClient();

CAtlHttpClient &httpClient = ws->m_socket;

CSampleBasicAuth authObject;

authObject.setUserName();

httpClient.AddAuthObj(ATL_HTTP_AUTHTYPE_BASIC, &authObject,
&authObject);

bool val = httpClient.NegotiateAuth(true);

WSInputClass in;

in.member = ...

WSOutputClass* out = new WSOutputClass();

HRESULT hr = (HRESULT) ws->process(in, out);

if(FAILED(hr)){
switch(ws->GetClientError( ))
{
case SOAPCLIENT_INITIALIZE_ERROR :
strMessage="SOAPCLIENT_INITIALIZE_ERROR";
break;
case SOAPCLIENT_OUTOFMEMORY :
strMessage="SOAPCLIENT_OUTOFMEMORY";
break;
case SOAPCLIENT_GENERATE_ERROR :
strMessage="SOAPCLIENT_GENERATE_ERROR";
break;
case SOAPCLIENT_CONNECT_ERROR :
strMessage="SOAPCLIENT_CONNECT_ERROR";
break;
case SOAPCLIENT_SEND_ERROR :
strMessage="SOAPCLIENT_SEND_ERROR";
break;
case SOAPCLIENT_SERVER_ERROR :
strMessage="SOAPCLIENT_SERVER_ERROR ";
break;
case SOAPCLIENT_SOAPFAULT :
strMessage="SOAPCLIENT_SOAPFAULT";
break;
case SOAPCLIENT_PARSEFAULT_ERROR :
strMessage="SOAPCLIENT_PARSEFAULT_ERROR";
break;
case SOAPCLIENT_READ_ERROR :
strMessage="SOAPCLIENT_READ_ERROR";
break;
case SOAPCLIENT_PARSE_ERROR :
strMessage="SOAPCLIENT_PARSE_ERROR";
break;
case SOAPCLIENT_SUCCESS :
strMessage="SOAPCLIENT_SUCCESS";
break;
}
MessageBox(strMessage);
}

}

Feb 13 '07 #1
2 3321
Sorry, I mistakenly erased the information part.

I want to retrieve information from secured(requires user name and
password) web service. I can connect it with .NET using
NetworkCredentials class. But when I tried it with C++, I cannot even
send the username and password. I analyze the network activity with
Ethereal, the code doesn't send any authentication information. So the
server send HTTP 401 Authectication error back.

I'm searching web since last friday. I read and tried all I found.
What am i doing wrong?

Thanks for your help.

Feb 13 '07 #2
I solved the issue. Just added the following line.

httpClient.SetSilentLogonOk(true);

Thanks

Feb 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: pberna | last post by:
Dear all, I built a Web Form application to start and stop a Windows Service remotely. I successful tested the application on Windows 2000 server + IIS. I must include the ASPNET user to the...
3
by: cmueller | last post by:
Hey all - I'm in a bit of a bind concerning web services and integrated authentication. I'll give you a little background as to what I'm trying to do ... I have a client application that...
3
by: Evan Camilleri | last post by:
I have a problem for a Windows Service to login on an SQL server (different machine) - neither Windows Authentication nor SQL Authentication worked. LOGIN FAILED FOR USER sa (for example). If...
3
by: Wild Wind | last post by:
Hello all, I apologise in advance for the long windedness of this post, but I feel that if I am going to get any solution to this problem, it is important that I present as much information...
0
by: John Bown | last post by:
This query is similar to some others on this discussion group, but none of them were resolved! Can anybody help: The issue is related to integrated authentication. First I'll describe a simple...
0
by: Albertas | last post by:
What I'm doing wrong that I can't make my authentication to work. Here is the situation: I'm hosting a Web Service from a Windows forms application, using .NET Framework 3.0 WCF. And I want to...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
3
by: Brad | last post by:
I'm setting up my new pc with all my VS.net projects and I'm missing something.....something I've done many times before without problem. I have several asp.net apps accessing secure .net web...
4
by: =?Utf-8?B?VGFrdW1p?= | last post by:
I have a ASP.NET web page that calls a web service on a server with IIS installed on it. When it calls the web service, it gives a HTTP status 401 error stating that it is unauthorized to call the...
0
by: JeremyPollack | last post by:
Here's the situation : I have the same ASP.NET 2.0 web application running on both Machine A and Machine B. On both machines, I have Integrated Windows Authentication turned on, and Anonymous...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.