Q

Disallow user from opening a form without specific role

I'm using Domino 5. I am trying to avoid opening a form if the user doesn't have a specific role. I need to access

the 'role' field from the doc so I have code in the postopen event. However, the continue=false doesn't work. An error message displays, and the form opens anyway. Please help!

Here's the code:

Sub Postopen(Source As Notesuidocument)
 Dim doc As notesdocument
 Dim item As notesitem
 Set doc = source.document
 Set item=doc.getfirstitem("RoleX")
 If item.contains("[
CSSUnderwriters]") Then  
  continue=True
 Elseif item.contains("[
Admin]; [
CSSUnderwriters]") Then
  continue=True
 Else
  Messagebox "You are not 
authorized to open this form.",,"No Access"
  continue=False
  Exit Sub
 End If
End Sub

Continue is not available in the PostOpenEvent. You have two options. First, you can use your code in the PostOpen Event as modified below.
Sub Postopen(Source As Notesuidocument)
 Dim doc As notesdocument
 Dim item As notesitem
 Set doc = source.document
 Set item=doc.getfirstitem("RoleX")
 If item.contains("[
CSSUnderwriters]") Then  
  Goto SingleExit
 Elseif item.contains("[Admin]; 
[CSSUnderwriters]") Then
  Goto SingleExit
 Else
  Call source.Close
 Messagebox "You are not authorized to 
open this form.",,"No Access"
 End If
:SingleExit
End Sub

However, you shouldn't even show the document if you don't want the user to open it. You could use your original code in the QueryOpen event so the document is not opened. Continue is available and will function in QueryOpen.

Although both of these methods will keep the document from being opened, it is not a security function and will not prevent people from accessing information in the document.

Do you have comments on this Ask the Expert question and response? Let us know.

This was first published in October 2004

Dig deeper on Lotus Notes Domino Application Development

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

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:

SearchWinIT

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

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close