Far too late to help abhishekitb, but it can be used by somebody else who asks the same question.

Even if environment variables work well, as NeoPa said, this works too :
Code:
var ActX=new ActiveXObject("wscript.network");
alert(ActX.username);
Note that in the same way, you can get the computer and the domain name.
Code:
alert(ActX.computername);
alert(ActX.userdomain);
Tested...