Kashif Nizam Qureshi

Adding user to Project Server Group Programmatically

Use the following code to add user to Project Server Group Programmatically.


SvcSecurity.SecurityClient securityClient = new SvcSecurity.SecurityClient("basicHttp_QU_Security");
 ///securityClient.ClientCredentials=  CredentialCache.DefaultCredentials;

Guid securityGroupGuid = new Guid(System.Configuration.ConfigurationManager.AppSettings["ProjectManagerGroupGuid"]);
 Guid resourceGuid = new Guid("58199201-315c-4251-87ea-67b4ce80bcc5"); //Kashif

using (SvcSecurity.SecurityGroupsDataSet groupDs = securityClient.ReadGroup(securityGroupGuid))
{
    SvcSecurity.SecurityGroupsDataSet.GroupMembersRow member = groupDs.GroupMembers.FindByRES_UIDWSEC_GRP_UID(resourceGuid, securityGroupGuid);
    if (member == null)
    {
        SvcSecurity.SecurityGroupsDataSet.GroupMembersRow groupMembership = groupDs.GroupMembers.NewGroupMembersRow();
        groupMembership.RES_UID = resourceGuid;
        groupMembership.WSEC_GRP_UID = securityGroupGuid;
        groupDs.GroupMembers.AddGroupMembersRow(groupMembership);
        securityClient.SetGroups(groupDs);

    }
}
Advertisements

2 thoughts on “Adding user to Project Server Group Programmatically

  1. Thank’s a lot! It helped me very much!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s