Partilhar via


SPRoleDefinitionCollection.GetByType Method

Returns the role definition of the specified type from the collection.

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

Syntax

'Declaration
<ClientCallableMethodAttribute(CacheReturnValue := True, ReturnObjectIdentity := True)> _
<ClientCallableExceptionConstraintAttribute(FixedId := "0", ErrorType := GetType(ArgumentException),  _
    Condition := "Specified role type is None or no role with this type was found in the collection.")> _
Public Function GetByType ( _
    roleType As SPRoleType _
) As SPRoleDefinition
'Usage
Dim instance As SPRoleDefinitionCollection
Dim roleType As SPRoleType
Dim returnValue As SPRoleDefinition

returnValue = instance.GetByType(roleType)
[ClientCallableMethodAttribute(CacheReturnValue = true, ReturnObjectIdentity = true)]
[ClientCallableExceptionConstraintAttribute(FixedId = "0", ErrorType = typeof(ArgumentException), 
    Condition = "Specified role type is None or no role with this type was found in the collection.")]
public SPRoleDefinition GetByType(
    SPRoleType roleType
)

Parameters

Return Value

Type: Microsoft.SharePoint.SPRoleDefinition
An SPRoleDefinition object that represents the role definition.

Exceptions

Exception Condition
ArgumentException

Either SPRoleType.None was passed as an argument or a definition with the specified role type was not found.

Remarks

A role definition collection can contain only one role definition for each SPRoleType.

See Also

Reference

SPRoleDefinitionCollection Class

SPRoleDefinitionCollection Members

Microsoft.SharePoint Namespace