Reputation: 23
I want to get my system's username and render it on browser. The method that I have used so far is using ActiveXObject with which I was able to get the username but it has certain flaws such as ActiveX must be enabled on the system and will work only on Internet Explorer also I came to know that this method is not secured enough.The other solution I found was to use AJAX but I am not sure how to use it to get username. It will be great if anyone can help me with this and tell me how exactly to use AJAX to fetch username. PS: I don't have any idea about AJAX and don't have much time to learn it.
Upvotes: 0
Views: 489
Reputation: 3541
There are no methods that are "secured enough" the moment that you grant access to local resources.
The "proper" way to do this would be to make a call to a specific server (yes, an AJAX call) that will recognise the user by some UUID, or that will match the login used on the browser with your system login and display that.
That implies that you should have
I don't see any other way of doing it that is not a security risk.
If your idea was to have an HTML file to directly open in the browser so that you could run some sort of local command to get the username, then no, it's not possible and it would be very worrisome if it were.
So yes, you'll have to learn how ajax calls work, but keep in mind that if there's no server to reply to those calls, there's no point.
Upvotes: 0
Reputation: 74
I think is not possible to do that. It would be a huge security risk if a browser access to that kind of personal information
Upvotes: 1