SP.Web.ensureUser Method (sp.js)

Checks whether the specified login name belongs to a valid user in the site. If the user doesn't exist, adds the user to the site.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

SP.Web.ensureUser()

Parameters

  • logonName
    Type: String

    The login name of the user.

Return value

Type: SP.User

The user with the specified login name.

Remarks

This method does not add a user with the specified login name to the website if that user is already on the website.

REST resource endpoint

See Web resource for more information.

Endpoint URI structure

http://<sitecollection>/<site>/_api/web/ensureUser(logonName)

HTTP requests

This resource supports the following HTTP commands:

  • POST

POST syntax

POST http://<sitecollection>/<site>/_api/web/ensureUser(logonName)

Resource parameters

  • logonName