Tip

Get Person Document from NAMES.NSF with CGI Remote User

At times it is necessary to get the details of the Domino "cgi - Remote_User" person Document in NAMES.NSF. In my case, I needed to get a value from the comments field (which was actually not a comment but a key value to get the person document in our custom Address Book).

I thought it was not a good idea to change the design of the Public Address Book(NAMES.NSF) because of the upgrades and such that this NSF goes through (e.g. the design changes could be lost).

So, I wrote something that would get the cgi varaible, Remote_User, and from that get the person document in NAMES.NSF. From there you can get the details in any of the fields in that person document. i.e. Phone Number, Email address, Comments.

Randy McDougall


Dim session as New NotesSession
Dim cgidoc as NotesDocument
Dim remote_user as String

Set cgidoc = session.DocumentContext

remote_user = cgidoc.Remote_User(0)

'************************************************
' This function is used to get the Person doc from names.nsf
' Randy McDougall Nov. 19, 1998

'*************************************************

Dim db As New NotesDatabase ("", "names.nsf")

Dim view As NotesView

Dim IDdoc As NotesDocument

'***************************************
' Create a name string that will match a lookup in names.nsf people view

Dim positionOfChar As Long
Dim lengthOfString As Long

lengthOfString& = Len(remote_user)

theSpace = " "
positionOfChar& = Instr(1, remote_user, theSpace)

Dim holder As Long
holder = LengthOfString - positionOfChar

Dim FirstName As String
FirstName$ = Left$(remote_user, positionOfChar - 1)

Dim LastName As String
LastName$ = Right$(remote_user, holder )

nameString = LastName + " , " + FirstName

'****************************************

Set view = db.GetView("People")

Set IDdoc = view.GetDocumentByKey(nameString)

'Here you can get any value you like
'I needed an id(key value) from the comments field
Dim ID As String
ID = IDdoc.comment(0)

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.