How to get the name of a web user

Posted on 2002-06-10
Last Modified: 2013-12-18
This is the  code i have written for an agent:
Dim Session As New NotesSession
     Dim db As NotesDatabase
     Dim curdoc As NotesDocument    
     Dim remcreator As NotesItem
     Set db=Session.CurrentDatabase
     Set curdoc=Session.DocumentContext
     Set remcreator=curdoc.GetFirstItem("FNRemCreators")
     Set usr=New NotesName(Session.Username)
     Msgbox curdoc.Remote_User(0)
     curdoc.Save True,False

The purpose of this agent is to trap the name of the user who is calling the agent and append the name to the FNremCretors field.
On the Notes client I can do this using Session.UserName but on the browser it returns me the server name.Although I login to the browser using admin but it is unable to trap the value using this code.Any clues???
Question by:sampa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2

Expert Comment

by:Jean Marie Geeraerts
ID: 7069144
First of all you need to set the agent to run as web user, otherwise the name of the server will be returned.
To do this open the agent properties from the agent list, then on the third tab check the checkmark for "Run Agent as Web user".

To get the name of the currently logged on user, use the EffectiveUserName property of NotesSession.

So in your code this would be:
Set usr=New NotesName(Session.EffectiveUserName)

LVL 10

Accepted Solution

zvonko earned 50 total points
ID: 7069210
Hello JM, hello sampa,

Alternatively to setting this option for the agent as upper proposed is there a more simple way getting current web user name: create an additional field on your form and placing a value @Formula to get current logon name of the web user. Do not hide the field with Notes hide-when methods; use http option: “type=hidden” or enable form option: GenerateHtmlForAllFields
One of the suitable value formulas could be: @Name([CN];@UserName)

This method is especially useful if you do not like to loose agent privileges granted from agent signer (saving designer) by using RunAsWebUser option.



Author Comment

ID: 7069262
Jerrith,thanks for the help but effectiveUserName returns the person who last saved the script but i do not want that I want the person who has currently logged in.I think that way zvonko ur suggestion satisfies the requirement.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

by:Jean Marie Geeraerts
ID: 7069326
EffectiveUsername will return the current username if the agent is run as web user.
You have not set the option as I specified, otherwise it would work, without the use of an extra field on the form.

Author Comment

ID: 7069416
I checked out with everything that u had given but although i had logged in as user1 it was showing me admin and i checked the doc properties it showed modified by admin.
LVL 10

Expert Comment

ID: 7069594
Thank you for the points :-)

But my buddy JM is right: you surely made a mistake testing his proposal.

Here is my code testing his proposal and getting the described result: effective web user name

Sub Initialize
     Dim Session As New NotesSession
     Dim usr As NotesName
     Set usr=New NotesName(Session.EffectiveUserName)
     Print "Starting...<br>"
     Print "User: " & usr.Common
End Sub


PS: you need two print lines on web! Otherwise is a single print line interpreted as redirection URL by Domino web engine.


Expert Comment

by:Jean Marie Geeraerts
ID: 7069742
It's not the document properties, but the agent properties from the agent list that you need to check.
There is on the design tab of the agent an option you need to check to run an agent as web user.
You need to make sure that the user has sufficient rights to run the agent and perform actions that are performed in the agent for this option to be effective.
I mostly use this option for WebQueryOpen agents where the document is modified and saved when the document is opened from web. (Otherwise you get a save or replication conflict when saving the document afterwards)

Author Comment

ID: 7069780
See actually there is an action called Create Remark which is there on a response doc which has already been created.Once I click on the action I should be able to create a resp to resp doc.Now my purpose is to check whether this user has already created a resp to resp for the current resp doc.If it is so then stop creation of further resp to resp docs.

Jerrith I have checked the same from agent properties.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question