webassembly get current windows authenticated user intranet RRS feed

  • Question

  • User1556204831 posted

    From my browsing over the web tonight, I am not thinking this is possible.

    Is there away from the blazor client app, to get the current logged in user on the intranet, and then auto login and by pass needing to have the user log in on the client?

    Just like on a server project, I would like the client project to know the username of the current windows user.

    I know I could just have them login and submit, but they are used to not having to do that, all other projects we have built they don't need to login.

    I suspect I will need to just do a blazor server project as I normally do, but I thought it would be a nice option to do a client app and do it as a pwa so the user could install the app instead of needing to save the link.

    Monday, February 1, 2021 4:30 AM

All replies

  • User-474980206 posted

    WebAssembly blazor can use windows authentication with web api calls. for the blazor app to know the user, it just makes an api call to an window authenticated endpoint that return user info.

    note: the browser must support windows authentication, but you seem to have this working.

    Monday, February 1, 2021 3:54 PM
  • User1556204831 posted

    Thanks Bruce, I am probably missing something here, but how does the api know what user is on the client?

    I am assuming the client has to pass this on to the api since the application loaded in the browser is the client app, how would the user info be passed on to the api, outside capturing credentials from a login form?

    Is there a built in function, similar to httpcontext, in the client that knows the user info over windows authentication?

    Thank you,

    Rick Doll. 

    Monday, February 1, 2021 4:34 PM
  • User-474980206 posted

    if you are using windows authentication, then the browser handles the authentication (if supported) on the ajax requests. The server api must require windows authentication.  

    as I indicated, the client does not know, it must make a server api call to get the user info.

    Monday, February 1, 2021 7:16 PM
  • User1556204831 posted

    For now I am going to do this current app in a blazor server project so that I can get it done. 

    For future projects, I am a bit lost on how I am supposed to get the user in the server api call.

    What I do to get the user id of a windows authenticated user in the blazor server app is I get it out of the httpcontext on the razor page.

    There is no login form, app runs in IIS and they may get a pop up every now and again to enter credentials from iis, but generally do not need to and the app knows who they are.

    I realize for security that this isn't the same in the client app.

    What alternative method should I be using with the api call to get to the windows user?

    Tuesday, February 2, 2021 4:46 PM