473,563 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13329
FYI,

ws.Credentials = System.Net.Cred entialCache.Def aultCredentials ;

will do that job!!!

"John Lee" <jo***@newsgrou p.nospam> wrote in message
news:e5******** ******@TK2MSFTN GP14.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.Credentia ls = System.Net.Cred entialCache.Def aultCredentials

DefaultCredenti als 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.Netw orkCredential class and the
System.Net.Cred entialCache class. For example, here is a code snippet that
manually generate a Credential that use NTLM authentication type:

=============== =============== ======
private void btnCall_Click(o bject sender, System.EventArg s e)
{
//create webservice proxy
MyService.MySer vice ms = new AuthClient.MySe rvice.MyService ();

//create networkCredenti al
System.Net.Netw orkCredential nc = new System.Net.Netw orkCredential
("username","pa ssword","domain name");
System.Net.Cred entialCache cc = new System.Net.Cred entialCache();

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

ms.Credentials = cc;

ms.Execute("dfd sfds");

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

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
14898
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
2787
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 = System.Net.CredentialCache.DefaultCredentials; (ws is a web service proxy request instance) to call the web service BUT this method does not work if I...
1
1550
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 denied error message from the webservice unless I turn on the anonymous login in the config file for the service. Note, the original web application...
5
10380
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 they need to consume this web service using HTTP. The developer's IDE is Notepad. Yeah, weird I know. How is this done? I guess if I can get it to...
6
2890
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 the service successfully. Once started, the service is responding to requests. The service runs under a user a/c (the user is part of the local...
6
1697
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 subject" .HtmlBody = "This is the Body" .Send End With
3
7733
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 services (secure meaning windows authentication credentials must be used to access the web services). The problem is that when the web apps attempt to...
3
13773
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 service run in an application pool which runs under a domain user, this domain user has permissions of accessing database and the connection to...
0
2060
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: Authentication Mode=Windows Identity Impersonate=False IIS Allow Anonymous Disabled Integrated Windows Authentication Enabled Application Pool...
1
2222
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 coding.. public MemberView ChangeEmailAddress(InfiSession infiSes, string oldEmailAddress, string newEmailAddress) { try ...
0
7659
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7882
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7634
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7945
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5481
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.