问题描述
如何在ADFS中将AD属性作为声明规则进行迭代?
更具体地说,我想检查用户的proxyAddresses是否包含预定的域,如果是,则将该电子邮件作为名称ID返回,否则返回用户的主要电子邮件。
解决方法
您将在声明规则上使用regex来检查域,如果存在,则发出NameID声明。
然后使用“ NOT EXISTS”规则。
类似这样:
NOT EXISTS([Type == "http://contoso.com/NAMID"])
=> add(Type = "http://contoso.com/hasNAMEID",Value = "No");
Sample Rule 2:
c1:[Type == "http://contoso.com/hasNameID"] &&
c2:[Type == "http://contoso.com/email"]
=> issue(Type="http://contoso.com/email",Value=c2.value);
使用常规的电子邮件声明类型等。
在撰写本文后大约10分钟,我发现了这个示例,它显示了more detail中的解决方案。
,我昨天玩了一段时间,最后得到了以下结果,这似乎可行,但也许不是最干净的方法?
规则1:
代理地址和用户主体名称的常规属性声明
规则2:
c:[Type == "fake/proxyAddresses",Value =~ "subdomain.example.com$"]
=> issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",Value = RegExReplace(c.Value,"smtp:",""));
规则3:
NOT EXISTS([Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"])
=> add(Type = "fake/UseUPN",Value = "Yes");
规则4:
c1:[Type == "fake/UseUPN"]
&& c2:[Type == "fake/UPN"]
=> issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",Value = c2.Value);