473,765 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Securing my webservice with Windows authentication

I have a problem securing my webservice with Windows authentication.
The goal is a client app transfering (large amounts of) data to a
server which is blocked for anonymous requests.
To do this, the client app asks the user for credentials, build some
NetworkCredenti al wit them & adds them to the CredentialCache .
When i look at the iis log, each call to my webmethod appears twice in
the log - first try without credentials (which fails with http 401) and
then a second one with credentials (which works).
As far as i see also the data is transmitted two times, really bad.
My question: How can the (first) anonymous request be suppressed?

To make it clear, here is some code:

Simple client console app, calling the server method ten times:
******** Client app:
WSTest.SecureWS myWS = new WSTest.SecureWS (); // Webservice proxy
// Credentials:
CredentialCache credCache = new CredentialCache ();
NetworkCredenti al netCred = new NetworkCredenti al("peter", <password>);
credCache.Add( new Uri(myWS.Url), "NTLM", netCred );
myWS.Credential s = credCache;
// webservice calls:
int startCount=Envi ronment.TickCou nt;
for (int i=0; i<10; i++) {
Console.WriteLi ne(myWS.WhoAmI( "".PadLeft(1000 0,"x"[0])));
}

int endCount = Environment.Tic kCount;
Console.WriteLi ne("this takes " + (endCount-startCount).ToS tring() +
"ms");
******** /Client app

Simple server webmethod:
******** Server method:
[WebMethod]
public string WhoAmI(string postData) {
return "You are: [" + Thread.CurrentP rincipal.Identi ty.Name +
"] - " + postData.Length + " bytes received.";
}

******** /Server method

With server configuration like this
<authenticati on mode="Windows" />
<deny users="?" />
the iis log shows
******** log
2005-09-19 13:33:36 127.0.0.1 - 127.0.0.1 80 POST /WSTest/SecureWS.asmx
- 401 2241 10588 0 ...
2005-09-19 13:33:36 127.0.0.1 peter 127.0.0.1 80 POST
/WSTest/SecureWS.asmx - 200 727 10834 0 ...
******** /log
for each method call. If no authorization is requested (<allow
users="*" />), the iis log shows
******** log
2005-09-19 13:33:52 127.0.0.1 - 127.0.0.1 80 POST /WSTest/SecureWS.asmx
- 200 712 10588 0 ...
******** /log
for each method call.

thx
alberich

Nov 23 '05 #1
0 1869

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

Similar topics

2
2021
by: PocketDeveloper | last post by:
I am an experienced developer...but a novice at creating web services, so please have mercy on me! Here is my question: I developed a fairly simple Webservice that returns a table from SQL Server. It runs great on my development machine. Now, I must deploy it to my website. My website is on a shared server holding lots of websites. The websoervice will not run there. It cannot read my SQL Server
2
8920
by: Russell Mangel | last post by:
Hi, How can I set permissions, so my webservice will run, without entering my name and password in the Web.Config file? I have created a WebService, and then added a Web reference to a Windows Form program. The webservice is an Administrators Utility, and needs to delete files on various drives/directories, and do file maintenance. This will require big access permissions.
13
12958
by: ALI-R | last post by:
I know how to authenticate to a webservice using either of these ways(Assuming that rService represents the webservice): 1) rService.Credentials = new System.Net.NetworkCredential("username","password","domainName"); 2)rService.Credentials = System.Net.CredentialCache.DefaultCredentials; My question is that is there a way to authenticate to a user using WindowsIdentity ???
1
1054
by: Dave | last post by:
Hi, 1.) We have a central database of shared values that is maintained by an asp.net app. Only a few admins have access to the maintenance forms for this data which is secured by a simple web.config in forms folder for now. 2.) This application also exposes some webservices that allows client applications to consume the data that is maintained within it. How can I restrict which of our intranet applications consume the
1
5737
by: Eric | last post by:
I need to call a function in a WebService from a VC++ 7.1 project. The WebService requires NTLM authentication and should be the user of the calling program. How should this be done? I have found this article from Microsoft: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/handling_authentication.asp But it looks that it's very low-level. Even if I copy the code generated by the sproxy.exe program and...
7
10875
by: GD | last post by:
Hi, I am trying to call a webservice from a windows service application. It works only if I launch the windows service app from VS.Net 2005 (Worked around from Main()) or from a winform test application. However, it generates a kind of security error after I install and start the service in my Window Server machine. I believe that it is related to authentication. The following is the sample code: HttpWebRequest obj =...
2
3485
by: =?Utf-8?B?TGFycnlLdXBlcm1hbg==?= | last post by:
Our WebDev team seems to have found a problem that exposes a bug in .NET 2.0. This problem can be shown when trying to access a WebService using SSL and through a proxy server after using the HttpWebRequest object. Under normal circumstances I am able to use the webservice without any problems. But after using an HttpWebRequest object to make a call to a website all subsequent attempts to use the WebService will fail with a 401...
10
9778
by: Anton | last post by:
Hi, when accessing a secured 3rd party webservice i'm getting a 401 HTTP Statuscode (unauthorized). When entering the url in a browser and entering the username and password manually, the wsdl is returned. So the username and password should be ok. I'm using this code: Merchant myMerch = new Merchant(); myMerch.merchantIdentifier=merchantId;
2
2268
by: Mike Endys | last post by:
Hi all, have problem to use login to the web service. Im thinking about the web service that provides datas and files to the WinForm Client. I want the client log-in to the application... here is my not-working solution this is my web service, with the Forms authentication and working on AspSqlMembershipProvider and with Role provider implemented too. It is working well. I can create user, I can ValidateUser... But I would like, that...
0
9393
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10153
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9946
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8830
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6646
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5413
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3530
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2800
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.