public override Task TicketReceived(TicketReceivedContext context)
{
var result = base.TicketReceived(context); var identity = context.Principal.Identity as ClaimsIdentity;
if (identity != null)
{
// Add the Name ClaimType. This is required if we want User.Identity.Name to actually return something!
if (!context.Principal.HasClaim(c => c.Type == ClaimTypes.Name) &&
identity.HasClaim(c => c.Type == "name"))
identity.AddClaim(new Claim(ClaimTypes.Name, identity.FindFirst("name").Value)); // Check if token names are stored in Properties
if (context.Properties.Items.ContainsKey(".TokenNames"))
{
// Token names a semicolon separated
string[] tokenNames = context.Properties.Items[".TokenNames"].Split(';'); // Add each token value as Claim
foreach (var tokenName in tokenNames)
{
// Tokens are stored in a Dictionary with the Key ".Token.<token name>"
string tokenValue = context.Properties.Items[$".Token.{tokenName}"];
identity.AddClaim(new Claim(tokenName, tokenValue));
}
}
}
return result;
}

oidc User.Identity.Name 为空解决方法的更多相关文章

  1. ORACLE里怎么能判断一个日期类型的字段是否为空,解决方法:is null

    ORACLE里怎么能判断一个日期类型的字段是否为空,解决方法:is null,解决方法:判断什么null都可以用is null.

  2. 【转】WebElement.getText()为空解决方法

    WebElement.getText()为空解决方法 当使用getText()获取一个普通的链接文本时: <a href="http://www.baidu.com"> ...

  3. MVC5 Controller构造方法获取User为空解决方法

    用如下方法获取UserId报空引用异常 public class BaseController : Controller { protected SiteContext db = new SiteCo ...

  4. mysqldump定时任务生成备份文件内容为空解决方法

    1问题:写好了一个mysqldump备份脚本(如图)直接执行可以正常生成备份文件,但在用crontab运行时却生成内容为空 2原因分析:由于mysqldump存在于全局环境变量mysql的bin下面, ...

  5. json解析出来数据为空解决方法

    从APP端或从其他页面post,get过来的数据一般因为数组形式.因为数组形式不易传输,所以一般都会转json后再发送.本以为发送方json_encode(),接收方json_decode(),就解决 ...

  6. selenium中WebElement.getText()为空解决方法

    当使用getText()获取一个普通的链接文本时: <a href="http://www.baidu.com">baidu</a> 如果得到的文本只为空, ...

  7. Centos 6.4 /usr/src/kernels 目录为空解决方法

    /usr/src/kernels 目录下是Linux的内核源码,如果其为空,则需要安装安装 kernel-headers 和 kernel-devel包

  8. MySQL data路径为空解决方法

    CMD x:\mysql\5.7.12\bin>mysqld --initialize-insecure --user=mysql

  9. session在本地可以正常使用,而在sae上却无法使用或者值为空的解决方法

    session在本地可以正常使用,而在sae上却无法使用或者值为空的解决方法: session_start()放在当前页代码的第一行即可解决该问题. 在本地上session_start()如果不是放在 ...

随机推荐

  1. ThinkPHP5.0完全开发手册 --技术文档

    1.ThinkPHP5.0完全开发手册.chm 链接:https://pan.baidu.com/s/1199wK6q6O9IyOf5RU_-Xow 提取码:hnek 2.ThinkPHP5.0完全开 ...

  2. 填写数独 洛谷P1784

    题目链接:https://www.luogu.org/problemnew/show/P1784 因为要求行列以及每9个数字组成的中格子都得有1-9这9个数,我们不妨建三个二维数组 第一维代表是第几个 ...

  3. CSS设置表格TD宽度布局

    使用表格布局时,对单元格的宽度控制很伤脑筋,所以查阅资料整理如下: 一.表格布局table-layout 语法: table-layout : auto | fixed 取值: auto  : 大多数 ...

  4. RabbitMQ环境安装及入门

    1. 说明 在企业应用系统领域,会面对不同系统之间的通信.集成与整合,尤其当面临异构系统时,这种分布式的调用与通信变得越发重要.其次,系统中一般会有很多对实时性要求不高的但是执行起来比较较耗时的地方, ...

  5. Docker部署Django项目+Nginx+Fluend日志收集 和redis、memcached、RabbitMQ、Celery

    前言 一.docker 1.docker是什么? Docker的英文本意是“搬运工”,Docker搬运的是集装箱(Container)可以成为容器,我可以把写的Django的WEB应用以及Python ...

  6. 公网IP被别人恶意解析的后果

    在网上看的一个案例,说是自己网站的IP被别的域名恶意解析了,恶意网站没有备案,IP地址为没有备案的域名提供了正常的网站服务,导致对应的IP也被封了. 检查方法:telnet xxx.me 80端口不通 ...

  7. 遇见 TiDB

    遇见 TiDB 文章来源:企鹅号 - 塔塔驿站 最近TiDB掀起了一波分布式数据库的热潮,公司也在着手准备TiDB的落地工作,前几天也参与了几场公司针对TiDB的分享会,下面我们了解一下关于TiDB. ...

  8. POST形式 soapUI调用WebService的restful接口,传入json参数,并且返回json

    第一次使用POST形式传JSON字符串,怎么都调不到后台方法,只是因为注解没加对…… CXF的WebService接口类 package com.zit.webservice.main; import ...

  9. Xcode10 library not found for -lstdc++ 找不到问题

    在Xcode9上正常编译的项目,在Xcode10上编译可能会遇到如下错误: library not found library not found library not found for -lst ...

  10. 输入、输出与Mad Libs游戏

    name1 = input('请输入一个名字:') name2 = input('再输入一个名字:') article = input('请输入一种物品:') print('{}掉进了{},{}去救她 ...