Ask the Expert

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

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: