Modules/SharePointDsc.ServiceAppSecurity/SPServiceAppSecurity.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Expand-AccessLevel
{
    [OutputType([System.String[]])]
    param(
        [Parameter()]
        $Security,

        [Parameter()]
        [System.String[]]
        $AccessLevels
    )

    $expandedAccessLevels = $AccessLevels

    foreach ($namedAccessRight in $Security.NamedAccessRights)
    {
        if ($AccessLevels -contains $namedAccessRight.Name)
        {
            foreach ($namedAccessRight2 in $Security.NamedAccessRights)
            {
                if ($expandedAccessLevels -notcontains $namedAccessRight2.Name -and
                    $namedAccessRight2.Rights.IsSubsetOf($namedAccessRight.Rights))
                {
                    $expandedAccessLevels += $namedAccessRight2.Name
                }
            }
        }
    }
    return $expandedAccessLevels
}