Bug report: `ownerEntraM365GroupUserSetCommand.getOwners` overrides `userType`
Priority
(Low) Something is a little off
Description
EntraM365GroupUserSetCommand.getOwners() returns list of Graph API users, but it overrides the userType property and sets it to Owner with a note (at least 5 years old note)
// Currently there is a bug in the Microsoft Graph that returns Owners as // userType 'member'. We therefore update all returned user as owner
userType is a property that indicates whether the user is a member or guest in the tenant. It's not related to owners/members of a group.
We shouldn't override userType and use this property later for check if the user is member/owner.
There are two side effects:
- if you want to promote a guest user (who is a member) to a owner of a group, it will never work
if (args.options.role === "Owner") {
const foundMember: User | undefined = users.find(e => args.options.userName.toUpperCase() === e.userPrincipalName!.toUpperCase() && e.userType === 'Member');
e.userType will be Guest
- some users have
userTypeset to null. If a user was created before 2014 whenuserTypewas introduced, theuserTypeis not set, so promoting such a user from a member to a owner of a group will never work.
Steps to reproduce
Check EntraM365GroupUserSetCommand.getOwners()
Expected results
userType is not overridden
Actual results
userType is overridden
Diagnostics
No response
CLI for Microsoft 365 version
v8
nodejs version
v20.8.1
Operating system (environment)
Windows
Shell
PowerShell
cli doctor
No response
Additional Info
Same probably in TeamsUserListCommand.getOwners
Hi @MartinM85, could catch, that something we shouldn't definitely do. Since it's not part of the output, it's not a breaking change. Are you willing to fix this?
Same probably in TeamsUserListCommand.getOwners
That's taken care of in #5558
Based on the comment https://github.com/pnp/cli-microsoft365/issues/5558#issuecomment-1758543559 It should be fixed in #6132. Anyway, it would be better to wait until #6132 is merged. I will take this ticket later if needed., not now.
Fixed as part of different issue.