SPWeb.AddApplicationPrincipal Method

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.

Namespace:  Microsoft.SharePoint
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


Type: System.String

The Active Directory logon name of the user.

Type: System.Boolean

true to allow the new application principal user to access information about the website users; otherwise, false.

Type: System.Boolean

true to require that the new application principal user has a request token; otherwise, false.

Return Value

Type: Microsoft.SharePoint.SPUser
The application principal user.


There is already a user on the website with the logon name logonName that is not an application principal.


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.