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)

Syntax

'Declaration
Public Function AddApplicationPrincipal ( _
    logonName As String, _
    allowBrowseUserInfo As Boolean, _
    requireRequestToken As Boolean _
) As SPUser
'Usage
Dim instance As SPWeb
Dim logonName As String
Dim allowBrowseUserInfo As Boolean
Dim requireRequestToken As Boolean
Dim returnValue As SPUser

returnValue = instance.AddApplicationPrincipal(logonName, _
    allowBrowseUserInfo, requireRequestToken)
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.

Return value

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

Exceptions

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.

Remarks

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.

See also

Reference

SPWeb class

SPWeb members

Microsoft.SharePoint namespace