IIS 7 C# web service should log into intranet - c#

I try to run a web service which gets a list of pages and then should try to print this pages as pdf sites.
The problem is now, that the service has to authenticate. Because the HTTP server which hosts the pages is inside an intranet zone.
The service runs on an IIS7 and is written in C#.
Thanks for helping.
-lony

Hopefully this should help;
PRB: "Access Denied" Error Message When You Call a Web Service While Anonymous Authentication Is Turned Off
Update:
Sorry misunderstood your question, would you not use the HTTP Authorization header to do this? Something like;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("url");
request.Credentials = new NetworkCredential("username", "Password");

Related

AzureAd authentication always uses local ip address of server as redirect_url

I'm currently having a issue with AzureAd authentification on a remote server when using the public URL like https://mysoftware.mydomain.net.
I've added AzureAd authentication with the following lines:
services.AddMicrosoftWebAppAuthentication(Configuration, "AzureAd")
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { GraphApiScopes.ScopeUserRead })
.AddInMemoryTokenCaches();
As long as I'm running the software with URL https://localhost:5001 then authentification works well, and the callback is https://localhost:5001/signin-oidc
If I am now accessing the software using https://mysoftware.mydomain.net the redirect to https://login.microsoft.com works well, but the callback will then to https://local-ip-of-my-server/signin-oidc.
To be honest I absolutely don't understand why its sending the local ipaddress of the server as redirect_uri query param to the authentification service from Microsoft.
Of course I will now get a error message from Azure telling, that the reply URL doens't match the configured reply URL as my configuration is made for https://mysoftware.mydomain.net/siginin-oidc and https://localhost:5001/singin-oidc.
If I'm now adding https://local-ip-of-my-server/singin-oidc as redirect url in the App registration the redirect back to this IP works well but of course on the calling computer the local ip of my server is not accessible.
Hopefully it was understandable and someone is able to help me with that problem.
Greetings,
Luca
Problem is solved...
It had nothing todo with .NET-Core.. The firewall didn't include the original header when forwarding the request to my server.
The option was called "pass-through host header".
Greetings,
Luca

Central Authentication Service (CAS) and HttpWebRequest - Authentication

I'm using HttpWebRequest to get data from websites. Currently I want to get data from website, which is secured by CAS system. I'm sending and receving headers via HttpWebRequest (C#) and all is ok. Unfortunately when I want to get certain pages, then I got message "Automatically logged out.". I checked headers in LiveHttpHeaders (Firefox Add-On), and all my headers in my C# app and in Firefox are the same.
Example (headers from Firefox):
https://www.example.com/balance/ > Moved temporarily to:
https://www.example.com/cas/login?service=https%3A%2F%2Fwww.example.com%3A443%2Fbalance%2Fj_spring_cas_security_check
In web browser all is working. In C# app nope.

Response time from HTTPS and HTTP web services

I have an application in WPF which is using Java web service. Users can search some documents via application. Two days ago they(who have created the web service) told me that I must change url of the service. So, I did it. But after that the application began to get datas slower than previous. To tell the truth, i am making about 12 request to the web service in one searching. But it was getting all datas in approximately 0.52 second with the previuos web service which was using HTTPS. But the current web service is using HTTP and it takes about 8 seconds to get all datas. And in my opinion the problem might be protocol. But actually, processing time in HTTP must be greater than HTTPS.
So, what could be a problem?
Also, i am connecting to web service with that code:
HQRTXServiceWSService service = new HQRTXServiceWSService();
service.Url = " a url of the web service";
service.Credentials = new System.Net.NetworkCredential("user", "password");
service.PreAuthenticate = true;
Maybe the webservice implementation has been updated and they messed up with their performance?
It could also be their infrastructure, or if there are more people using their webservice... Could be many things but your code ;)
I don't think that HTTP should be slower than HTTPS, usually, it's the contrary, because there's a small overhead for encryption on HTTPS.

Passing credentials from ASP.NET C# to another web service

I have a one page ASP.NET 4.0 C# script running. In debug mode my script works just fine but when I publish it, it seems like it is not sending the credentials when making the WebRequest.
The following is the code I am using, I have tried a bunch of things but I keep getting a 401 Unauthorized when I am using my published version of the script. BTW I am using IIS 7
WebRequest fwRequest = HttpWebRequest.Create(fwURL);
fwRequest.UseDefaultCredentials = true;
//fwRequest.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)fwRequest.GetResponse();
While debugging, your project use your credentials, but when you publish it it will use the credentials of ASP.NET user, or the credentials set in IIS configuration.
So no, you can not pass credentials of your client to another web service/appliaction unless you convince him/her to pass username-password to your application (Except that both web apps are on the same machine).

401 when POSTing using HttpWebRequest (yes I used Credentials)

I'm using HttpWebRequest to pull down XML, and POST data back to a 'WebService' and getting a 401 on the POST.
When creating the requests I've added Credentials and now tried a credentials cache and setting PreAutenticate to True, still getting the 401! :(
Watching the HTTP traffic on the router I set the get make an unauthenticated GET request.. it hits the 401 and then makes an authenticated GET and is allowed through. When I watch the POST I see it hit the 401... and it doesn't even try an authenticated POST.
This appears only on mobile phones (compact-framework 3.5 and 2.0 on WinMobile 6.1). The same .exe works perfectly on any desktop machines.
What am I missing? Please help!
Try setting the header manually:
http://devproj20.blogspot.com/2008/02/assigning-basic-authorization-http.html

Categories