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结构Project或Resource对象类型获取 GUID。对于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);
. . .