-1

My NodeJS app is running on a Linux server.

I have several machines connecting to the app (via browser) running on Windows.

How can I get, in my app, the current windows logged in user?

VeZoul
  • 500
  • 6
  • 19

2 Answers2

2

If your Linux server is on the same local network as your Windows clients, you can use an NTLM authentication package like express-ntlm to authenticate your users and get their username.

var express = require('express'),
ntlm = require('express-ntlm');

var app = express();

app.use(ntlm({
    debug: function() {
        var args = Array.prototype.slice.apply(arguments);
        console.log.apply(null, args);
    },
    domain: 'MYDOMAIN',
    domaincontroller: 'ldap://myad.example',
}));

app.all('*', function(request, response) {
    response.end(JSON.stringify(request.ntlm)); // {"DomainName":"MYDOMAIN","UserName":"MYUSER","Workstation":"MYWORKSTATION"}
});

app.listen(80);
Eric B
  • 691
  • 5
  • 11
0

Browser trying to access that kind of information is considered a security risk and not wildly supported.

But you can access the logged in windows user name in Internet Explorer alone using ActiveX. For more information of how to get follow this SO post JavaScript - How to get the name of the current user

Muthukumar
  • 8,679
  • 17
  • 61
  • 86