JavaScript to find the operating system user name
If a user is accessing a Lotus Notes database anonymously, you can find out the person's operating system user name by using the WScript.Shell ActiveX. Just use his JavaScript code provided by SearchDomino.com member Yossi Sabag.
If a user is accessing a Lotus Notes database anonymously, you can find out the person's operating system user name by using the WScript.Shell ActiveX. Just use the following JavaScript code:
var oShell=new ActiveXObject("WScript.Shell") un=oShell.ExpandEnvironmentStrings("%USERNAME%") domain=oShell.ExpandEnvironmentStrings ("%USERDOMAIN%") document.all.item('username').value=un document.all.item('domain').value=domain
If you get an error that says: "Automation object can't create object," then register the WScript object by running the Wscript -regserver command from a command prompt or from the Run command on the Start menu.
This tip didn't work for me at all. There was no error message, just the default database view. Also, there is nothing that says where to put the JavaScript on the form
—Hamish S.
******************************************
When the user says "It didn't work for me at all," it depends on the Internet Explorer security policy. Regarding the user saying "there is nothing that says where to put the JavaScript on the form," it is possible to put it in various events such as Onload, button click, etc.
—Yossi Sabag, tip author
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip library by member Yossi Sabag. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.