You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用正则替换将Azure AD Group Claim转换为小写

解决Azure AD Group Claim转全小写的问题

方法1:使用内置ToLower转换(推荐)

Azure AD提供了直接转换字符串为小写的内置声明转换,无需正则:

  • 进入应用注册的Token configuration页面,先配置好需要返回的groups声明。
  • 新增一个Claims transformation,选择ToLower作为转换类型,输入声明选择http://schemas.microsoft.com/ws/2008/06/identity/claims/groups,为转换后的声明命名(比如groupsLowercase)。
  • 在SAML配置的Attribute mappings中,将输出的groups属性值设置为刚才创建的groupsLowercase,即可将AD-Saml-Group转为ad-saml-group。

方法2:正则替换的正确写法

你之前使用的\L.*AD-.*\E是Perl风格的正则语法,Azure AD基于.NET正则引擎,不支持该写法,因此会直接输出标记文本。正确的正则配置如下:

  • 创建RegexReplace类型的Claims transformation:
    • 输入声明:http://schemas.microsoft.com/ws/2008/06/identity/claims/groups
    • 正则模式:^.*$(匹配整个组名称字符串)
    • 替换字符串:${0,lower}(将匹配到的整个内容转换为小写)

内容的提问来源于stack exchange,提问作者Abhishek Raj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 20:24:30