Security.CheckUserObjectPermission 方法
會檢查目前的使用者是否擁有單一指定的安全性類別權限的專案或資源的物件。
命名空間: WebSvcSecurity
組件: ProjectServerServices (在 ProjectServerServices.dll 中)
語法
'宣告
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CheckUserObjectPermission", 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 CheckUserObjectPermission ( _
objectUid As Guid, _
objectTypeUid As Guid, _
categoryPermissionUid As Guid _
) As Boolean
'用途
Dim instance As Security
Dim objectUid As Guid
Dim objectTypeUid As Guid
Dim categoryPermissionUid As Guid
Dim returnValue As Boolean
returnValue = instance.CheckUserObjectPermission(objectUid, _
objectTypeUid, categoryPermissionUid)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CheckUserObjectPermission", 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 CheckUserObjectPermission(
Guid objectUid,
Guid objectTypeUid,
Guid categoryPermissionUid
)
參數
objectUid
類型:System.Guid物件的 GUID。
objectTypeUid
類型:System.Guid物件類型的 GUID。
categoryPermissionUid
類型:System.Guid安全性類別權限的 GUID。
傳回值
類型:System.Boolean
True目前使用者有權限 ; 如果否則,請false。
備註
若要避免指定objectTypeUid,您可以使用CheckUserProjectPermission或CheckUserResourcePermission ,而不是CheckUserObjectPermission。
若要檢查多個物件權限,請使用CheckUserObjectPermissions、 CheckUserProjectPermissions或CheckUserResourcePermissions較佳的效能。檢查另一個資源的安全性權限時,需要使用模擬該資源身分登入。
objectTypeUid參數,請使用PSSecurityObjectType結構來取得 GUID Project或Resource物件類型。categoryPermissionUid參數,請使用PSSecurityCategoryPermission結構來取得 GUID 的其中一個預設類別權限,或使用ReadCategoryPermissions來取得 GUID 的自訂類別權限。
Project Server 權限
權限 |
描述 |
---|---|
可讓使用者登入 Project Server。通用權限。 |
範例
下列範例會檢查目前的使用者是否有特定資源的 「 指派資源 」 權限。如需其他資訊及完成的範例應用程式,請參閱 <使用安全性方法中的 PSI。
using System;
using System.Net;
using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
CookieContainer cookiecontainer = new CookieContainer();
SvcSecurity.Security security = new SvcSecurity.Security();
security.Url = "https://ServerName/ProjectServerName/_vti_bin/psi/security.asmx";
security.CookieContainer = cookiecontainer;
security.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Check whether the user has the "Assign Resource" permission for a resource.
// Set the GUID for an existing resource.
Guid resourceUid = new Guid("a1fcbf91-e91d-44e2-a4a7-3b4b698cb984");
Guid resourceType = PSLibrary.PSSecurityObjectType.Resource;
Guid categoryPermission = PSLibrary.PSSecurityCategoryPermission.AssignResource;
bool hasAssignResourcePermission =
security.CheckUserObjectPermission(resourceUid, resourceType, categoryPermission);
. . .