Security.CreateGroups Method

Creates one or more security groups.

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

Syntax

'Declaration
<SoapDocumentMethodAttribute("http://schemas.microsoft.com/office/project/server/webservices/Security/CreateGroups", RequestNamespace := "http://schemas.microsoft.com/office/project/server/webservices/Security/",  _
    ResponseNamespace := "http://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("http://schemas.microsoft.com/office/project/server/webservices/Security/CreateGroups", RequestNamespace = "http://schemas.microsoft.com/office/project/server/webservices/Security/", 
    ResponseNamespace = "http://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 the 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 principal security category GUID. For the principal categories, 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 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 the global permissions, see the PSSecurityGlobalPermission structure.

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

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

Project Server Permissions

Permission

Description

ManageUsersAndGroups

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();
SecurityWebSvc.Security security = new SecurityWebSvc.Security();
security.Url = "http://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.
SecurityWebSvc.SecurityGroupsDataSet groupDs =
   new SecurityWebSvc.SecurityGroupsDataSet();
SecurityWebSvc.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.
SecurityWebSvc.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
SecurityWebSvc.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