Partager via


Security.CheckUserResourcePermission Method

Checks whether the current user has the specified security category permission for a specified resource.

Namespace:  [Security Web service]
Service reference: http://ServerName:32843/[Project Service Application GUID]/PSI/Security.svc
Web service reference: http://ServerName/ProjectServerName/_vti_bin/PSI/Security.asmx?wsdl

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CheckUserResourcePermission", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Security/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Security/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function CheckUserResourcePermission ( _
    resourceUid As Guid, _
    categoryPermissionUid As Guid _
) As Boolean
'Usage
Dim instance As Security
Dim resourceUid As Guid
Dim categoryPermissionUid As Guid
Dim returnValue As Boolean

returnValue = instance.CheckUserResourcePermission(resourceUid, _
    categoryPermissionUid)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CheckUserResourcePermission", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Security/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Security/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public bool CheckUserResourcePermission(
    Guid resourceUid,
    Guid categoryPermissionUid
)

Parameters

  • resourceUid
    Type: System.Guid
    The GUID of the resource.
  • categoryPermissionUid
    Type: System.Guid
    The GUID of the category permission.

Return Value

Type: System.Boolean
true if the current user has the category permission for the resource; otherwise, false.

Remarks

CheckUserResourcePermission wraps a call to CheckUserObjectPermission. To check multiple category permissions for a resource, use CheckUserResourcePermissions for better performance. Checking a category permission for another user on a resource requires using impersonation to log on as that user.

For the categoryPermissionUid parameter, use the PSSecurityCategoryPermission structure to get the GUID for one of the default category permissions, or use ReadCategoryPermissions to get the GUID for a custom category permission.

Project Server Permissions

Permission

Description

LogOn

Allows a user to log on to Project Server. Global permission.

Examples

The following example checks whether the current user has the "Create Surrogate Timesheet" permission for an existing resource. For additional information and a complete sample application, see Using Security Methods in the PSI.

using System;
using System.Net;
using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
CookieContainer cookiecontainer = new CookieContainer();
SecurityWebSvc.Security security = new SecurityWebSvc.Security();
security.Url = "https://ServerName/ProjectServerName/_vti_bin/psi/security.asmx";
security.CookieContainer = cookiecontainer;
security.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Set the GUID for an existing resource.
Guid resourceUid = new Guid("a1fcbf91-e91d-44e2-a4a7-3b4b698cb984");
Guid categoryPermission = PSLibrary.PSSecurityCategoryPermission.CreateSurrogateTimesheet;

bool hasSurrogateTimesheetPermission = 
   security.CheckUserResourcePermission(resourceUid,  categoryPermission);
. . .

See Also

Reference

Security Class

Security Members

Security Web Service

Other Resources

Using Security Methods in the PSI

Walkthrough: Creating and Using Custom Project Server Permissions