0

Is there any way to get the credentials (mainly Name and/or E-Mail) of the currently logged in Microsoft User in MS Edge via JavaScript?

In older IE Versions, there was the ActiveXObject function, which would've allowed me to solve the problem like this, however this is depreactead and won't work in Edge:

var WinNetwork = new ActiveXObject("WScript.Network");
console.log(WinNetwork.UserName); 

Another possible option for me would be to just fetch the Windows User but I don't think that's possible in JS as it's pretty limited to the browser or am I wrong?

Zer0
  • 1,580
  • 10
  • 28
  • Which version of Edge browser are you using? What kind of account info do you want to get? I want to confirm that if you want to get the browser profile log in account or the Windows log in account. If you mean Windows log in account then I think you can't get it in JavaScript. The Windows log in account is in OS level and it's unsafe to allow client-side code to reach it. – Yu Zhou Sep 11 '20 at 06:26
  • Yeah, it doesn't matter anymore as I found a work-around with ASP.NET to solve my problem – Zer0 Sep 11 '20 at 06:27
  • That's great. It will be nice if you put your solution as an answer and mark it as an accepted answer after 48 hrs, when it is available to mark. It can help other community members in future in similar kind of issues. Thanks for your understanding. – Yu Zhou Sep 11 '20 at 06:30
  • yeah I thought so too, however as I didn't use any technology related to JS I thought I'd leave it open because there may be a solution – Zer0 Sep 11 '20 at 06:31
  • That also makes sense. Let's wait and see. – Yu Zhou Sep 11 '20 at 06:40
  • You're right tho, I'll still post an answer showing what I did, but won't mark it as accepted – Zer0 Sep 11 '20 at 06:44

1 Answers1

0

As this was intended for an ASP.NET application, I managed to achieve what I wanted (aka getting the Windows Username) using Windows Authentification based on a few other articles that I'll link below, I hope this helps anybody who is facing similiar issues:

There are fairly more answers in other Stack Overflow questions as well, but this is mainly what I used (Note: One thing that took me hours is that Visual Studio didn't update the project properties to also work with Windows Authentification, so be sure to check this as well)

Zer0
  • 1,580
  • 10
  • 28