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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.