自定义声明规则

时间:2020-11-12 08:24:26

标签: adfs claims

我是ADFS声明规则的新手,并在自定义规则中苦苦挣扎。

我想要做的是基于组名过滤组,然后将匹配的组作为SID返回。我也想同时返回UPN,电子邮件,姓氏,GivenName和WindowsAccountName,但过滤后的组最为重要。

我尝试过但没有成功:

c:[Type == "http://schemas.xmlsoap.org/claims/Group", Value =~ "(?i).+(Test|Test2).+"]
=> issue(Type = "https://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid");

有人可以帮助我制定此规则或为我指明正确的方向吗?如果您打扰的话,我也希望对此规则进行解释。

2 个答案:

答案 0 :(得分:0)

您首先需要一个规则来创建组。

因此,在向导中,设置LDAP规则。

在LHS上,选择“令牌组->不合格名称”。

在RHS上,选择“ http://schemas.xmlsoap.org/claims/Group”。

您现在可以在其中运行正则表达式。

c:[类型==“ http://schemas.xmlsoap.org/claims/Group”,值=〜“(?i)。+(Test | Test2)。+”] =>问题(类型=“ https://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid”,Value = c.value);

规则说的是,获取所有类型为“ http://schemas.xmlsoap.org/claims/Group”的声明,运行正则表达式,如果为true,则创建具有Group声明值的groupsid声明。 >

请注意,如果有多个与正则表达式匹配的组,您将获得多个groupid类型的声明。

此外,请在此处查找reference

答案 1 :(得分:0)

这给了我想要的用户参数,根据名称过滤组,并以不合格的名称和SID返回组

获取群组:

if let url = Bundle.main.url(forResource: "Filename", withExtension: "json") {
        do {
            let data = try Data(contentsOf: url)
            let array = try! JSONDecoder().decode(YourModel.self, from: data)
            // deal with it.
        } catch {
            print("error",error)
        }
    }

过滤和发布组:

c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"]
 => add(store = "Active Directory", types = ("http://schemas.xmlsoap.org/claims/Group"), query = ";tokenGroups;{0}", param = c.Value);

发布用户参数:

c1:[Type == "http://schemas.xmlsoap.org/claims/Group", Value =~ "INSERT-REGEX-HERE"]
 && c2:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"]
 => issue(store = "Active Directory", types = ("https://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid", "http://schemas.xmlsoap.org/claims/Group"), query = "(&(name={0}));objectSid,name;{1}", param = c1.Value, param = c2.Value);