WCF / ASMX :: Custom Basic Authentication With WCF REST / Getting Error "401 - Unauthorized"
Mar 30, 2010
I want to implement a custom authentication in my application using the basic authentication schema. I've configured it in the Web.config and enabled the basic authentication in the IIS, but when I try to open the service in the browser... appears a login dialog... what do I have to put ther? Besides, I want to control the authentication, I mean, I want to check whom is allowed in my custom list... where is it looking now?
When I use the WebRequest class, I'm getting a "401 - Unauthorized":
req = WebRequest.Create("http://localhost/RESTfulService/Service1.svc/Test");
req.Credentials = CredentialCache.DefaultNetworkCredentials;
WebResponse res = req.GetResponse();
What do I have to do for implement a custom basic authentication? (I cannot use membership providers).
I've set up in the Web.config:
[code]....
View 1 Replies
Similar Messages:
Oct 15, 2010
I'm using a WCF with windows authentication.
I also use custom binding:
[Code]....
While trying to access the service without specifing the user credentials everything work's ok and the current user(Thread.CurrentPrincipal.Identity.Name) at service is the logged in user.
When I try to set user credentials this way:
[Code]....
The service just ignores them.
When I try it this way:
[Code]....
I'm getting this error: "The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'."
View 1 Replies
Sep 30, 2010
i call my project web service, previously there was no pre-authetication. Now i didn't work web service. My code is as follows:
[Code]....
View 5 Replies
Aug 25, 2010
I have an XML web service where the authentication used is BASIC WINDOWS. Following is my client code to connect to the service.
[Code]....
Now, the issue is that the client is really authenticated only in the first attempt(First time I execute the code in VS). Further attempts succeed even if the code to assign credentials is commented or even after providing wrong user id/ password. I ensured that the server is hit each time(Just to make it clear that it not just because of client side caching).Is this the behavior of Basic authentication/credential cache. I would prefer the client be authenticated each time he hits the server.
View 2 Replies
Jul 19, 2010
I'm looking to implement my own basic webforms authentication. I don't want to use the 'membership' features in this case because I don't want to modify the database schema with all the membership elements that I won't use, and I don't need to support users across multiple applications. I want to wind up with one simple 'users' table that has username, password, passwordSalt, and several other fields to support custom user attributes specific to this application.
I was looking at this:
http://www.xoc.net/works/tips/forms-authentication.asp
but it's rather dated... is this still valid? I'm looking for guidance on what I need to do to implement a custom webforms auth solution. A very basic skeleton I can expand upon, or a good tutorial/guide that illustrates the necessary parts... just the basics..
View 5 Replies
May 3, 2010
We have Novell's Access Manager protecting our site. After the user logs in, Access Manager forwards the request back to a web page. On that web page, I need to read a combination of some Basic Auth username information as well as some custom header variablest that AM is passing to the web page. AM will continue to send these variables/values on every page as long as the user stays logged in.
What I'd like to do is create a class that checks for these values to evaluate whether the user is logged in or not. How do I gain access to those variables from a .cs class file?
View 3 Replies
Sep 2, 2010
I have looked at nearly every single WCF Rest PUT/POST issues on SO here and have still been unable to determine why I am unable to PUT or POST to my web service but am able to call a test GetTime method via GET. This particular service exchanges custom credential information (username, password and some other information) for a token. This token information is encrypted and added to the header of subsequent requests to other web services so that username/passwords don't have to be passed around everywhere. All web service calls are still treated as stateless, but require this auth header information rather username/passwords to access secured service operations.
[Code]....
I have also checked in IIS 7 the handler mappings for *.svc and checked that 'all verbs' are enabled.
View 1 Replies
Jun 18, 2010
I am trying to consume a webservice. I added the web reference. But when i try to access the method, I am getting the error as:"The request failed with HTTP status 401: Unauthorized."The web service has username as "user1", password as "pass".I tried this:
Service1.TestPrcsService serv = new Service1.TestPrcsService();
serv.PreAuthenticate = true;
serv.Custom_methodname(true);
How to pass the username and password to access the method?
View 2 Replies
Sep 15, 2010
I am using Kerberos as the Authentication mode for a WCF Client to interact with an ASMX Web Service. I am using customBinding in the WCF Client. I am getting the below mentioned Fault Exception when I invoke the HelloWorld Method by creating a Proxy using SVCUTIL.
`System.Web.Services.Protocols.SoapHeaderException: Server unavailable, please try later ---> System.ApplicationException: WSE841: An error occured processing an outgoing fault response. ---> System.Web.Services.Protocols.SoapException:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: WSE914: This instance of derived key token does not support encryption, decryption, or key wrapping. It can only be used to sign or verify signature. Please make sure that the length of the derived key matches the length of the key required by the symmetric encryption algorithm configured for the derived key token manager.
at Microsoft.Web.Services3.Security.Tokens.DerivedKeyToken.Psha1SymmetricKeyAlgorithm.get_EncryptionFormatter()
at Microsoft.Web.Services3.Security.EncryptedData.ResolveDecryptionKey(String algorithmUri, KeyInfo keyInfo)
at Microsoft.Web.Services3.Security.EncryptedData.Decrypt(XmlElement encryptedElement)
I am badly struck with this exception and unable to progress further.
View 2 Replies
Feb 18, 2011
how to implement WCF username authentication with a custom validator in both client side and server side. I am trying this since last 2 days. but no result.
View 7 Replies
Jul 14, 2010
This could be very straight forward for some of you, but I got caught up. I am doing very simple test - browsing from IIS Manager to see the default page or "under Construction", however I am being challenged to provide my login credential . When I provide my login credential, I am able to see the default page. I wanted to see the default page without providing my credential since Enable anoymous access + basic authentication I am simply wanted to see the default page asit is working on other servers except this one. I have included screen print to make sure may question is clear.
View 3 Replies
Jan 4, 2011
What's the difference between Basic Authentication and Integrated Windows Authentication in IIS?
View 3 Replies
May 1, 2015
I'm trying to connected to a third-party server, that allows API access via XML post/response. I've created just a very simple test page with a button to press.... the button should just go to the URL, log in with basic authentication and then return the response. if I use a browser and go to the URL, I see the XML response. Usuing my app, I'm still getting 401 unauthorized. I've been at this for hours, I've searched the forums and googled extensively, still no luck. Also, this is an internal app to internal server so security is not the highest priority. I'm setting the UN and PWD for authentication in a simple form.
Here's my VB code behind:
Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
Dim result As String
'disables self-signed SSL cert errors
[Code] ....
And the username and password are 100% accurate - as I mentioned above the code (well, implied).
I feel like this SHOULD be pretty easy: Overall request for testing: Submit a web request to a URL, disable the SSL check (self-signed certs used), login with basic UN and PWD I supply, return the response to a textbox.
View 1 Replies
Sep 23, 2010
tried so many different things but havent got past this seemingly trivial problem. I created a WCF service application from visual studio 2010 WCF templates. it generated the IService.cs and Service1.svc files and generated the web.config
i created a website in IIS 7 on windows 2008, and pointed it to the app folder. when i go to [URL] via web browser, i get a message indicating service is running and suggests using svcutil etc etc., but when i go to [URL] the web browser says 400 bad request. this is without changing anything from what VS generated. the operation contract looks like
[Code]....
Update: forgot to mention i even tried decorating the operation with WebGet attribute with UriTemplate parameter, without luck.
View 4 Replies
Mar 16, 2011
I am trying to call webservice from my web application. The web application had integrated windows authentication. I've written custome principal class to do authorization. But when I give call to my web service with default credentials it gives me 'the request failed with http status 401 unauthorized.' error.
When I give call to my local webservice it is running fine (It also has integrated windows authentication) But when I add reference of same web service from QA server I am getting this error. Not sure what is happening. I also tried
WS.PreAuthenticate = false;
WS.Credentials = System.Net.CredentialCache.DefaultCredentials;
View 2 Replies
Oct 5, 2010
I am a REST web service newbie, does visual studio, .NET, or some other nifty microsoft tool provide any easy way to auto generate classes to consume a REST web service? With REST services is there even a service definition like there is with SOAP (WSDL) beyond the printed documentation? There is a new service that I'd like to consume but they only wrote wrappers for PHP, Pearl, Ruby, and Java and have more or less said you are on your own with .NET. I could write it myself but I'd like to cut corners and save time wherever possible.
View 1 Replies
Jan 18, 2011
can Pass object in Rest Service Uri
View 1 Replies
Oct 26, 2010
[Code]....
this method i can access using asp.net but not by using a android.. i have checked for the headers etc.. the response is OK in android while debugging but the data is not inserted..
what is the equivalent of stringbuilder in android??
in android i use
StringEntity se = new StringEntity(json.toString());
//and post the data to my service...
post.setEntity(se);
what is the equivalent of stringentity in C# and what can i do for this prob?
View 2 Replies
Oct 1, 2010
My code below
BtnClick
YahooSample();
public void YahooSample()
{
HttpWebRequest request = WebRequest.Create("http://developer.yahoo.com/yui/") as HttpWebRequest;
[Code]....
View 1 Replies
Mar 30, 2010
How may I post arbitrary data to a REST WCF webservice? I mean, wihout use contracts.
Because my data is dynamic and I cannot have contracts, I want to get ride of the serialization overhead.
How should I declare my service and method?
View 1 Replies
Apr 12, 2010
Is it possible to create REST based web service using asmx?
View 1 Replies
Sep 15, 2010
this question should be fairly basic. I want to control the flow of an ASP.NET page -- if a certain condition is met, I want to write out an error message and stop drawing the page. However, I also want ASP.NET to output correct HTML (i.e. not cut off in the middle). Right now I am doing this:
if (condition != what-i-want) {
Label_Error.Text = "Sorry, you messed up";
return;
}
And the problem with that snippet is that ASP.NET draws the rest of the defined page without cutting off after the error. I really don't want to make the whole page Visible = False and then undo it when someone is authenticated. Is there some good way to do this? I have tried Response.End() but that doesn't output clean HTML (or anything actually, since I'm checking in Page_Load). I've had similar experiences with Response.Close(), et al.
View 1 Replies
Feb 9, 2011
In my asp.net MVC 3 web application, I want to implement basic authentication system in my webapp. I have been searching and reading for past two days but still not able to get a hold of it.
I was following [URL]
I created a CustomMembershipProvider class in my models
[Code]....
In my webconfig file, I do have [Code]....
Now, I created a AccountController, in that I added following code
[Code]....
After that I added view fo Logon
[Code]....
Now, the first problem which I am facing is, when I Debug the webapplication, I get HTTP404 error. Url generated
[URL]
But when I try to open
[URL]
View 7 Replies
Oct 12, 2010
I have an Intranet which is on IIS 7.0. I want to authenticate my users and know who is logged in. What options do I have to set in IIS Authentication part that my users do not need to type their user name and password to login to Intranet. I have set the Authentication to Basic and Impersonation, but it is asking user name and password.
View 3 Replies
Aug 23, 2010
I need to create an application (ASP.NET or WinForms or Windows Service, not sure) that needs to make a call to a url including username and password for basic authentication and have the url return a csv file. I then need to use the csv file in the application. I don't know how to do this. How do I call the url in my app. There can be no user interaction, it needs to be completely automated in the returning of the csv file.
View 2 Replies