简体   繁体   中英

How to call an asmx service which needs authorization from WCF in .NET 3.5

How can I call an asmx service which needs windows identity authorization from WCF in .NET 3.5? We are limited to .NET 3.5 framework. I have the credentials, but not sure how to implement this in C# code.

There is an example of authentication at http://msdn.microsoft.com/en-us/library/ff406125 In this url this is done as follows:

public decimal ReportSales()
{
    var currentUser = new WindowsPrincipal((WindowsIdentity)
    System.Threading.Thread.CurrentPrincipal.Identity);
    if (currentUser.IsInRole(WindowsBuiltInRole.BackupOperator))
    {
        return 10000M;
    }
    else
    {
       return -1M;
    }
 }

There are also alternative methods with compiler attributes described in http://haacked.com/archive/2011/10/19/implementing-an-authorization-attribute-for-wcf-web-api.aspx

For later versions of .net WIF would be the way to go.

I hope this helps...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM