SPWeb.AddApplicationPrincipal Method
SharePoint 2010
Adds a user to the website as an application principal; that is, a user object that is delegated to act on behalf of an external application.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
public SPUser AddApplicationPrincipal( string logonName, bool allowBrowseUserInfo, bool requireRequestToken )
Parameters
- logonName
- Type: System.String
The Active Directory logon name of the user.
- allowBrowseUserInfo
- Type: System.Boolean
true to allow the new application principal user to access information about the website users; otherwise, false.
- requireRequestToken
- Type: System.Boolean
true to require that the new application principal user has a request token; otherwise, false.
| Exception | Condition |
|---|---|
| SPException |
There is already a user on the website with the logon name logonName that is not an application principal. |
| ArgumentOutOfRangeException |
No user with the specified logon name could be found in the Active Directory. |
This method can only run in the user context of a site collection administrator or in a call to RunWithElevatedPrivileges(SPSecurity.CodeToRunElevated).
When this method is called, the user must already exist in Active Directory, but must not exist as a user of the website with permissions, unless they are already an application principal.