首页 > 解决方案 > ADFS 声明规则中的正则表达式负前瞻

问题描述

我需要向不匹配特定 LDAP 属性的每个人授予声明。我想使用带有负面展望的正则表达式来执行这个“not”子句

c1:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", Value =~ "^(?!Test User).*$"]
 => issue(Type = "http://goofyclaim", Value = "youre not a tester");

我的测试用户似乎并不满意上述规则。正则表达式有问题吗?还是 ADFS4.0 不支持它。我在 ADFS 事件日志中看不到任何错误。

这是 win2012r2 AD 域上的 win2016srv。

作为参考,这条规则确实有效:

c1:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", Value =~ "(?i)^Test User1"]  
 => issue(Type = "http://somethignelseentreily", Value = "imispellwhendriving");

标签: regexadfsadfs4.0

解决方案


首先我需要为 REGEXP_NOT_MATCH使用(在这里找到ADFS 规则语言终端)

!~

接下来,我必须通过在 ^ 标识符中不区分大小写来稍微重构正则表达式模式修饰符

c1:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", Value !~ "^(?i)Test User"]
 => issue(Type = "http://somethignelseentreily", Value = "imispellwhendriving");

推荐阅读