# AdfsTest **Repository Path**: LzlDemo/AdfsTest ## Basic Information - **Project Name**: AdfsTest - **Description**: No description available - **Primary Language**: C# - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2018-09-22 - **Last Updated**: 2021-09-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ADFS Test #### 项目介绍 用于演示.NET怎么集成ADFS。 #### ADFS架构 https://blog.csdn.net/nista/article/details/49099921 !["ADFS_Flow"](ADFS_Flow.png "ADFS_Flow") #### 本机调试 1. 拉取项目代码 1. 打开项目解决方案,编译项目(可调整 .NET Framework版本) 1. 在本机IIS上默认站点配置https,在默认站点下创建应用程序AdfsTest 1. 将项目部署到AdfsTest下面 1. 在浏览器中访问 https://localhost/AdfsTest #### 说明 1. ADFS Server要求应用必须使用https,可以在IIS创建一个自签名证书来配置https 1. [Web.config](/AdfsLzlTest/Web.config)有2个配置 - ida:ADFSMetadata:ADFS Server元数据地址 - ida:Wtrealm:应用在ADFS Server注册时填写的URN 1. [Startup.Auth.cs](/AdfsLzlTest/App_Start/Startup.Auth.cs) 配置集成ADFS,请注意不同版本的ADFS,引用不同Microsoft.Owin.Security.WsFederation类库 1. 获取当前登录人邮箱 ``` public static string CurrentUserEmail { get { var email = ClaimsPrincipal.Current.FindFirst(ClaimTypes.Email); return email?.Value; } } ``` 1. 查看登录用户更多返回信息 https://localhost/AdfsTest/Home/About 1. 测试帐户testcommon@lizhanglong.com lzlCommon@925