Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different API versions required to access directory extension #3077

Open
goldfinger3 opened this issue Jan 20, 2025 · 0 comments
Open

Different API versions required to access directory extension #3077

goldfinger3 opened this issue Jan 20, 2025 · 0 comments
Labels

Comments

@goldfinger3
Copy link

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_
@goldfinger3 goldfinger3 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jan 20, 2025
@timayabi2020 timayabi2020 added Status: Needs Investigation and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants