Domanda

I am using UserProfilePropertiesForUser class to pull SharePoint profile properties of the user. However for some users, i am receiving user not found exception. I have just checked on the SharePoint site and can find the user even through check permissions.

Can someone please guide me what could be the possible root cause of this issue that i am getting user not found exception but the user can access the SPO site. I am also attaching the code and error screenshot for the reference.

var usr = context.Web.SiteUsers.GetByEmail("abc@constoo.com");
cxt.Load(usr); 
cxt.ExecuteQuery();

After the execute query call, i am getting the below exception. enter image description here Regards, Tayyab

È stato utile?

Soluzione

SiteUsers will return you the user if user as visited the SharePoint list at least once. This is because it looks into UserInformationList which is present in every site collecction. You can try Graph API instead .

import { graph } from '@pnp/graph';
import '@pnp/graph/users';

const getUser = await graph.users.getById('foo@contoso.com')();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top