//sample that shows how to set workflow permissions
        //in this sample, we are giving a dummy user account rights to a dummy process
        public void SetWorkflowPermissions()
        {
            //establish the connection
            WorkflowManagementServer K2Mgmt = new WorkflowManagementServer();

            K2Mgmt.CreateConnection();
            K2Mgmt.Connection.Open("connectionstring");

            //get the proc set ID of the workflow whose permissions we need to set
            SourceCode.Workflow.Management.Criteria.ProcessCriteriaFilter filter = new SourceCode.Workflow.Management.Criteria.ProcessCriteriaFilter();
            Processes procs = null;

            filter.AddRegularFilter(ProcessFields.ProcessFullName, Comparison.Equals, "processFullName");
            procs = K2Mgmt.GetProcesses(filter);
            int procSetId = procs[0].ProcSetID;

            //now that we have the proc set ID, we can apply permissions
            //build up a collection of permissions to apply to the workflow
            Permissions permissions = new Permissions();
            //create a ProcSetPermission object - this object will be added to the Permissions collection
            ProcSetPermissions procPermissions = new ProcSetPermissions();

            procPermissions.ProcSetID   = procSetId;
            procPermissions.UserName    = @"domain\username"; //could also be ProcPermissions.GroupName for a group
            procPermissions.Admin       = true;
            procPermissions.Start       = true;
            procPermissions.View        = true;
            procPermissions.ViewPart    = false;
            procPermissions.ServerEvent = false;
            //add the permission to the permissions collection
            permissions.Add(procPermissions);
            procPermissions = null;

            //now we can apply the updated set of permissions to the process
            K2Mgmt.UpdateProcPermissions(procSetId, permissions);

            //several other methods are also available, listed below. Check product documentation for more information
            //K2Mgmt.UpdateGroupPermissions();
            //K2Mgmt.UpdateOrAddProcUserPermissions();
            //K2Mgmt.UpdateProcGroupPermissions();
            //K2Mgmt.UpdateProcUserPermissions();

            //close the connection
            K2Mgmt.Connection.Close();
        }