Incarnation of WCF

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;
                ........

                //get the data as a string.
                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.

+3
source share
2 answers

, anon, MattK .

.

WCF

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class TransferFile : ITransferFile

web.config

   <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled ="true" />

0

"" ; "" , .

, -, "TokenImpersonationLevel" :

http://www.devx.com/codemag/Article/33342/1763/page/4

+1

Source: https://habr.com/ru/post/1717823/


All Articles