Home > Domino Tips > Developer > Agent > Group roles on the Web
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

AGENT

Group roles on the Web


Jason Fenner
07.22.2002
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


The core of our parts website is created by Domino web agents. These agents are written in lotusscript and Several of the items are shown or hidden base on user roles.

Since there wasn't a function capable of checking roles for groups I wrote verifyUserRole. You pass in the Role, Session, and Canonical User name and it returns true or false.

As a test copy this code into an agent and call it via url from your web browser.



Code

Sub Initialize
 
 Dim s As New NotesSession
 Dim db As NotesDatabase
 Dim acl As NotesACL
 Dim entry As NotesACLEntry
 Dim doc As notesdocument
 Dim nn As notesname
 Set doc = s.documentcontext
 Set nn = New notesname(doc.remote_user(0))
 role$ = "[com]"
 roleIsEnabled = verifyUserRole (role$, s, nn.Canonical)
 If roleIsEnabled Then
  Print role$ & " is enabled for user " & nn.Abbreviated
 Else
  Print role$ & " isn't enabled for user " & nn.Abbreviated
 End If
 
End Sub

Function verifyUserRole (role As String, s As NotesSession, user_Name As String) As Variant
 
 Dim acl As NotesACL 
 Dim entry As NotesACLEntry
 Dim currdb As NotesDatabase 
 Dim GroupsView As NotesView
 Dim groupdoc As NotesDocument
 Set currdb = s.CurrentDatabase
 Dim NAdb As New NotesDatabase(currdb.Server,"names.nsf")
 Set acl = currdb.ACL
 Set GroupsView = NAdb.GetView("Groups")
 roleIsEnabled = False
'Check to see if the user is listed directly in the ACL  
 Set entry = acl.GetEntry( user_Name )
 If Not entry Is Nothing Then
  If entry.Isroleenabled(role$) Then
   verifyUserRole = True
   '  print "User role" & role & " is enabled for " & user_Name
   Exit Function
  End If
 Else
  
'User is not listed get first entry in the ACL to look for groups
  Set entry = acl.GetFirstEntry 
  While Not entry Is Nothing 
   '  print "entry " & entry.name & " <br>"
   If entry.Isgroup Then
    '  print entry.name & " is a group<br>"
    If entry.IsRoleEnabled(role)Then
     '  print "The " & role & " role is enabled for " & user_Name & " in group " & entry.name & "<br>"
'Find group in the Address Book
     Set groupdoc = GroupsView.GetDocumentByKey(entry.name) 
     If Not groupdoc Is Nothing Then
'Roll through members and check for current user
      Forall names In groupdoc.members 
       If user_Name = names Then
        '  print "verified <br>"
        verifyUserRole =True 'role is enabled for user
        Exit Function
        Exit Forall
       End If
      End Forall
     End If
    End If
   End If
'Get next ACL entry
   Set entry = acl.GetNextEntry(entry)
  Wend
 End If
End Function

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Agent
Run or restart Notes/Domino agents via text messages
Approve Lotus Notes documents using a BlackBerry mobile device
LotusScript agent indexes Lotus Notes/Domino databases
Open documents in Lotus Notes from the Web without a UNID
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
How to export data from a Lotus Notes database to a CSV file
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts