Security.CreateGroups 方法
會建立一或多個安全性群組。
命名空間: WebSvcSecurity
組件: ProjectServerServices (在 ProjectServerServices.dll 中)
語法
'宣告
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CreateGroups", 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 Sub CreateGroups ( _
groups As SecurityGroupsDataSet _
)
'用途
Dim instance As Security
Dim groups As SecurityGroupsDataSet
instance.CreateGroups(groups)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CreateGroups", 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 void CreateGroups(
SecurityGroupsDataSet groups
)
參數
groups
類型:WebSvcSecurity.SecurityGroupsDataSet會包含一或多個安全性群組的相關資訊。
備註
groups參數必須包含至少一個SecurityGroupsDataSet.SecurityGroupsRowSecurityGroups表定義新的群組。SecurityGroupsDataTable可以包含多個SecurityGroupsRow物件。Project Server 驗證下列每個SecurityGroupsRow :
唯一的群組名稱和 GUID
群組使用者 (如果有的話) 存在
SecurityGroupsDataSet有五個DataTable物件。僅限SecurityGroupsDataTable必須包含的資料。資料表格的順序,,如下所示:
SecurityGroups每個資料列會指定類別的 GUID、 名稱和描述。只有 GUID 和名稱 (WSEC_CAT_UID 和 WSEC_CAT_NAME),才能建立安全性類別。
SecurityPrincipleCategoryRelations選用的。每個資料列會指定群組 GUID 和主要的安全性類別的 GUID。如 primarycategories,請參閱 < PSSecurityCategory結構。
CategoryPermissions選用的。每個資料列會指定的群組 GUID 和類別權限的 GUID,並設定Allow或Deny權限。如需類別權限的資訊,請參閱 < PSSecurityCategoryPermission結構。
GlobalPermissions選用的。每個資料列會指定的群組 GUID 和通用權限的 GUID,並設定Allow或Deny權限。如需通用權限的資訊,請參閱 < PSSecurityGlobalPermission結構。
GroupMembers選用的。每個資料列會指定群組 GUID 和資源的 GUID。
如需有效的群組的範例,按一下 [群組Project Web App,在 [管理群組] 頁面上,請參閱 < 欄位並設定 [新增或編輯群組] 頁面。
Project Server 權限
權限 |
描述 |
---|---|
可讓使用者管理 Project Server 使用者和群組。通用權限。 |
範例
下面範例會建立安全性群組、 將資源新增至群組,並將設為Allow群組] 通用權限。
如需其他資訊及完成的範例應用程式,建立一個安全性類別與群組,請參閱 <使用安全性方法中的 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;
. . .
// Create a GUID for the new group.
Guid groupGuid = Guid.NewGuid();
// Specify basic group information.
SvcSecurity.SecurityGroupsDataSet groupDs =
new SvcSecurity.SecurityGroupsDataSet();
SvcSecurity.SecurityGroupsDataSet.SecurityGroupsRow groupRow =
groupDs.SecurityGroups.NewSecurityGroupsRow();
groupRow.WSEC_GRP_NAME = "SDK Test Group";
groupRow.WSEC_GRP_UID = groupGuid;
groupRow.WSEC_GRP_DESC = "This is the SDK Test Group.";
groupDs.SecurityGroups.AddSecurityGroupsRow(groupRow);
// Set the GUID for an existing resource.
Guid resourceUid = new Guid("a1fcbf91-e91d-44e2-a4a7-3b4b698cb984");
// Add the resource to the new group.
SvcSecurity.SecurityGroupsDataSet.GroupMembersRow groupMembersRow =
groupDs.GroupMembers.NewGroupMembersRow();
groupMembersRow.WSEC_GRP_UID = groupGuid;
groupMembersRow.RES_UID = resourceUid;
groupDs.GroupMembers.AddGroupMembersRow(groupMembersRow);
// Specify a global permission for the group.
SvcSecurity.SecurityGroupsDataSet.GlobalPermissionsRow globalPermRow =
groupDs.GlobalPermissions.NewGlobalPermissionsRow();
globalPermRow.WSEC_GRP_UID = groupGuid;
// Add a permission that applies to the group.
// For example, add the "About Microsoft Office Project Server" permission.
globalPermRow.WSEC_FEA_ACT_UID =
PSLibrary.PSSecurityGlobalPermission.AboutMicrosoftOfficeProjectServer;
globalPermRow.WSEC_ALLOW = true;
groupDs.GlobalPermissions.AddGlobalPermissionsRow(globalPermRow);
// Now that all the rows are added to the relevant tables,
// create the group.
security.CreateGroups(groupDs);
. . .