This topic is locked

Handling Group Permissions

7/7/2020 11:05:38 AM
PHPRunner General questions
O
ondra author

Good day All, I have an existing database set up where I am using a linking table dbo.UsersUserTypeId to connect dbo.Users.UserId to dbo.UsersTypes. In this setup a User can belong to many groups. How do I make use of this setup or recreate the same function in PHPrunner?

Thanks in advance for your assistance.

Sergey Kornilov admin 7/7/2020

With Static User Group Permissions this is not possible but with Dynamic User Group Permissions, user may belong to multiple groups.
If you need to use your own permissions tables then you need to code permissions manually. You can read data from your permissions tables after user has logged in and use setPermissions() function to assign permissions for each table: https://xlinesoft.com/phprunner/docs/secapi_set_permissions.htm

O
ondra author 7/8/2020



With Static User Group Permissions this is not possible but with Dynamic User Group Permissions, user may belong to multiple groups.
If you need to use your own permissions tables then you need to code permissions manually. You can read data from your permissions tables after user has logged in and use setPermissions() function to assign permissions for each table: https://xlinesoft.com/phprunner/docs/secapi_set_permissions.htm


After successful login what is in $pageObject

$pageObject - an object of LoginPage class. When logging in as Guest this parameter is NULL
Also

Looking at the example for setting table permissions. For multiple table permissions access would I be using the example

after multiple If statements for each table. If not, do you have a code example of setting permissions for multiple tables.
Manual example: -

$rights = Security::getPermissions("Cars");

$rights["A"] = true;

$rights["D"] = false;

Security::setPermissions("Cars", $rights);
Thanks in advance

Sergey Kornilov admin 7/8/2020

It all depends on how do you store those permissions in your own tables.
There must be some sort of a loop, where you go through all your tables and run this or similar code for each table.

O
ondra author 7/9/2020



It all depends on how do you store those permissions in your own tables.
There must be some sort of a loop, where you go through all your tables and run this or similar code for each table.


Looking at dynamic permissions.

I have an existing database with customers assigned to groups. To link

existing customers to the new security tables created using dynamic

permissions table wizard, can I enter values directly into the data tables

via SSMS? Or is this best done using the browser interface. To put it another

way, how do I connect existing "User" table data to work with the dynamic

permissions algorithm?
Again thanks in advance

Sergey Kornilov admin 7/9/2020

I have an existing database with customers assigned to groups.


Is this something that were created by PHPRunner or something that is completely different. How do you assign users to groups?

O
ondra author 7/9/2020



Is this something that were created by PHPRunner or something that is completely different. How do you assign users to groups?


No this was not created using PHPRunner. I'm using and existing mssql database. I have a Users table, a UserTypes table, that holds the group list, and

a linking table. I current use an insert statement to add to tables. To retrieve the customer groupId I use the following:
Select TypeOfUser

From dbo.UserTypes

INNER JOIN dbo.UsersUserType ON dbo.UserTypes.Id = dbo.UsersUserType.UserTypeId

INNER JOIN dbo. Users ON dbo.UsersUserType.UsersId = dbo.Users.UsersId

Where dbo.Users.UsersId = UsersId

Sergey Kornilov admin 7/9/2020

If you are using your own set of tables to store users, groups and user types - then Dynamic Permissions won't help you much.
In this case you need to revert to the scenario we discussed previously. Based on logged user name you pull a list of groups and a list of permissions from your own tables and do Security::setPermissions() for each table.