Nathan McNulty Profile picture
Jul 16, 2021 20 tweets 13 min read Read on X
It's finally time to learn about Groups in Azure AD :)

Groups are foundational components for granting access to resources, email delivery, and even assigning licenses within Azure AD.

But first, you need users, so if you haven't yet, go create some :)

In Azure AD, we have a few different types of groups

The main group types are security and Microsoft 365 groups, but in Exchange we also have distribution lists which are mail enabled groups with no security context

Each group also has an assigned and dynamic membership type
Now, before we start creating groups, I need to warn you that Microsoft stupidly believes any user should be able to create groups, both security and M365 types

What you should know is that they can select any email address they want 😱

Let's start here: portal.azure.com/#blade/Microso…
You have 2 options:

1) Prevent users from creating groups - IT wants to be the bottleneck ;)

2) Create a naming policy, and optionally pester group owners to "renew" groups. If they don't, groups are automatically cleaned up.

docs.microsoft.com/en-us/microsof…

docs.microsoft.com/en-us/microsof…
With that out of the way, let's create some groups!

portal.azure.com/#blade/Microso…

Click "New group" and start with the simplest form - security groups using assigned membership

This is the traditional method you'd see in on-prem AD and will be most common/familiar to AD based ogs
Groups with "assigned" membership can now be granted a role in Azure AD, so I'm going to do that too

This also lets us use PIM to add users to the group allowing us to have different settings/approval workflows for different groups.

Very cool stuff:
docs.microsoft.com/en-us/azure/ac…
Next, security groups with dynamic membership

You'll quickly see how important it is to populate user attributes as that is the key to building these groups

While Azure AD doesn't come close to the flexibility of an IAM, this could be totally sufficient for many orgs
Microsoft 365 Groups are a weird beast

They create a ton of backend resources and are heavily used by Yammer and Teams

Overview
docs.microsoft.com/en-us/microsof…

These have an email address, so ensure your naming convention prevents abuse

You can recover them if an owner fails to renew
If you want, create an M365 group with dynamic membership for practice :)

Before we move to Powershell modules, let's look at Audit logs and group based licensing

Audit logs:
portal.azure.com/#blade/Microso…

Group based licensing takes planning but worth it:
docs.microsoft.com/en-us/azure/ac…
Ran out of time tonight, but on the plus side, got to snuggle a baby for an hour.

I'll finish this up tomorrow, but I did just push some of the Powershell code for creating groups.

Will push Get, Modify, and Delete tomorrow once I comment it all :)

github.com/nathanmcnulty/…
Time for some Powershell :)

If you haven't installed the modules, check out this repo and section of my previous thread:


Also a reminder, I love questions and try to respond to everyone I can. Please ask away :D
Let's create a group with the Az module

Authenticate:
Connect-AzAccount

Then create:
New-AzADGroup -DisplayName "Test Group 1" -MailNickname "TestGroup1"

There aren't many properties available when creating a group with these modules. Let's look at the others :)
Next, let's create a group with the AzureADPreview module

Authenticate:
Connect-AzureAD

Create:
New-AzureADGroup -DisplayName "Test Group 2" -MailEnabled $false -MailNickname "TestGroup2" -SecurityEnabled $true

-MailEnabled $true doesn't work yet, still not many options here
Finally, let's do the MSOnline module

Authenticate:
Connect-MsolService

Create:
New-MsolGroup -DisplayName "Test Group 3" -Description "Test Group 3"

So none had very many property options :-/

Let's see if we can change membership and properties with a Set/Update
The Az module does not appear to have a Set/Update cmdlet.. :(

At least it does have an add group member option:

Add-AzADGroupMember -MemberUserPrincipalName "tuser1@getsecurer.onmicrosoft.com" -TargetGroupDisplayName "Test Group 1" -Verbose

No output on this without -Verbsose
Hurray! The Azure AD module has cmdlets to deal with group membership, ownership, and attributes for both assigned and even dynamic groups!

Commands are too long for Twitter, so be sure to check the repo here:
github.com/nathanmcnulty/…
The MSOnline modules are disappointing (as usual)

Note that some of these cmdlets require ObjectId, so we have to do (Get-Group).ObjectId to get it.

Set-MsolGroup -ObjectId (Get-MsolGroup -SearchString "Test Group 3").ObjectId -DisplayName "Test Group 3 - Modified" -Verbose
OK, so let's use the "Get-" cmdlets to see if our changes went through :)

One of the neat discoveries I had going through this was the -AzureADMSGroup cmdlets can work with dynamic group properties

It's been around a while, but the documentation isn't really even there :P
And finally, we'll delete all the test groups with the "Delete-" cmdlets

Rather than type them all out here, you can check them out in the repo:
github.com/nathanmcnulty/…

Hopefully this gives you some ideas on how to build automation around groups in Azure AD :D
No Exchange yet, so no lists for now

Already have content for adding a custom domain to AAD, setting up the mail records, and for installing Azure AD Connect in Express mode

Plan to do properly delegated AAD Connect with ADFS, then migrate to PHS

Other suggestions welcome! :)

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Nathan McNulty

Nathan McNulty Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @NathanMcNulty

Jan 25
Hello for Business works great with AD integrated apps (Kerberos/NTLM), but it requires setting up a trust model

