Share via


SPRoleAssignmentCollection.GetAssignmentByPrincipal Method

Gets the role assignment object based on the specified user or group.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
<ClientCallableExceptionConstraintAttribute(FixedId := "System.ArgumentException$0", ErrorType := GetType(ArgumentException),  _
    ErrorCode := , Condition := "The user or group does not exist in the collection at the given scope")> _
<ClientCallableMethodAttribute(Name := "GetByPrincipal", ReturnObjectIdentity := True)> _
<ClientCallableExceptionConstraintAttribute(FixedId := "System.UnauthorizedAccessException$-2147024891",  _
    ErrorType := GetType(UnauthorizedAccessException), Condition := "")> _
Public Function GetAssignmentByPrincipal ( _
    principalToFind As SPPrincipal _
) As SPRoleAssignment
'Usage
Dim instance As SPRoleAssignmentCollection
Dim principalToFind As SPPrincipal
Dim returnValue As SPRoleAssignment

returnValue = instance.GetAssignmentByPrincipal(principalToFind)
[ClientCallableExceptionConstraintAttribute(FixedId = "System.ArgumentException$0", ErrorType = typeof(ArgumentException), 
    ErrorCode = , Condition = "The user or group does not exist in the collection at the given scope")]
[ClientCallableMethodAttribute(Name = "GetByPrincipal", ReturnObjectIdentity = true)]
[ClientCallableExceptionConstraintAttribute(FixedId = "System.UnauthorizedAccessException$-2147024891", 
    ErrorType = typeof(UnauthorizedAccessException), Condition = "")]
public SPRoleAssignment GetAssignmentByPrincipal(
    SPPrincipal principalToFind
)

Parameters

Return Value

Type: Microsoft.SharePoint.SPRoleAssignment
The role assignment for the specified user or group.

Exceptions

Exception Condition
ArgumentNullException

principalToFind is null .

Remarks

This method retrieves the role assignment of the user or group specified by the principalToFind parameter.

See Also

Reference

SPRoleAssignmentCollection Class

SPRoleAssignmentCollection Members

Microsoft.SharePoint Namespace