Skip to content

Different API versions required to access directory extension #3077

Open
@goldfinger3

Description

@goldfinger3

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_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions