microsoftgraph / microsoftgraph/msgraph-sdk-powershell
Different API versions required to access directory extension
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 898
- Forks
- 230
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 31
Description
Describe the bug
You need the beta API version access for users but not for groups to receive data from Directory Extension.
Setting of the extension will work with V1 API version.
In my opinion, this is inconsistent and a bug.
Expected behavior
With the V1 API we should get the directory schema extension attributes of users like the group ones.
How to reproduce
Import-Module Microsoft.Graph.Authentication, Microsoft.Graph.DirectoryObjects, Microsoft.Graph.Applications
# The problem library
Import-Module Microsoft.Graph.Users
Import Microsoft.Graph.Beta.Users, Microsoft.Graph.Beta.DirectoryObjects
Import-Module Microsoft.Graph.Groups
# Works
# Replace
$myAppName = 'MyTenantDirectorySchemaApp'
# Get the partial name which is same as the Application AppID without hypen
$AppIDSchemaPartName = ((Get-MgApplication -Filter "DisplayName eq '$myAppName'").AppID).Replace("-","")
# Replace
$userID = "00000000-0000-0000-0000-000000000000"
# Change Numbers
$BodyParam = @{
"extension_$($AppIDSchemaPartName)_myNumber" = 42
}
Update-MgUser -UserId $UserID -BodyParameter $BodyParam
#######################
# I M P O R T A N T #
# switch to beta API #
# Bug or Feature? #
#######################
# Get show all extentsions
(Get-MgBetaUser -UserId $userID).AdditionalProperties
# Get directory attribute
(Get-MgBetaUser -UserId $userID).AdditionalProperties."extension_$($AppIDSchemaPartName)_myNumber"
(Get-MgBetaDirectoryObject -DirectoryObjectId $userID).AdditionalProperties."extension_$($AppIDSchemaPartName)_myNumber"
(Invoke-MgGraphRequest -Method GET "https://graph.microsoft.com/beta/users/$userID/extension_$($AppIDSchemaPartName)_myNumber").Value
# N O T W O R K I N G !!!
(Get-MgUser -UserId $userID).AdditionalProperties#
(Get-MgUser -UserId $userID).AdditionalProperties."extension_$($AppIDSchemaPartName)_myNumber"
(Get-MgDirectoryObject -DirectoryObjectId $userID).AdditionalProperties."extension_$($AppIDSchemaPartName)_myNumber"
(Invoke-MgGraphRequest -Method GET "https://graph.microsoft.com/v1.0/users/$userID/extension_$($AppIDSchemaPartName)_myNumber").Value
# Same for groups
#replace
$groupID = "00000000-0000-0000-0000-000000000000"
# Change Number
$BodyParam = @{
"extension_$($AppIDSchemaPartName)_myNumber" = 42
}
Update-MgGroup -GroupId $GroupID -BodyParameter $BodyParam
# Works w i t h o u t Beta API !
(get-MgGroup -GroupId $groupid).AdditionalProperties
(get-MgGroup -GroupId $groupid).AdditionalProperties."extension_$($AppIDSchemaPartName)_myNumber"
(Get-MgDirectoryObject -DirectoryObjectId $groupID).AdditionalProperties."extension_$($AppIDSchemaPartName)_myNumber"
(Invoke-MgGraphRequest -Method GET "https://graph.microsoft.com/v1.0/groups/$groupID/extension_$($AppIDSchemaPartName)_myNumber").Value
SDK Version
2.25.0 Microsoft.Graph.Users
Latest version known to work for scenario above?
No response
Known Workarounds
Using Microsoft.Graph.Beta.Users but this is no productive solution.
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the discrepancy with Microsoft.Graph.Users, Microsoft.Graph.Beta.Users, Microsoft.Graph.DirectoryObjects, and Microsoft.Graph.Groups using the v1.0 and beta commands shown. Compare the users and groups responses and request results; done means determining whether v1.0 user directory extension attributes can match group behavior or documenting the confirmed limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100