We have requirement to Give particular access to the USER using their email ID , on List item with REST call. We are clear with the steps to be followed. the only change we are seeing is with the endpoint addroleassignment. As per the documentation at MSDN , we have to pass PRINCIPALID and ROLEID.

We are ok with ROLEID. However, principalID is the userID.

Now there are ways to find this UserID using other endpoints (/SiteUser), we can pass email ID and get this Principal ID.


AFAIK the PrincipalID that we get through site user end point is generated only when that user actually visits the sharepoint site. So if there is an Organization with 50K employees, we will not see all these employees listed with their userID using /SiteUsers endpoint.

May I know, how do we give an access to the users on list item which never visited the site and hence will not have any userid .

MSDN documentation says its Int32, so what are my options (can the membership name work? i#[email protected] etc?)

please help.

Update 1:

My assumption that UserID gets generated only when the user actually visits was WRONG. behavior is, whenever we add a user to sharepoint site through Group, direct permissions etc. then UserID gets generated for that User. Being said that, original issue remains.

2 Answers 2


If the email id is the same as the login, you can use the EnsureUser method exposed from the Web object. To do so with REST, simply post to this endpoint:


That will add the user to the user information list if they do not already exist, and will return the user (including the id).

More about the method can be found here.

  • Thank you..we decided to add user to the Sharepoint Group so ID gets generated automatically..but your suggestion is cleaner way to do it
    – Rohit
    Commented May 10, 2017 at 12:29

I am on SharePoint online and every new user get access through the "All Users" group. I am able to get the user information whether they never login also. Here is the REST Api call I am using. We have only few employees and I know the users never logged in and working fine in my case.

siteurl/_api/web/siteusers(@v)?@v='i:0%23.f|membership|[email protected]'

And you can do above query using login name format i:0%23.f|membership|[email protected] it returns user id which can be used to grant permissions.

  • I get below message in browser for users who never visited..for users who have visited at some point I get the Id .. <m:error xmlns:m="schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <m:code>-2146232832, Microsoft.SharePoint.SPException</m:code> <m:message xml:lang="en-US">User cannot be found.</m:message> </m:error> .........
    – Rohit
    Commented May 9, 2017 at 13:32
  • I will create a new account and see I can get this error. Commented May 9, 2017 at 13:39
  • I am getting "User cannot be found" error in case of new account requires change password for the first time login. When I change the account password policy to "User cannot change password" I am able to get details even user not logged in. Commented May 9, 2017 at 15:31
  • I am sorry..i dont see that behavior and can confirm that its been same since sharepoint 2007. Site users will list only user from the website and not all users :)
    – Rohit
    Commented May 9, 2017 at 15:51
  • Yes. In on-premises we are seeing the site users after visit the site and in online we started seeing the users even though they never log in. This one we came to know in our recent POC. Our Online environment is integrated with organization AD. Commented May 9, 2017 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.