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

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

Hello,
i need to get device/system details by using javascript, please help me for the same.
thanks

Cancel

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close