pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
417 stars 644 forks source link

Parameter in username makes Teams provisioning fail #2277

Open StevenC365 opened 5 years ago

StevenC365 commented 5 years ago

Category

[X] Bug [ ] Enhancement

Environment

[X] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013

Expected or Desired Behavior

Being able to use a parameter in the name of a user bring added to the security in teams. This was needed to add new users created to a Team as part of a Hackathon session environment.

Observed Behavior

No errors, just nothing at all is provisioned

Steps to Reproduce

ghost commented 5 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

mmsharepoint commented 4 years ago

Can confirm that issue with PnP-PowerShell Version 3.15.1911.0 Also full user replacement does not work:

First line is working, second is not but usage of Parameter really makes sense here I think.

conncampbell commented 4 years ago

when tracing is enabled (or using fiddler) the error is: "Failed to get user by upn information." The graph query from fiddler shows the parameter token is not replaced: GET https://graph.microsoft.com/v1.0/users/%7Bparameter%3ATeamOwner%7D?$select=id. The problem is in the ObjectTeams.cs class where the owners are translated into IDs. The string is not parsed by the tokenizer.

var userIdsByUPN = team.Security.Owners .Select(o => o.UserPrincipalName) .Concat(team.Security.Members.Select(m => m.UserPrincipalName)) .Distinct(StringComparer.OrdinalIgnoreCase) .ToDictionary(k => k, k => { var jsonUser = HttpHelper.MakeGetRequestForString($"{GraphHelper.MicrosoftGraphBaseURI}v1.0/users/{Uri.EscapeDataString(k.Replace("'", "''"))}?$select=id", accessToken); return JToken.Parse(jsonUser).Value("id"); });

ejazhussain commented 4 years ago

Just wondering if there is any update about this issue? I can confirm that I am also getting same issue when provisioning Teams.