Get windows username from browser

Get client windows username

Can i get the username of the currently looged in person using applets. If yes, how can i use the applet in my dynamic web project? I know in I.E we can do like this

but i want it using applet so that it will work in any browser.

1 Answer 1

Be aware that this is in fact an attempt to circumvent the browser security. look at the answer to this similar (but not excactly the same) question. http://www.coderanch.com/t/243316/Applets/java/windows-NT-login-applet

  • ActiveX will not run properly in Chrome / Firefox.
  • Javascript won’t (due to security reasons) allow you to get that information from the operating system.
  • Flash is cross browser, and can be used for this, but it is difficult to get around chromes sandbox.

so my best suggestion is java.

And the provided link from an answer to another similar question points to a java solution, but there are limits to the success: http://www.rgagnon.com/javadetails/java-0441.html

However I think you should start from there, and then post a solution here when it works 😉

See the problem here is that when the applet tries to interact with local resources the browser must allow it, or block it.. Security settings in IE, may prevent that if set to high, and Chromes sandbox may block it if you do it wrong. I don’t know of problems with Firefox or Safari, but I guess you’ll find them when testing.

Node.Js — Get windows username

I am trying to get the windows username of the machine that is running my node.jS app (the app is always running on a Windows machine).

How can I get the current windows username using Node.Js?

I am trying to find something similar to WindowsIdentity.GetCurrent().Name in C# for node.js, or whoamI command in CMD.

6 Answers 6

Since Node v6 (2016-04), you can just use os.userInfo :

To get the current logged-in username:

I understand that this will not give the client user of a web app as OP asked, but this question is very high in the search results for trying to get the logged in user when running a Node application locally.

You can reproduce the \ output of whoamI and WindowsIdentity.GetCurrent() with environment variables in Windows.

Читайте также:  Flytv prime 34 для windows 10

If you’d rather use USERPROFILE :

Although node has the built in operating system function os and the os.hostname() to return the host name, you will need to access the client’s hostname in ASP.NET or the language of your choice. You can’t do that in node since it is running on the server side and has nothing to do with the client’s local info.

Look at this question

GET CLIENT HOST NAME IN ASP.NET AKA CLIENT SIDE

SPOON FEED FOR THE LAZY

Someone has created a module called username that does all of the hard work for you.

You use it like

I believe you are stating that you have a Asp.NET application, and would like to use Node.js to determine the current users username, and then submit it to your Asp.NET application.

I do not develop on Windows though from this question I believe this may be stored as an environment variable. process.env is a javascript map / dict of environment variables and likely contains the users username.

Alternatively you can parse it from the users home directory as such :

var path = require(‘path’); var username = path.sep(process.env[‘USERPROFILE’])[2];

The question I linked above implies that USERPROFILE resolves to C:\Users\USERNAME\ . I then split the path and take the 3rd element, being the username.

Again, I do not have a windows machine and could not confirm this. Hope this sets you down the right path though.

Can you get a Windows (AD) username in PHP?

I have a PHP web application on an intranet that can extract the IP and host name of the current user on that page, but I was wondering if there is a way to get/extract their Active Directory/Windows username as well. Is this possible?

16 Answers 16

Check the AUTH_USER request variable. This will be empty if your web app allows anonymous access, but if your server’s using basic or Windows integrated authentication, it will contain the username of the authenticated user.

In an Active Directory domain, if your clients are running Internet Explorer and your web server/filesystem permissions are configured properly, IE will silently submit their domain credentials to your server and AUTH_USER will be MYDOMAIN\user.name without the users having to explicitly log in to your web app.

I’ve got php mysql running on IIS — I can use $_SERVER[«AUTH_USER»] if I turn on Windows Authentication in IIS -> Authentication and turn off Anonymous authentication (important)

Читайте также:  Asus g771jw драйвера windows 10

I’ve used this to get my user and domain:

$user will return a value like: DOMAIN\username on our network, and then it’s just a case of removing the DOMAIN\ from the string.

