[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

question for jerrith (script library)

Posted on 2002-05-01
10
Medium Priority
?
244 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

650 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