Solved

question for jerrith (script library)

Posted on 2002-05-01
10
222 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
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 50 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now