Base solution for your next web application
Open Closed

Automatic login via windows authentication (azuread\myname) #2386


User avatar
0
adamm created

I am not sure if I am heading down the wrong path, but I am trying to login automatically (no login page or login) based on the windows identity.

I tried following the instructions for the LDAP, but am a bit lost.

For now, I modified the TokenProviderMiddleware:

public Task Invoke(HttpContext context)
{
    SetCurrentUser(context);

... (rest of code) ...
}

private void SetCurrentUser(HttpContext context)
{
            if (NullAbpSession.Instance.UserId != null) return;
            var currentUser = context.User.Identity.Name;
            var user = _userManager.FindByNameAsync(currentUser);
            if (user?.Result?.Id == null) return;
            //TODO: set Session with this user
}

I haven't yet figured out the setting and authenticating, but I assume there is a different/better way?

Please advise...


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I'm not %100 sure if this is what you are lokking for but you can take a look at this comment of mine. #1725@ecf150a8-ddb4-4bf8-baf9-d8288d9796a2

    Create a custom Auth middleware (I don't know if there is one for this, maybe there is already one) and use it in your project.