Very poorly generalized, Hello uses certificates that AD doesn't understand, so we need a way to request a Kerberos ticket with the certs

This is crazy easy now 🧵
Before I share how easy it is now, I want to share why people still hate Hello because its history was way more complicated

Originally we had certificate trust which required full PKI deploying certificates to all of your devices and AD

Doing this properly was really hard...
So with Server 2016, Microsoft introduced a massive improvement - key trust

This meant we only needed to put certificates on domain controllers

This was so much easier, but it still required PKI and setting up the templates

And a hybrid model was added to support Azure AD... Image
Read 6 tweets
Jan 24
I think the most common misunderstanding of Conditional Access is its relationship to authentication, and this results in not understanding how the rest of the controls actually work

Conditional Access performs authorization by evaluating tokens from the authentication service
This provides important insights 💡

CA policies cannot block anything until AFTER authentication occurs

This means CA cannot help with password spray/credential stuffing. This is why we have Password Protection and Smart Lockout.

learn.microsoft.com/en-us/entra/id…
learn.microsoft.com/en-us/entra/id…
This also means an attacker blocked by a CA policy either has a valid username/password or has a stolen token

When we don't understand this, we don't monitor and respond, and we give attackers more time with valid credentials

Identity Protection helps here, but it isn't perfect
Read 7 tweets
Jan 20
You likely aren't collecting all available events to the Unified Audit Log

First, not all events are enabled or retained optimally. Consider creating this policy in the Purview portal (leave users and record types blank to collect everything).

Retention is based on license... Image
This policy only applies to users with the Microsoft 365 Advanced Audit SKU assigned, audit records are retained for 1 year. Audit records for users without this SKU are retained for 180 days (thanks CISA for the bump up from 90 days!)

Second, this still doesn't get everything..
Next we have to enable all the records for mailbox auditing

But wait, Microsoft totally pinky promises that you don't need to manage these records because they enable them for you



It would be nice if they actually enabled everything, but they don't :-/ learn.microsoft.com/en-us/purview/…Image
Read 6 tweets
Sep 6, 2024
A common ask I get often is:

I want to require fresh strong authenticaton from a compliant device (or specific devices) when someone activates a role via PIM

So let's walk through that scenario really quick

If anything is unclear, just try harder!

I'm kidding, ask away 😜
First, if the built-in phishing resistant auth strength works for you, use it

If not, we can customize exactly what we want (avoid requiring one not allowed in another poilcy)

We can even define AAGUIDs to specify exact models of keys that must be used

learn.microsoft.com/en-us/entra/id…
Image
Second, we need to create an authentication context

This is like a label used to tie PIM activation to a specific Conditional Access policy. The name can be changed any time 😉


In our access token, this is the 'acr' value
learn.microsoft.com/en-us/entra/id…
learn.microsoft.com/en-us/entra/id…Image
Image
Read 5 tweets
Aug 8, 2024
In this thread, I will provide Graph PowerShell commands to find synced users with admin privileges

Microsoft has been very vocal about not granting privileges to synced accounts for about 4 years now

Read this post by @Alex_T_Weinert:


Then check below techcommunity.microsoft.com/t5/microsoft-e…
@Alex_T_Weinert For those with PIM, these two scopes will help us get what we need (remove the /'s):

Connect-MgGraph -Scopes 'RoleAssignmentSchedule./Read.Directory','RoleEligibilitySchedule./Read.Directory'

If you don't use PIM, I believe you only need: RoleManagement./Read.Directory
First, we can get a list of all synced users who have an active assignment:

# Get active assignments
Get-MgBetaRoleManagementDirectoryRoleAssignmentSchedule -ExpandProperty RoleDefinition,Principal,DirectoryScope -All | ForEach-Object {
if ($_.Principal.AdditionalProperties."@odata.type" -match '.user' -and $_.Principal.AdditionalProperties.onPremisesSyncEnabled -eq $true) {
Write-Output "$($_.RoleDefinition.DisplayName),$($_.Principal.AdditionalProperties.userPrincipalName)"
}
if ($_.Principal.AdditionalProperties."@odata.type" -match '.group') {
$roleName = $_.RoleDefinition.DisplayName
$members = (Get-MgGroupMember -GroupId $_.PrincipalId).AdditionalProperties.userPrincipalName
if ($members.Count -ne 0) { $members | ForEach-Object { Write-Output "$roleName,$_" }}
}
#if ($_.Principal.AdditionalProperties."@odata.type" -match '.servicePrincipal') {
#    Write-Output "$($_.RoleDefinition.DisplayName),$($_.Principal.AdditionalProperties.appId)"
#}
}
Read 6 tweets
Jul 31, 2024
How non-privileged users can make themselves admin of your SaaS apps - a short story :)

Let's say your company uses Salesforce and has configured SAML for SSO with your Identity Provider

Salesforce's SAML implementation lets us pass identity and roles (permissions) on the token
So we create a security group named "Salesforce Admins" and add our admins to the group

Then we configure the claims rule in our Identity Provider to send the role value of System Administrator for members of a group with the display name of "Salesforce Admin" 🚩
Unfortunately, display names are almost never unique, so anyone that can create or modify a group to match the display name can now add admins by adding them to this group

In Entra, ANYONE can create a group by default or owners of groups can modify them, no admin roles needed Image
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(