0

在我的Azure Web App中,我想通过使用他们的ClaimsIdentity来模拟用户来调用第三方API。第三方Web API允许使用基本或Kerberos,如果需要,我可以选择切换到使用Windows集成安全性的第三方SDK。Azure Web App Web API模仿使用ClaimsIdentity的用户

我遇到的问题是模拟位,下面是我的代码,因为它是。

var webUser = HttpContext.Current.User.Identity as ClaimsIdentity; 

var windowsIdentity = S4UClient.UpnLogon(webUser.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Upn)).Value); 

using (var impersonationContext = windowsIdentity.Impersonate()) 
{ 
    //make call to 3rd party Web API or SDK 
} 

当运行上面我得到以下错误:

The pipe endpoint 'net.pipe://localhost/s4u/022694f3-9fbd-422b-b4b2-312e25dae2a2' could not be found on your local machine. 

一切我读过点启动C2WTS Windows服务,有没有开始为Azure的web应用程序这种服务方式?如果不是,我该如何去冒充用户或将凭据传递给我的第三方api/sdk?

回答

1

当您使用Azure WebApp时,您与基础架构和主机环境隔离 - 因此您无法启动类似“Windows服务”的内容。

如果您需要为单个用户使用Windows/Kerberos身份验证来访问Web应用程序后面的资源,则无法使用Azure WebApp。您应该将Azure VM与IIS一起使用,该IIS是您的域的成员服务器。然后,您可以将Web应用程序配置为接受基于声明的身份验证(例如来自Azure AD),并通过UPN和WindwosIdentity构造函数(> .NET 4.5)模拟您的内部域帐户。

+0

这可以在云服务Web角色中完成吗? – Alan