Manage Learn to apply best practices and optimize your operations.

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.

VIEW MEMBER FEEDACK TO THIS TIP

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.

MEMBER FEEDBACK TO THIS TIP

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.

Dig Deeper on JavaScript for Lotus Notes Domino

SearchWindowsServer

Search400

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter

SearchContentManagement

Close