%% Authorize Users for Job and Task Access
% This example shows how to authorize users to access your job on a MATLAB Job Scheduler cluster with security level 2 or 3. For security level 2 and 3, when you create and submit a job to a MATLAB Job Scheduler cluster, jobs and tasks are identified with the submitting user. These jobs and tasks are password protected, and therefore other unauthorized users cannot access your jobs.
% Use parcluster to create a cluster object using the cluster profile 'MyMJSCluster'. Replace 'MyMJSCluster' with the name of your cluster profile. Then, use batch to create and submit a job on the cluster.

c = parcluster('MyMJSCluster');
j = batch(c,@rand,1,{2});

% You can use the AuthorizedUsers of a job to authorize user access to a job and the job’s and tasks. Each user that you specify must have previously interacted with MATLAB Job Scheduler cluster. To authorize access to a job for users "user1" and "user2", set the AuthorizedUsers of the job to ["user1","user2"].

j.AuthorizedUsers = ["user1","user2"];

% Copyright 2020 The MathWorks, Inc.