Solved

How to get the name of a web user

Posted on 2002-06-10
8
226 Views
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)
     remcreator.AppendToTextList(curdoc.remote_user(0))
     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???
0
Comment
Question by:sampa
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

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)

Regards,
JM
0
 
LVL 10

Accepted Solution

by:
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.

Regards,
zvonko

0
 

Author Comment

by:sampa
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.
Thanks
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 8

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.
0
 

Author Comment

by:sampa
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.
0
 
LVL 10

Expert Comment

by:zvonko
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

Cheers,
zvonko

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

0
 
LVL 8

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)
0
 

Author Comment

by:sampa
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.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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