4

I just started using angular 2/4 to develop internal applications. All of the applications need to be able to get the username of the logged in user on windows machines. The angular applications will be hosted using IIS and Windows Authentication. When using angularJS I used a web form as the index page and got the windows username using .NET and storing the username on the webpage.

How can I get the windows username using angular 2/4? I am using the CLI to create my applications.

All help is much appreciated.

Aaron
  • 141
  • 1
  • 1
  • 7
  • You are still able to host Angular 2/4 applications inside of .NET. – HaveSpacesuit Jul 12 '17 at 20:33
  • Nothing to do with angular. Has to do with the website host, which must log users on using ntlm or Kerberos (windows auth), after which time the website can supply the current user's name to the UI. –  Jul 12 '17 at 20:35
  • 1
    just create a web api service and set as windows auth and return an object with principal.Identity.Name or whatever else you need. I'm dong the same thing but I created a token service and return a JWT with the user info and roles and application specific roles stored in the database – Fab Jul 27 '17 at 16:52

2 Answers2

3

You can use Angular CLI with Visual Studio and .Net as described here: http://candordeveloper.com/2017/04/12/how-to-use-angular-cli-with-visual-studio-2017/

But as others have said, Angular is a client side web framework and as such cannot access the user's windows login info.

DeborahK
  • 57,520
  • 12
  • 104
  • 129
1

You would do it similar to how you did with your angularJS .NET project. Angular 2/4 does not have the ability to access the client's PC.

Surreal
  • 1,007
  • 1
  • 13
  • 29