close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple Restrict access not working

Thread began 11/01/2019 6:45 am by Michael | Last modified 11/05/2019 12:39 pm by Ray Borduin | 26 views | 3 replies |

Michael

Multiple Restrict access not working

Hi Support,

In DW, I can set this $MM_authorizedUsers = "Administrator,Operator"; and it will work but I tried doing it using your MySQLi Server Behaviors as seen below but it didn't work. Why please???

<?php
if ("" === "") {
$RestrictAccess = new WA_MySQLi_Auth();
$RestrictAccess->Action = "restrict";
$RestrictAccess->Name = "Administrator,Operator";
$RestricAccessRedirect = "errorlogin.php";
if (function_exists("rel2abs")) $RestricAccessRedirect = $RestricAccessRedirect?rel2abs($RestricAccessRedirect,dirname(__FILE__)):"";
$RestrictAccess->FailRedirect = $RestricAccessRedirect;
$RestrictAccess->execute();
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

This has to be done a little differently with our extensions. Advanced page access rules are only available in Databridge, but I see you don't own that product.

The easiest solution (if you don't own DataBridge) is to save the same session variables that Dreamweaver login uses so that you can use the old restrict access server behavior based on user group.

They use:
MM_Username and MM_UserGroup

You can add those variable names to the list of saved columns in your login (it doesn't matter which column you use for MM_Username, but save the access group column as MM_UserGroup).

Then you can just use the Adobe Restrict Access to Page server behavior to do access group based page access.

Sign in to reply to this post

Michael

Originally Said By: Ray Borduin
  This has to be done a little differently with our extensions. Advanced page access rules are only available in Databridge, but I see you don't own that product.

The easiest solution (if you don't own DataBridge) is to save the same session variables that Dreamweaver login uses so that you can use the old restrict access server behavior based on user group.

They use:
MM_Username and MM_UserGroup

You can add those variable names to the list of saved columns in your login (it doesn't matter which column you use for MM_Username, but save the access group column as MM_UserGroup).

Then you can just use the Adobe Restrict Access to Page server behavior to do access group based page access.  





If I understand you sir, do you mean I should the following

1. Restrict access to using Adobe Restrict Access as seen below

<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "SuperAdmin,Administrator";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "errorlogin.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>


2. Add those variable names (which are: MM_Username and MM_UserGroup) to the list of saved columns in your login as seen below

<?php
$Authenticate = new WA_MySQLi_Auth($DBMS);
$Authenticate->Action = "authenticate";
$Authenticate->Trigger = ($_SERVER["REQUEST_METHOD"] === "POST");
$Authenticate->Name = "Administrator";
$Authenticate->Table = "admin_login";
$Authenticate->addFilter("user_name", "=", "s", "".((isset($_POST["user_name"]))?$_POST["user_name"]:"") ."");
$Authenticate->addFilter("password", "=", "s", "".((isset($_POST["password"]))?md5($_POST["password"]):"") ."");
$Authenticate->addFilter("level", "=", "s", "".((isset($_POST["level"]))?$_POST["level"]:"") ."");
$Authenticate->storeResult("MM_Username", "MM_Username");
$Authenticate->storeResult("password", "password");
$Authenticate->storeResult("MM_UserGroup", "MM_UserGroup");
$Authenticate->RememberMe = (false);
$Authenticate->SaveLogin = (true);
$Authenticate->AutoReturn = false;
$SuccessRedirect = "dashboard.php";
$FailedRedirect = "errorlogin.php";
if (function_exists("rel2abs")) $SuccessRedirect = $SuccessRedirect?rel2abs($SuccessRedirect,dirname(__FILE__)):"";
if (function_exists("rel2abs")) $FailedRedirect = $FailedRedirect?rel2abs($FailedRedirect,dirname(__FILE__)):"";
$Authenticate->SuccessRedirect = $SuccessRedirect;
$Authenticate->FailRedirect = $FailedRedirect;
$Authenticate->execute();
?

Kindly advice please.

Thank you so much

Sign in to reply to this post

Ray BorduinWebAssist

This code should have the session variable name and the corresponding column name.

$Authenticate->storeResult("MM_Username", "MM_Username");
$Authenticate->storeResult("password", "password");
$Authenticate->storeResult("MM_UserGroup", "MM_UserGroup");

so it should be something like:
$Authenticate->storeResult("user_name", "MM_Username");
$Authenticate->storeResult("user_group", "MM_UserGroup");

I'm guessing your user group column name, but the point is that the column name is first and then the session variable name it is stored as.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...