Main Content

compiler.UserInfo

Retrieve details of logged-in user

Since R2022a

Description

example

user = compiler.UserInfo() returns the details of a user logged in to the machine running a desktop version of MATLAB® or details of a user logged in to MATLAB Web App Server™.

Examples

collapse all

At the MATLAB command prompt execute:

user = compiler.UserInfo()
user = 
  UserInfo with properties:

         UserID: 'someid'
    DisplayName: <missing>
         Groups: <missing>
         Domain: 'SOME_DOMAIN'

Create the userinfo.json file in the webapps_private folder on MATLAB Web App Server.

{
    "version": "1.0.0",
    "userInfo.doc": "Property values to be fetched during login from IdP",
    "userInfo": {
      "UserID": "upn",
      "DisplayName": "displayName",
      "Groups": "groups",
      "LastName": "surname",
      "Email": "mail"
    },
    "appAccess.doc": "Policy for allowing access to user properties within an app or group of apps",
    "appAccess": {
      "BloodPressure": ["UserID","Email"],
      "Mortgage": ["UserID","LastName"],
      "Mystery": ["UserID","Email","WebAppsRole","WebAppsDisplayName"]
    }
  }
Then use the compiler.UserInfo function within your app to customize the app.
function startupFcn(app)

try
    user = compiler.UserInfo();
catch me
    error(me.message);
    return
end

if ~ismissing(user.UserID)
    % customizing app code
end
if isprop(user, 'Email')
    % customizing app code
end

Output Arguments

collapse all

Logged-in user details, returned as a compiler.UserInfo object.

Version History

Introduced in R2022a

See Also

|

Topics