saleemkhan
asked on
question for jerrith (script library)
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.Effectiv eUserName)
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(Toda y, "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 .
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.Effectiv
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(Toda
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 .
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.Effectiv eUserName)
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
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.Effectiv
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here the best example why whisper behind the curtain is no good :)
OH well,
Saleem can still reject the answer and accept my comment :-)
Saleem can still reject the answer and accept my comment :-)
That was not that what I mean.
I mean the delta between email and postings here :-)
I mean the delta between email and postings here :-)
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 :)
Hey, I am no angel too. I have done this also in former times. Only topic is to be aware of the side effects :-)
ASKER
Thanks jerrith.
You'r' welcome :-)
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