473,385 Members | 1,772 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,385 software developers and data experts.

How to call a web service using NT Authentication

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
Nov 16 '05 #1
2 13304
FYI,

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

will do that job!!!

"John Lee" <jo***@newsgroup.nospam> wrote in message
news:e5**************@TK2MSFTNGP14.phx.gbl...
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

Nov 16 '05 #2
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.)

Nov 16 '05 #3

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

Similar topics

4
by: MTB | last post by:
I created a webservice, but I can't call the webservice using HTTP GET. SOAP and POST work fine, but not GET. Am I missing something in the configuration?
1
by: John Lee | last post by:
Hi, I have two web services and they are setup as "Integrated Windows Authentication" only and they are both assigned to application pool with Domain Account. I can use ws.Credentials =...
1
by: markeboy | last post by:
I want to be able to call a web service using integrated windows authentication from a serviced component? The COM+ application is configured to use a domain account, however, I get an access...
5
by: David Lozzi | last post by:
Howdy, I wrote a web service in .Net for my customer. My customer has another vendor who now has to consume it but they are not using Visual Studio. Most of their pages are jsp, and they said...
6
by: Ravi Shankar | last post by:
Hello, I have written a service using VB.Net which is basically a asynch socket listener. I have been able to install it successfully. Using the Service Control Manager I am able to start & stop...
6
by: AbraAbraCadabra | last post by:
Here is the code I have been using to send mail... Set objCDO = Server.CreateObject("CDO.Message") With objCDO .To = strTo .From = "markus@domain.com" .Subject = "This is the...
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...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
0
by: jordo | last post by:
I have an asp.Net app that connects to the WSS 2.0 list web service. I'm having issues with IIS and .Net configurations and hope that someone can help me. My ideal configuration is: asp.net:...
1
by: riaz1983 | last post by:
Hi, I am trying to access a .net web service using php.A member function in the web service has an object as a parameter. I was not able to access that member function. Here is the web service...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.