Share via


Security.CreateGroups method

Creates one or more security groups.

Namespace:  WebSvcSecurity
Assembly:  ProjectServerServices (in ProjectServerServices.dll)

Syntax

'Declaration
<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 _
)
'Usage
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
)

Parameters

Remarks

The groups parameter must contain at least one SecurityGroupsDataSet.SecurityGroupsRow in the SecurityGroups table that defines a new group. The SecurityGroupsDataTable can contain multiple SecurityGroupsRow objects. Project Server validates each SecurityGroupsRow for the following:

  • Unique group name and GUID

  • Existence of group users (if any)

There are five DataTable objects in a SecurityGroupsDataSet. Only the SecurityGroupsDataTable must contain data. The data tables are in order, as follows:

  1. SecurityGroups   Each row specifies the category GUID, name, and description. Only the GUID and name (WSEC_CAT_UID and WSEC_CAT_NAME) are required to create a security category.

  2. SecurityPrincipleCategoryRelations   Optional. Each row specifies the group GUID and the primary security category GUID. For the primarycategories, see the PSSecurityCategory structure.

  3. CategoryPermissions   Optional. Each row specifies the group GUID and category permission GUID, and sets Allow or Deny for the permission. For information about the category permissions, see the PSSecurityCategoryPermission structure.

  4. GlobalPermissions   Optional. Each row specifies the group GUID and global permission GUID, and sets Allow or Deny for the permission. For information about the global permissions, see the PSSecurityGlobalPermission structure.

  5. GroupMembers   Optional. Each row specifies the group GUID and the resource GUID.

For examples of valid groups, click a group on the Manage Groups page in Project Web App, to see the fields and settings on the Add or Edit Group page.

Project Server Permissions

Permission

Description

ManageUsersAndGroups

Allows a user to manage Project Server users and groups. Global permission.

Examples

The following example creates a security group, adds a resource to the group, and adds a global permission set to Allow for the group.

For additional information and a complete sample application that creates one security category with a group, see Using Security Methods in the 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);

. . .

See also

Reference

Security class

Security members

WebSvcSecurity namespace