【问题标题】:I need to assign users to an Azure Active Directory Group if they are members of multiple groups. Is this possible?如果用户是多个组的成员,我需要将用户分配到 Azure Active Directory 组。这可能吗?
【发布时间】:2022-11-11 12:49:59
【问题描述】:

我有 A 组、B 组和 C 组。如果成员同时是 B 组和 C 组中的任何组的成员,我只想允许他们进入 A 组

例如,用户 Joe Blow 是组 B 的成员,也是组集合 C 中的第三个组。他将被允许进入组 A。

这可能吗?

编辑: 这个问题的答案是肯定的,理论上是有可能的。它应该通过动态组来处理。

Dynamic membership rules for groups in Azure Active Directory

但是,对于此用例,它似乎无法正常工作。 此查询应该有效:

user.memberof -any (group.objectId -in ["GroupC-1Id", "GroupC-2Id"]) -and user.memberof -any (group.objectId -in ["GroupBId"])

但仅是 Group C-1 成员的用户仍会进入 Group A

此查询对其他人有效:

user.memberof any (group.objectId in ["GroupBId"]) and (user.memberof any (group.objectId eq ["GroupC-1Id"]) or user.memberof any (group.objectId eq ["GroupC-2Id"])) 

但对我来说,它会导致仅是 B 组成员的用户仍然进入 A 组。

【问题讨论】:

  • 您能否通过 GUI 或尝试的任何 PowerShell 命令执行步骤?
  • @kavyaSaraboju 到目前为止,我已经用我的研究更新了这个问题。

标签: azure azure-active-directory azure-security


【解决方案1】:

我试图在我的PowerShell环境中重现:

以下是需要检查的组。

Group 1:

Group 2:

Group 3:

我已经尝试过使用的场景powershell,当用户属于组 1 并且还属于组 2 和组 3 中的任何一个时,用户被添加到 Group-Anew

$AllUsers=Get-AzureADUser

#Add-AzureADGroupMember -ObjectId "<groupOb>" -RefObjectId "<userOb>"


$Newgroup=New-AzureADGroup -Description "TsInfoGroupNew group is for TsInfo" -DisplayName "Group-ANew" -MailEnabled $false -SecurityEnabled $true -MailNickName "TsInfoGroupNew"

$GroupAObjectId= $Newgroup.ObjectId

foreach($user in $AllUsers)
{
$userGroupMembership=Get-AzureADUserMembership  -ObjectId $user.ObjectId | select displayname, description , ObjectId

$userGroupMembership

if($userGroupMembership.DisplayName -eq "group1" –and ($userGroupMembership.DisplayName -eq "group2" -or $userGroupMembership.DisplayName -eq "group3" ) )
{
$allowUsers=$user.ObjectId
#below command adds the allowed users to group Group-ANew
Add-AzureADGroupMember -ObjectId $GroupAObjectId -RefObjectId $user.ObjectId

}

}

用户根据需要在执行命令后按预期方式添加。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-26
    • 1970-01-01
    相关资源
    最近更新 更多