?
Solved

question for jerrith (script library)

Posted on 2002-05-01
10
Medium Priority
?
238 Views
Last Modified: 2013-12-18
I created one script library named

 Name : Check_Role

And the code is
Dim roles As Variant
Dim found As Integer
Dim session As  notessession

Sub stat_role
     Set session =New  notessession
Dim user As New NotesName(session.EffectiveUserName)
        roles=Evaluate("@UserRoles")
     found=False
     Forall r In roles
          If r="[Static_Role]" Then
               found=True
               Exit Forall
          End If
     End Forall
     
     If Not found Then
Print "Sorry, " + user.Common + ".[<BR>]You are not  authorized."
     Exit Sub
     End If
     
End Sub

And  script library I am calling in agent like this

and the agent i made as "run agent as web user"  

Use "Check_Role"

        Dim  session As New notessession
     Dim db As notesdatabase
     Dim view As notesview
     Dim doc As notesdocument
     
     Set db = session.currentdatabase
     Set view = db.getview("Qstatic")
     Set doc=view.Getlastdocument


Call stat_role    
Exit Sub

And I have some html code like this
        Print"<html>"
        Print"<head>"
     Print "<title>Dialup MTD</title>"
     Print "<body topmargin="0" leftmargin="0">"
     Print "<div align='center'>"
     Print "<b>Date:"
     Print"<font color='blue'>"&Format(Today, "Medium Date")&"</font></b><br>"
Print “</html>”

Now the problem is if the user is not having role permission its giving proper output like

U r not authorized.

If the user logs who is having the role permission its giving agent done.i don’t know where I am wrong .

0
Comment
Question by:saleemkhan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Expert Comment

by:jvanhalderen
ID: 6983404

    If Not found Then
Print "Sorry, " + user.Common + ".[<BR>]You are not  authorized."
    Exit Sub
    End If

change it into:


    If Not found Then
Print "Sorry, " + user.Common + ".[<BR>]You are not  authorized."
    Exit Sub
ELSE
Print "Welcome " + user.common
    End If
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6984246
to jvanhalderen: Are you relative to JM?

to saleemkhan: your Sub stat_role can not abort the processing of calling agent.
Better way would be to make a function.
Like this:
Function stat_role As Integer
  Dim roles As Variant
  Dim found As Integer
  found=False
  roles=Evaluate("@UserRoles")
  Forall r In roles
    If r="[Static_Role]" Then found=True
  End Forall
  If Not found Then
    Dim session As New NotesSession
    Dim user As New NotesName(session.EffectiveUserName)
    Print "Sorry, " + user.Common + ".[<BR>]You are not  authorized."
    stat_role = False
  Else
    stat_role = True  
  End If
End Function

Than you can call it from your Agent like this:
  If (stat_role) Then
   '...your html prints
  End If

Regards,
zvonko

0
 
LVL 8

Accepted Solution

by:
Jean Marie Geeraerts earned 200 total points
ID: 6985691
Hi Saleem,
I noticed you posted a question for the mail you sent me.

So here's my response as given by email:

Well the best way to use the check_role code is to put it in a function and have that function return true or false, depending on the result.

Here's a general setup for your agent :

(Options)
Option Public
Option Declare
Use "Check_Role"

(Declarations)
Dim session as NotesSession

Function Verify_Role(role as string)
     REM Check if the user has the role specified as a parameter and return true or false
     REM Call the function with the role to check as a parameter and include square brackets.
     REM e.g. hasRole=Verify_Role("[Static_Role]")

     Dim roles As Variant
     Dim found As Integer
     Dim user As New NotesName(session.EffectiveUserName)

     roles=Evaluate("@UserRoles")
     found=False
     Forall r In roles
          If r=role Then
               found=True
               Exit Forall
          End If
     End Forall
     Verify_Role=found
End Function

Sub Initialize
     Set session=New Notessession
     Dim user As New NotesName(session.EffectiveUsername)

     If Not(Verify_Role("[Static_Role]")) Then
          Print "You are not authorized to run this agent"
     Else
          Print"<html>"
          Print"<head>"
          Print "<title>Dialup MTD</title>"
          Print "<body topmargin="0" leftmargin="0">"
          Print "<div align='center'>"
          Print "<b>Date:"
          Print"<font color='blue'>"&Format(Today, "Medium Date")&"</font></b><br>"
          Print "</html>"
     End If
End Sub


If you use this body for your agent everything should work fine.
Regards,
JM
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:zvonko
ID: 6985697
Here the best example why whisper behind the curtain is no good :)

0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6985807
OH well,
Saleem can still reject the answer and accept my comment :-)
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6985844
That was not that what I mean.
I mean the delta between email and postings here :-)



0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6985848
Answer by email is a lot quicker for the questioneer, but if he doesn't say he's posted a question on EE as well, well I don't go look there, you know :)
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6985891
Hey, I am no angel too. I have done this also in former times. Only topic is to be aware of the side effects :-)

0
 

Author Comment

by:saleemkhan
ID: 7005269
Thanks jerrith.
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7005314
You'r' welcome :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question