Saturday, December 29, 2007

JavaScript: Return the NT ID of an user using Shell

// ***
// Returns NT ID of current user
// Note: Would cause an ActiveX warning message if corresponding site is not added in "Trusted Sites" list
// Behavior may also vary with different versions of IE (IE6 vs IE7)
// ***
function getCurrentUserId()
{
var wshell = new ActiveXObject("WScript.Shell");
var userId = wshell.ExpandEnvironmentStrings("%USERNAME%");
return userId;
}

No comments:

Post a Comment

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.