views:

1416

answers:

2

Hope someone can help!

I am calling a WCF service using JSON but I am not able to get the user credentials out.
We are using Kerberos so IIS is setup as the following:

Server-side tasks:

  1. IIS server is member of domain
  2. Set IIS server computer account in AD Users & Computers MMC as "Trusted for Delegation"
  3. IIS Server must be rebooted for this policy to take effect.
  4. Integrated Windows Authentication only must be selected for site / virtual directory
  5. IIS must not have NTLM only set as authentication method (this is usually not a problem, NEGOTIATE is default, so unless you specifically ran a script to change this, don't worry about it).
  6. IIS server name either must match exactly account name in AD, or SetSPN tool should be used in cases where IIS site is set as alternative name (e.g. server is called server01.domain.com, and website is called www.application.com).

Client-side tasks

  1. Client must be using IE 5.x+. If client is running IE 6, ensure that "Enable Integrated Windows Authentication (requires restart)" is selected from Tools > Internet Options > Advanced.
  2. Web site MUST be recognized as Local Intranet (not Internet Zone) site to client. I have not seen any documentation explaining why, but I just have never been able to get it to work otherwise. If necessary, specifically add this to Local Intranet sites list.
  3. Client account must not be marked as "Sensitive, Do not Delegate" in AD Users and Computers MMC.

Everything works nicely when using wsHTTPBinding. However to get JSON working i am having to use WebHttpBinding. I then need to get the user credentials out so i can use impersonation to talk to the backend services.

My binding in the WFC config is as below: I used http://underground.infovark.com/2008/03/21/wcf-webhttp-binding-and-authentication/ to help < binding name="AjaxBinding"> transport clientCredentialType="Ntlm" />

            <endpoint name="DataJson" address="Datajson" binding="webHttpBinding" bindingConfiguration="AjaxBinding" behaviorConfiguration="jsonbehaviour" contract="MyContract"/>

-->

It is calling the WCF service successfully but I am unable to get anything from: HttpContext.Current.User.Identity OR ServiceSecurityContext.Current.WindowsIdentity

other than anonymous so i am unable to do:

WindowsIdentity identity = (WindowsIdentity)HttpContext.Current.User.Identity();

using (identity.Impersonate())

{

// ... code to call application B goes here ...

}

I have tried adding this into the web config incase of multiple identities that i read about:

              <deny users="?"/>

Any ideas anyone?

A: 

Hi

  • Do you have this section in your config?

    <system.web>
    <identity impersonate="true"/>
    
  • Under what account is your application pool running? (Network Service right?)

  • You dont perhaps have duplicate SPN's on the domain?

These are the only things that I have on my "list" of things to check when doind integrated authentication, that you did not explicitly mention in your question. Hope it helps?

Rihan Meij
Rihan,Thanks for quick responce:)I have tried <identity impersonate="true"/>. It doesnt seem to make any difference if it is in there or not.The application pool is configured to use a Domain account, not NetworkService.Im sure there are not duplicate SPN's.
As a note though we do have anonymous access enabled in IIS. It seems if i turn that off in IIS it starts to work. but as soon as the wcf service recyles the wcf service says Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. I believe this is due to our other endpoints that use wsHttpAuthentication.
Do you have Connection tiemout set on your website? I once ran accross a issue where the Enable HTTP Keep-Alives was not set, and it just did not want to work, after setting the HTTP Keep-Alives it worked. It sounds like you have tried everything, that is normally when I consider the following KB http://support.microsoft.com/kb/215383 Is there any usefull info in your iss log's?
Rihan Meij
With anonymous access enabled in IIS, you can never get the callers credentials as this overrides Integrated Security and all other security settings (Digest etc...).
Bigtoe
And what happens if you apply NTFS security on the files that the website access, and do not provide the user that your app pool is running under, access to those files, but you do provide access to Authenticated Users?
Rihan Meij
I have found this: http://blogs.msdn.com/drnick/archive/2007/03/23/preventing-anonymous-access.aspxSo I have placed an ssl cert on server and am trying with Transport authentication with anonymous access enabled. Not got anywhere with it yet though. From what i can tell its still picking up anonymous.I will look at connection timeout.
A: 

Have you tried? does that give same problem?

OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name

Tanner