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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.