microsoft-authentication-library-for-dotnet
microsoft-authentication-library-for-dotnet copied to clipboard
ASP.NET Webforms Sample
After days of trying nearly everything and reading - still no sucess
ASP.NET Webforms, MSGraph login startup
app.UseOpenIdConnectAuthentication(New OpenIdConnectAuthenticationOptions() With { .ClientId = clientId, .Authority = authority, .PostLogoutRedirectUri = postLogoutRedirectUri, .RedirectUri = "https://localhost:44399", .Notifications = New OpenIdConnectAuthenticationNotifications() With { .SecurityTokenValidated = Function(context) Dim name As String = context.AuthenticationTicket.Identity.FindFirst("preferred_username").Value context.AuthenticationTicket.Identity.AddClaim(New Claim(ClaimTypes.Name, name, String.Empty)) Return Task.FromResult(0) End Function, .AuthenticationFailed = Function(context) Return Task.FromResult(0) End Function } })
seems to be success. (user.identity.name)
account is null /nothing ClaimsPrincipal.Current. have user content in aspx page
`
Dim app = ConfidentialClientApplicationBuilder.Create(ClientID) _
.WithTenantId(tenantId) _
.WithClientSecret(ClientSecret) _
.WithAuthority(New Uri(authorityUri)) _
.WithLegacyCacheCompatibility(False) _
.WithRedirectUri(redirectUri).Build()
app.AddInMemoryTokenCache()
Dim result As AuthenticationResult
'' Dim accounts = Await app.GetAccountsAsync() old???
Dim Account = Await app.GetAccountAsync(ClaimsPrincipal.Current.GetMsalAccountId())
Try
result = Await app.AcquireTokenSilent(scopes, Account).ExecuteAsync().ConfigureAwait(False)
`
I am sure I miss some understanding
@hannespreishuber : did you look at this sample: https://github.com/Azure-Samples/ms-identity-aspnet-webapp-openidconnect ?
this is not Webforms. I know literally every sample
to complex- no dependency like [Authorize] to Webforms pattern
I am looking just for the 10 loc
Which error do you get? Are you signing-in with a guest account? or an account in the directory?
works with core and others. Azure AD - as I have written: account is null /nothing