views:

28

answers:

2

I have successfully created a WCF service using the webHttpBinding with no authentication or security. I can call my function over and over and it returns the value as expected.

Now I created a custom IAuthorizationPolicy, UserNamePasswordValidator and IPrincipal. I went back to wsHttpBinding (default) and did a normal service reference in code and set the ClientCredentials.UserName.UserName and ClientCredentials.UserName.Password appropriately and the service works perfectly fine. I modified the Username to be wrong just to ensure the code was firing and sure enough it failed.

So, I put the binding back to webHttpBinding, but now I cannot figure out how to set those credentials via jQuery. I have tried setting the "Authorization" header to a base64 encoded string using the following http://stackoverflow.com/questions/1002179/how-can-i-pass-windows-authentication-to-webservice-using-jquery. No matter what i do i always get the error "No custom principal is specified in the authorization context".

Anyone have info on how to properly call a WCF REST service that is using a Custom Principal?

A: 
var html = $.ajax({
  url: "some.jsp",
  username: "sdsdsdsdsd",
  passsword: "xxxxxxxx"
 }).responseText;

have tried just passing in the username and password

http://api.jquery.com/jQuery.ajax/

Aaron Saunders
No still get the same error. Apparently, WCF requires some kind of extra headers set or something along those lines that contains the information needed for a principal.
+1  A: 

I was tryng to do something that is not possible. I have to use the standard HTTP Authentication method because I am working with a REST webservice and not a wsHttpBinding webservice which has alot more wrapped around it. I found my answer here:

http://www.leastprivilege.com/FinallyUsernamesOverTransportAuthenticationInWCF.aspx