使用此代码,您可以检查WCF服务中的当前安全上下文.
如果用户已通过身份验证,并且WindowsPrincipal不为null,那么您使用的是Windows安全模型 - 您可以访问所有相关信息:
ServiceSecurityContext current = ServiceSecurityContext.Current;
if (!current.IsAnonymous && current.WindowsIdentity != null)
{
string userName = current.WindowsIdentity.Name;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1555 次 |
| 最近记录: |