【问题标题】:PnP — Add a claim value to a SP Group using PnP powershellPnP - 使用 PnP powershell 将声明值添加到 SP 组
【发布时间】:2019-04-25 17:02:08
【问题描述】:

我希望找到一个可以使用 PnP PowerShell 将特定自定义声明值添加到 SP 组的示例。基本上使用 PnP PowerShell 完成以下操作

$ClaimValue = $_.ClaimValue
if ($_.ClaimType -eq $ClaimTypeSchema.GroupSID)
{
  $objUserAccount = New-Object System.Security.Principal.NTAccount($EnvUserDomain, $_.ClaimValue)
  $objUserSID = $null
  Write-Output ("Generating Security Identifier for account: '" + $_.ClaimValue + "' ...")
  $objUserSID = $objUserAccount.Translate([System.Security.Principal.SecurityIdentifier])
  if ($objUserSID -eq $null)
  {
    continue
  }
  $ClaimValue = $objUserSID.Value
}
Write-Output ("   Adding Claim: '" + $_.ClaimType + "' with Value: '" + $ClaimValue + "' ...")
$Claim = New-SPClaimsPrincipal -ClaimType $_.ClaimType -ClaimValue $ClaimValue -TrustedIdentityTokenIssuer $AuthenticationProvider
$SPUserClaim = New-SPUser -UserAlias $Claim.ToEncodedString() -Web $RootWeb.Url
$SecurityGroup.AddUser($SPUserClaim)}
Write-Output "Completed"

【问题讨论】:

    标签: powershell sharepoint csom spfx sharepoint-2016


    【解决方案1】:

    看起来我可以使用下面的方法硬编码预期的格式

    i:0ǵ.t|custom-adfs|First.Last
    

    有关更多编码,请参阅下面的文章 https://social.technet.microsoft.com/wiki/contents/articles/13921.sharepoint-20102013-claims-encoding.aspx

    我仍然认为在 PnP 中有一个等价物会很好。

    $Claim = New-SPClaimsPrincipal -ClaimType $_.ClaimType -ClaimValue $ClaimValue -TrustedIdentityTokenIssuer $AuthenticationProvider
    

    $SPUserClaim = New-SPUser -UserAlias $Claim.ToEncodedString() -Web $RootWeb.Url

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-02
      • 2022-11-10
      • 2023-02-16
      • 1970-01-01
      • 2021-12-12
      • 2019-04-29
      • 2018-09-09
      相关资源
      最近更新 更多