SPWeb.EnsureUser Method
Checks whether the specified logon name belongs to a valid user of the website, and if the logon name does not already exist, adds it to the website.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Parameters
- logonName
- Type: System.String
The logon name (Domain\User_Alias) of the user.
| Exception | Condition |
|---|---|
| SPException |
The user with the specified logonName cannot be found in Active Directory. |
The current user must have the BrowseUserInfo rights to view the users of the website.
Error Thrown
Make sure that any login name you pass in actually exists in one of your authentication providers. If not you'll see an SPException thrown with the message "The specified user {0} could not be found.". Where {0} is the name of your user.
- 4/18/2011
- Mark Zacharias
