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™.
user =
UserInfo with properties:
UserID: 'someid'
DisplayName: <missing>
Groups: <missing>
Domain: 'SOME_DOMAIN'
To enable detailed user information on MATLAB
Web App Server, you must create a userinfo.json file and place it in
the webapps_private folder. This file maps properties from your
Identity Provider (IdP) to MATLAB properties and defines which apps can access that data.
{
"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": {
"Health/BloodPressure": ["UserID", "Email"],
"Finance/Mortgage": ["UserID", "LastName"],
"Mystery": ["UserID", "Email", "WebAppsRole"]
}
}
The keys in the appAccess object correspond to the location of
your web apps relative to the apps root folder. If an application is stored in a
subfolder, you must include the folder path in the mapping.
For example, if the BloodPressure app is located in a folder
named Health, the key in the JSON file must be
"Health/BloodPressure". If an app is located directly in the root
apps folder, use the app name alone, such as "Mystery".
Use the compiler.UserInfo function within the
startupFcn of your App Designer app to customize the app.
function startupFcn(app)
try
user = compiler.UserInfo();
catch me
% Handle errors if the server is not configured for authenticationreturnendif ~ismissing(user.UserID)
app.WelcomeLabel.Text = "Welcome, " + user.UserID;
endend
The returned object contains properties such as UserID,
DisplayName, Groups, and any custom attributes
defined in the userinfo.json file. Properties that are not mapped or
not permitted for a specific app will return as <missing>.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.