PC Review


Reply
Thread Tools Rate Thread

How to call a web service using NT Authentication

 
 
John Lee
Guest
Posts: n/a
 
      28th Dec 2004
Hi,

I have a web service setup as "Integrated Windows Authentication" only, How
can I set the credential to call the web service from Windows application? I
tried to create the proxy, and the Network Credential class required Domain,
userName and password - that's not a good one because the password should
not be hard-coded. - Even I hardcoded it still give me "401 - not authorized
error" Do I need to use WSE2.0 to call a WS using NT authentication?

Any help and tips will be greatly appreciated!

Thanks a lot!
John


 
Reply With Quote
 
 
 
 
John Lee
Guest
Posts: n/a
 
      29th Dec 2004
FYI,

ws.Credentials = System.Net.CredentialCache.DefaultCredentials;

will do that job!!!

"John Lee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have a web service setup as "Integrated Windows Authentication" only,
> How can I set the credential to call the web service from Windows
> application? I tried to create the proxy, and the Network Credential class
> required Domain, userName and password - that's not a good one because the
> password should not be hard-coded. - Even I hardcoded it still give me
> "401 - not authorized error" Do I need to use WSE2.0 to call a WS using NT
> authentication?
>
> Any help and tips will be greatly appreciated!
>
> Thanks a lot!
> John
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      29th Dec 2004
Hi John,

If Anonymous access was turned off for the Web Service application,
requests are
required to provide credentials. By default calls to the proxy do not
inherit the
credentials of the caller. So if no credentials are explicitly being
supplied the request fails with 401, Access Denied.

#1. To set the credentials on the proxy before you make the call use

PROXY.Credentials = System.Net.CredentialCache.DefaultCredentials

DefaultCredentials represents the system credentials for the current
security context in which the application is running. For a client-side
application, these are usually the Windows credentials (user name,
password, and domain) of the user running the application. For ASP.NET
applications, the default credentials are the user credentials of the
identity for the asp worker process, or the user being impersonated.

#2. If you want to programly generate and set the Credential, you need to
use the System.Net.NetworkCredential class and the
System.Net.CredentialCache class. For example, here is a code snippet that
manually generate a Credential that use NTLM authentication type:

====================================
private void btnCall_Click(object sender, System.EventArgs e)
{
//create webservice proxy
MyService.MyService ms = new AuthClient.MyService.MyService();

//create networkCredential
System.Net.NetworkCredential nc = new System.Net.NetworkCredential
("username","password","domainname");
System.Net.CredentialCache cc = new System.Net.CredentialCache();

//add into CredentialCache and speicfy the NTLM authType
cc.Add(new Uri(ms.Url),"NTLM",nc);

ms.Credentials = cc;

ms.Execute("dfdsfds");

}
==============================

Is this the one you're looking for? If there is anything else unclear,
please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)





 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call a Web service by using a client certificate for authentication in an ASP.NET Web application Colin Microsoft ASP .NET 1 14th Jul 2007 07:44 AM
how to call .net web service call from java client? B Deepak Microsoft C# .NET 2 21st Sep 2005 05:30 AM
How to call a web service using NT Authentication from Web Service John Lee Microsoft C# .NET 1 29th Dec 2004 03:22 AM
REMOTE CALL PROCEDURE call (RPC) SERVICE Pete Q Windows XP Networking 2 23rd Nov 2003 03:34 PM
401 Authentication fail calling Web Service over SSL from PocketPC with Basic Authentication. John Hynes Microsoft Dot NET Compact Framework 0 19th Sep 2003 02:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:11 PM.