using node-sspi with express.js
<p>Given the code included how would I go about getting a function that returns req.connection.user without using app.use etc? Totally confused!</p>

<p>I want to do this in app.js. I have tried a dozen different ways but I am hitting a wall. Thanks</p>

<pre><code>function GetUserName() {
}

--Sample code
'use strict';

var express = require('express');
var app = express();
var server = require('http').createServer(app);
app.use(function (req, res, next) {
  var nodeSSPI = require('node-sspi');
  var nodeSSPIObj = new nodeSSPI({
    retrieveGroups: true
  });
  nodeSSPIObj.authenticate(req, res, function(err){
    res.finished || next();
  });
});
app.use(function (req, res, next) {
  var out = 'Hello ' + req.connection.user + '! You belong to following groups:&lt;br/&gt;&lt;ul&gt;';
  if (req.connection.userGroups) {
    for (var i in req.connection.userGroups) {
      out += '&lt;li&gt;'+ req.connection.userGroups[i] + '&lt;/li&gt;&lt;br/&gt;\n';
    }
  }
  out += '&lt;/ul&gt;';
  res.send(out);
});
// Start server
var port = process.env.PORT || 3000;
server.listen(port, function () {
  console.log('Express server listening on port %d in %s mode', port, app.get('env'));
});
</code></pre>