Wireless Access

Reply
New Contributor

Error Handling on Custom Captive Portal pages

Hello All,

 

I'm having some issues getting Error Messages to display when using Custom Captive Portal pages on the Aruba Controller. We are currently running 6.4.2.4 code on our 7030 controller. I have copied the sample error handling code from the Aruba User Guide however I cannot seem to get it to work. The user guide also makes reference to the error messages being past in the URL however I am not seeing that done when using a custom page.

 

Below is a simplified version HTLM code I am using for our custom portal page. If anyone has any suggestions on how to get this working it would be greatly appreciated. Alternatively if anyone has any examples of a functioning custom portal page working with error handling that would be welcomed as well.

 

Thanks!

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Wireless Authentication</title>
<link rel="stylesheet" type="text/css" href="css/style.css">

<STYLE type=text/css>
body{
    margin-top:10px;
    padding:0px;
    font-family: Arial;
    background-color: #A4A4A4;
    color:#FFFFFF;
    }

#container{
    padding-top:10px;
    margin-top:20px;
    text-align:center;
    width: 400px;
    margin-left:auto;
    margin-right:auto;
}

h1{
    font-size: 48px;
    margin-left:7px;
    margin-right:7px;
    margin-top:5px;
    margin-bottom:5px;
    padding-bottom:5px;
    padding-top:5px;
    color:#FFFFFF;
    }
</style>
<script language="javascript" type="text/javascript">

{
function createCookie(name,value,days)
{

           if (days)
           {
                       var date = new Date();
                       date.setTime(date.getTime()+(days*24*60*60*1000));
                       var expires = "; expires="+date.toGMTString();
           }

           else var expires = "";
           document.cookie = name+"="+value+expires+"; path=/";
}
 var q = window.location.search;
 var errmsg = null;


  if (q && q.length > 1) {
   q = q.substring(1).split(/[=&]/);
   for (var i = 0; i < q.length - 1; i += 2) {
     if (q[i] == "errmsg") {
       errmsg = unescape(q[i + 1]);
         break;
     }

       if (q[i] == "host") {     
         createCookie('url',unescape(q[i+1]),0)
       }
   }
 }
  if (errmsg && errmsg.length > 0) {
   errmsg = "<div id='errorbox'>\n" + errmsg + "\n</div>\n";
   document.write(errmsg);
 }
}
</script>
</head>
<body>
<div id="container" >
    <div id="title"><H1>Company WiFi</H1></div>
    <p>Enter your username and password to connect to the wireless network.</p>
    
    <form action="login" id="regform" method="post" autocomplete="off" title="Form used by registered users to login">
            Username
            <br/>
                 <input type="text" name="user" id="user" size="30" class="text" accesskey="u" />
                 <br />
                 <br />
            Password
            <br/>    
            <input id="password" name="password" type="password" size="30" class="text" accesskey="p" />
                 <br />
                 <br />
                 <input type="hidden" name="cmd" value="authenticate" />
                <input type="submit" name="Login" value="Log In" class="button" />
                 <br />
                 <br />
                 By clicking the login button you are explicitly accepting the usage agreement.   
    </form>    
</div>

</body>
</html>

 

 

 

New Contributor

Re: Error Handling on Custom Captive Portal pages

I was able to solve my issue with error handling on the Aruba Controller Custom Captive Portal. Below is a very basic working sample I used on a Aruba 7030 controller running 6.4.2.4 code.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Wireless Authentication</title>
<STYLE type=text/css>
body{
    margin-top:10px;
    padding:0px;
    font-family: Arial;
    background-color: #A4A4A4;
    color:#444444;
    }

#container{
    padding-top:10px;
    margin-top:20px;
    text-align:center;
    width: 80%;
    margin-left:auto;
    margin-right:auto;
}
#errorbox{
 color:#FFFFFF;
 background-color:red;
 padding:3px;
 margin-left:auto;
 margin-right:auto;
 width: 80%;
}

h1{
    font-size: 48px;
    margin-left:7px;
    margin-right:7px;
    margin-top:5px;
    margin-bottom:5px;
    padding-bottom:5px;
    padding-top:5px;
    color:#FFFFFF;
    }

</style>
<script language="javascript" type="text/javascript">
 
function errorcheck(url){
 var errormessage = "None";
 org_url = url;

 if(url.search(/errmsg=Authentication%20failed/i)>0) {
  errormessage = "Login failed, please check your details and try again";

 }else if (url.search(/errmsg=Access%20denied/i)>0) {
  errormessage = "Access Denied, please check your details and try again";
 }else if (url.search(/errmsg=/i)>0) {
  errormessage = org_url.match(/(errmsg=.*?&)|(errmsg=.*$)/i)[0];
  errormessage = errormessage.replace(/(errmsg=)|&/g,"");
  errormessage = errormessage.replace(/%20/g," ");

 }else{
  errormessage = "None";
 }
  
 return errormessage;
}
 </script>
</head>
<body>
<div id="container" >
    <div id="title"><H1>Company WiFi</H1></div>
    <p>Enter your username and password to connect to the wireless network.</p>
   
<form ACTION="/auth/index.html/u id="regform" method="post" autocomplete="off" title="Form used by registered users to login">
 
<script>
 errormessage = errorcheck(document.URL);
 if(errormessage != "None"){
  error = "<div id='errorbox'>\n"+ errormessage + "\n</div>\n" + "<br />";
  document.write(error);
 }
</script>
   Username
   <br/>
           <input type="text" name="user" id="user" size="30" class="text" accesskey="u" />
     <br />
     <br />
   Password
   <br/> 
   <input id="password" name="password" type="password" size="30" class="text" accesskey="p" />
     <br />
     <br />
     <input type="hidden" name="cmd" value="authenticate" />
   <input type="submit" name="Login" value="Log In" class="button" />
     <br />
     <br />
     By clicking the login button you are explicitly accepting the usage agreement.
</form> 
  
</div>

</body>
</html>

Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: