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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.