cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

Bug report: `ownerEntraM365GroupUserSetCommand.getOwners` overrides `userType`

Open MartinM85 opened this issue 1 year ago • 2 comments

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 userType set to null. If a user was created before 2014 when userType was introduced, the userType is 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

MartinM85 avatar Aug 09 '24 05:08 MartinM85

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

milanholemans avatar Aug 09 '24 23:08 milanholemans

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.

MartinM85 avatar Aug 11 '24 08:08 MartinM85

Fixed as part of different issue.

MartinM85 avatar Oct 27 '24 18:10 MartinM85