Как вы сказали, OnTicketReceived
вызывается при нажатии кнопки входа в систему, но вы хотите, чтобы вход был успешным.
Вы увидите вход в систему и Журналы аудита из Azure AD на портале.
Sign-ins – Information about the usage of managed applications and user sign-in activities.
Audit logs - Audit logs provide system activity information about users and group management, managed applications, and directory activities.
So you don't need to add logs using NLog, the sign-in logs are automatically stored.
For more details about listing sign-ins, see здесь .
Пример кода:
// Read application settings from appsettings.json (tenant ID, app ID, client secret, etc.)
AppSettings config = AppSettingsFile.ReadFromJsonFile();
// Initialize the client credential auth provider
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(config.AppId)
.WithTenantId(config.TenantId)
.WithClientSecret(config.ClientSecret)
.Build();
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
// Set up the Microsoft Graph service client with client credentials
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
// status/errorCode eq '0' means sign-in success
var signIns = await graphClient.AuditLogs.SignIns
.Request()
.Filter("status/errorCode eq '0'")
.GetAsync();