SearchDomino.com
August 20, 2001
Developer Tip
================================================= 
------------------------------------------------- 
Sponsored By: SWING Software
------------------------------------------------- 
 ************* MS OFFICE INTEGRATION ************* 
Integrate your applications with Microsoft Office using new SWING
Integrator v2.1. Create, save, edit Office documents as attachments;
field exchange, mail-merge, labels, templates... Now there's no
easier way. No DLLs -- no end-user licenses -- unlimited distribution
(ROYALTY-FREE)! Learn what hundreds of developers and thousands of
end-users already know. 
http://www.swingsoftware.com/searchdomino.htm

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
Feature Tip
================================================= 
Title: Restrict access to design elements using reader fields

This tip was submitted by Catalin Popescu, a developer in Wien,
Austria.

Design elements are also Notes documents so access to these documents
could be restricted using reader fields. The following example shows
how to restrict access to an agent so it can be executed just by a
privileged group of users ([admin] role) without modifying the
original code of the agent. There are some situations when the code
of the agent cannot be modified (e.g. imported java agents). This
method could be extended if it is necessary for other design elements
like forms and views.

I'm using the function <getNoteID> that I've posted previously.  It
is published at
http://searchdomino.techtarget.com/tip/1,289483,sid4_gci550220,00.html#feedback.  

The function gets the NoteID of a design element that is referenced
by name and type(e.g. "getUserInfo" - AGENT)
-----------------------------
Option Public

Declare Function NIFFindDesignNote Lib "nnotes.dll" (Byval hDb As
Long, Byval noteName As Lmbcs String, Byval classType As Integer,
hNote As Long) As Integer

Declare Function NSFDbOpen Lib "nnotes.dll" (Byval sDbName As Lmbcs
String ,  hDb As Long) As Integer

Declare Function NSFDbClose Lib "nnotes.dll" (Byval hDb As Long) As
Integer

Declare Function OSPathNetConstruct Lib "nnotes.dll" (Byval portName
As Integer, Byval serverName As Lmbcs String, Byval fileName As Lmbcs
String, Byval pathName As Lmbcs String) As Integer

Const MAXPATH = 256
Const NOTE_CLASS_FORM = 0004  ' form note 
Const NOTE_CLASS_VIEW = 0008  ' view note 
Const NOTE_CLASS_FILTER = 0512 ' filter note 
Const NOTE_CLASS_FIELD = 1024 ' field note 

Function getNoteID(Byval servername As String,Byval filename As
String,Byval notename As String, Byval notetype As Integer) As Long
 Dim hdb As Long
 Dim hnote As Long
 Dim pathname As String*MAXPATH
 Dim result As Integer
 'OSPathNetConstruct creates a full network path - pathname -
specification for a Domino database file
 Call OSPathNetConstruct(0, servername, filename, pathname)
 'NSFDbOpen returns a handle  - hdb - to a database - pathname -
 result = NSFDbOpen(pathname, hdb)
 If result <> 0 Then
  Messagebox("Cannot open the database!")
  getNoteID = -1
  Goto ends
 End If
 'NIFFindDesignNote function returns the note ID of a form, view,
shared folder, agent, or field note, given the name and
NOTE_CLASS_xxx
 result = NIFFindDesignNote(hdb, notename, notetype, hnote)
 If result <> 0 Then
  Messagebox("Cannot find the note!")
  getNoteID = -1
  Goto dbclose
 End If
 getNoteID = hnote
 
dbclose:
 'NSFDbClose closes a previously opened database
 result = NSFDbClose(hdb)
 If result <> 0 Then
  Messagebox("Cannot close the database!") 
 End If
ends: 
End Function

-----------------------------------
The Sub is adding the reader field to the agent document 
-----------------------------------
Sub Initialize
Dim s As New NotesSession
 Dim db As NotesDatabase
 Dim noteID As Long
 Dim strNID As String
 Dim servername, dbname, notename As String
 
 servername="SEARCHDOMINO" ' "" for local
 dbname="TIPS.NSF"
 notetype = NOTE_CLASS_FILTER ' agent
 notename = "getUserInfo"
 
 Set db = s.GetDatabase(servername, dbname) 
 noteID = getNoteID(servername, dbname, notename, NOTE_CLASS_FILTER)
 If noteID = -1 Then 
  Goto ends
 End If
 strNID = Hex(noteID)
 Set doc = db.GetDocumentByID (strNID)
 If (Not doc Is Nothing )Then
 Dim newValues( 1 To 1 ) As String
  newValues( 1 ) = "[admin]"
  Dim readersItem As New NotesItem(doc, "docReaders", newValues,
READERS)
  Call doc.Save( True, True )
  
  
 End If
End Sub

http://searchdomino.techtarget.com/tip/1,289483,sid4_gci752882,00.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
DID THIS TIP WORK FOR YOU? Send us your feedback, and we'll add it to
the tip posted on searchDomino.com. Send you comments and feedback to
[EMAIL PROTECTED] 

OR SEND US YOUR FEEDBACK TO BE POSTED ON THIS TIP TO:
[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
NEWLY POSTED DEVELOPER TIPS: 
================================================= 
We posted 9 new tips last week. Thanks for all your tips and keep
them coming!

Agent Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283834_alpD_idx0,00.html
[1] Export to Word Script
[2] HTML newsletters

Domino Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283837_alpD_idx0,00.html
[1] Signature Files

HTML Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283838_alpD_idx0,00.html
[1] Cell background image for the Web
[2] Scrollable checkboxes
[3] Printer friendly
[4] Save your reports in a Notes document

Other Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283842_alpD_idx0,00.html
[1] Keeping the search bar enabled at all times

Script Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283841_alpD_idx0,00.html
[1] Print attachments with OLE Automation or a WindowsAPI

================================================= 
FEATURED BOOK:
================================================= 
Web Design & Development
by Kelly Valqui and Eunice Freire

This book and CD-ROM is a unique package that includes everything
needed to become a Web designer and developer. In addition to HTML
fundamentals, this title provides the skills for the entire Web
development process, from storyboarding a Web site, to adding images,
and JavaScript games, to uploading it as an e-commerce site. To
purchase this book at a discounted price or browse other titles in
the Learning Zone Bookstore, go to:

http://www.digitalguru.com/dgstore/product.asp?isbn=1584500360&ac_id=60

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
Disclaimer: These tips are submitted by your Domino peers. Our tips
services and online tips exchange are a way for you to learn from
other IT professionals and share technical advice and expertise with
your peers. Techtarget.com provides the infrastructure to facilitate
this sharing of information. However, we can't guarantee the accuracy
and validity of the material submitted. You agree that your use of
the searchDomino.com tips services and your reliance on any
questions, answers, information or other materials received through
searchDomino.com will be at your own risk.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
If you would like to sponsor this or any TechTarget newsletter,
please contact Gabrielle DeRussy at [EMAIL PROTECTED]

================================================= 



If you no longer wish to receive this newsletter simply reply to 
this message with "REMOVE" in the subject line.  Or, visit 
http://searchDomino.techtarget.com/register 
and adjust your subscriptions accordingly. 

If you choose to unsubscribe using our automated processing, you 
must send the "REMOVE" request from the email account to which 
this newsletter was delivered.  Please allow 24 hours for your 
"REMOVE" request to be processed.

Reply via email to