This has worked in IE, FF, Chrome, Safari (tested) so far.

Look at the PHP LDAP library functions: http://us.php.net/ldap.

Active Directory [mostly] conforms to the LDAP standard.

We have multiple domains in our environment so I use preg_replace with regex to get just the username without DOMAIN\ .

If you’re using Apache on Windows, you can install the mod_auth_sspi from

Instructions are in the INSTALL file, and there is a whoami.php example. (It’s just a case of copying the mod_auth_sspi.so file into a folder and adding a line into httpd.conf.)

Once it’s installed and the necessary settings are made in httpd.conf to protect the directories you wish, PHP will populate the $_SERVER[‘REMOTE_USER’] with the user and domain (‘USER\DOMAIN’) of the authenticated user in IE — or prompt and authenticate in Firefox before passing it in.

Info is session-based, so single(ish) signon is possible even in Firefox.

Get windows username from browser

This forum is closed. Thank you for your contributions.

Asked by:

Question

I am working in an internet application.Below are the technologies I am using in this project:

Angularjs and no server side framework.

Below is client requirement:

There is a login page.When user load the login page say http://mytime.com:8000 I want to auto populate the windows user(loged in user name) name in user name text box in login page.

In IE 11 I browser I was doing getting the windows username by using the javascript as below:

All replies

Even if the existing code works for you, ActiveX controls is needed to be on in security settings.

Instead of making this work for each OS/browser, it’s a good idea to use AJAX to call a server-side method returning the logged in username. You can have a HTML control to hold username.

Thanks Aishwarya.Yes I know It needs to be on in security settings . As I have mentioned below code is working in IE 11(after enable on security settings) but I want to use it on window 10 Edge browser.

var objUserInfo = new ActiveXObject ( «WScript.network» );

Check if this helps:

No help from the above URLs.

Can any one help me .

I ran into the same issue as yours and I got a solution for this.

The suggestion to use the ActiveXObject would not function on Chrome, Firefox and any other browsers than Internet Explorer.

Читайте также:  Собственный dns резольвер windows

You can only get current Windows User Name from the machine by means of ASP.NET server side code.

but this can only work if you:

  • enable Windows Authentication for the website in its properties in IIS server Control Panel
  • enable ASP.NET impersonation there too
  • disable Anonymous Authentication for the website in IIS server Control Panel

depending upon the completeness of the installation of the IIS package such as «Feature Delegation» package, I recommend you to add the following in the web.config file:

enter these lines:

See below a legit explanation for the two nodes and

Last, but not least, to make sure the Windows Authentication works on your IIS Webserver:

Set these properties on for Windows Authentication:

How to get logged-in user’s full name in windows?

How to get logged-in user’s full name (the one he/she entered as his/her real name) using windows API or something else? For example how to get «John Smith», not «john» (as it were his username).

GetUserName(. ) doesn’t do the job because it returns the username, not the full name.

6 Answers 6

Did you try GetUserNameEx(NameDisplay. )?

A quick Google reveals that NetUserGetInfo should do this. It doesn’t look like the easiest API in the world to use.

I think the level you’re after is 10, which returns a USER_INFO_10 structure, containing, among other things, a usri10_full_name .

Make sure you remember to free the structure when finished, using NetApiBufferFree!

Well, if the user never entered it, there’s no way for you to get it. You could look for installed email programs and politely ask them for the info, but that’s a bad idea for many reasons.

Here’s your best shot: Get the name the user entered when registering the copy of Windows. This is in the registry. The exact location differs between Windows versions, but in recent versions, it’s at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion (and in Windows 95/98/ME, at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion ).

In there, you’ll find RegisteredOwner, which is where the was supposed to enter the name. Obviously, if this is a company computer and the machine was set up by IT, it’s very common to find a standardized company string there. And, of course, lots of people will enter names there like «Joe Sixpack» or «Cracked by Quartex». However, that’s as close as you can get.

Оцените статью