I have a WCF service hosted in IIS, which I claim to impersonate as an annon account.
in my webconfig
<authentication mode="Windows"/>
<identity impersonate ="true"/>
Testing the next, with vs2008
public void ByRuleId(int ruleId)
{
try
{
string user = WindowsIdentity.GetCurrent().Name;
string name = Thread.CurrentPrincipal.Identity.Name;
........
using (FileStream fs = File.Open(location, FileMode.Open))
using (StreamReader reader = new StreamReader(fs))
{
rawData = reader.ReadToEnd();
}
}
catch.....
}
it works. however, if I add an impersonation attribute
[OperationBehavior(Impersonation=ImpersonationOption.Required)]
public void ByRuleId(int ruleId)
this does not work with error message
"Either the required impersonation level has not been provided, or the provided impersonation level is invalid."
Making a little joke, I noticed that the first path was authenticated by Kerboros, and the second method just did not pass the authentication type
I use the WCF client tool to transfer my credentials. it seems to work.
source
share