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
Solved

How to get the name of a web user

Posted on 2002-06-10
8
228 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

860 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