Hello,
I need a help with some code: In our application if a User logged in
ONLY with two specific roles assigned on his user name (or either one
of those two) than give a warning.
In case Else if user has many roles including those two it is ok to
proceed with the rest of the logic.
Any help with the code would be appreciated.
Thanks,
Brian |
Request for Question Clarification by
hammer-ga
on
21 Jan 2003 04:39 PST
Are you just looking for help on the logic, or do you also need to
determine what roles are assigned to a particular User?
- Hammer
|
Clarification of Question by
rbrian2-ga
on
21 Jan 2003 06:40 PST
Hi Hammer,
I need help with both. These two roles are belong to another
application for login, but they must be created in our application
(both applications sharing the same logic for login). The purpose of
my request is - if acidentally the user was assigned ONLY those two
roles and tries to login in our application (instead of another
application), the warning message will be issued. If the user was
assigned other roles among with these two - it is Ok.
|
Request for Question Clarification by
hammer-ga
on
21 Jan 2003 07:21 PST
Then I need to know how we get "our application" to tell me what roles
have been assigned. I can write the logic for this, but I have no idea
where your app keeps these roles or how to ask for them, in order to
compare them to anything else.
- Hammer
|
Clarification of Question by
rbrian2-ga
on
21 Jan 2003 07:25 PST
Hammer,
I am going to send you some code and explanation. Give me a little bit time.
|
Clarification of Question by
rbrian2-ga
on
21 Jan 2003 08:08 PST
Hammer,
Here is the some explanations and examples of logic. If you need any
additional info, please ask.
We open recordsets (class module) and then do SELECT on tables in
Oracle.
I have included all declarations in one place, so dont take me wrong
:)
1. Login logic (example how we do checking for roles)
2. Further in another function there is a code, where we open
recordset, do select on table( similar to this).
That function proceeds to open screens. There I need to include
checking for those two roles
(example: If user has ONLY those 2 roles then
give a warning
exit application
Else proceed with the existing logic above
Set rsMain = New clsRS
On Error GoTo ErrorDB
rsMain.Query "SELECT * FROM tbl1
..
If Not rsMain.EOF Then
.
End If
Private Sub cmdLogin_Click()
Dim sRoles As String
Dim sRole As String
Dim rsTerminal As clsRS
Dim rsUser As clsRS
Dim rsRoles As clsRS
Dim a as Integer
Public gsTerminalRoles(100) As String
Public gcTerminalRoles As New Collection
Public gsUserRoles(100) As String
Public gsRoles(100) As String
Public gcUserRoles As New Collection
Dim iTerminalCnt, iRoleCnt
Checking terminal roles
Set rsTerminal = New clsRS
rsTerminal.Query "select roles from tblRoles
.
If rsTerminal.RecordCount <= 0 Then
MsgBox "No roles for this terminal
Unload Me
Exit Sub
Else
sRoles = Trim(rsTerminal.FldValue("roles")) + ","
rsTerminal.Movefirst
a = 1
Do While Len(sRoles) > 0
b = InStr(sRoles, ",")
sRole = UCase(Trim(Left(sRoles, b - 1)))
sRoles = Trim(Mid(sRoles, b + 1))
gsTerminalRoles(a) = sRole
gcTerminalRoles.Add sRole, sRole
a = a + 1
Loop
iTerminalCnt = a - 1
End If
rsTerminal.CloseRS
Set rsTerminal = Nothing
Checking granted roles
Set rsRoles = New clsRS
rsRoles.Query "select granted_role from tblUser privs"
If rsRoles.RecordCount > 0 Then
rsRoles.Movefirst
Do While rsRoles.EOF <> True
If Left(rsRoles.FldValue("granted_Role"), 3) =
"CC_" Then
gsUserRoles(a) =
rsRoles.FldValue("granted_Role")
sRoles = rsRoles.FldValue("granted_Role")
gcUserRoles.Add
rsRoles.FldValue("granted_Role"), rsRoles.FldValue("granted_Role")
a = a + 1
End If
rsRoles.Movenext
Loop
iUserCnt = a - 1
End If
rsRoles.CloseRS
Set rsRoles = Nothing
For Each v In gcTerminalRoles
If Is_Member(v, gcUserRoles) Then
gsRoles(iRoleCnt) = gcUserRoles(v)
iRoleCnt = iRoleCnt + 1
End If
Next v
iRoleCnt = iRoleCnt - 1
If iRoleCnt <= 0 Then
MsgBox "Combined user and terminals do not allow
access...terminating.
Unload Me
Exit Sub
End If
|