Solved

Modifing the Exchange owa error.aspx

Posted on 2011-09-21
7
2,371 Views
Last Modified: 2012-05-12
Hi,

I would like to modify the "auth/error.aspx" for the exchange owa 2010 to do something special for one or two of the errors that can be returned to the aspx.

Below is the error.aspx.

I do not know enough about what would need to be changed in the code to do two things.

1.  Report the error exact error number to the user page so I can then set a redirect if that error occurs
2. Then set the redirect if that error occurs in the error.aspx

Could I ask for help on how to code this.

I attach the content of the aspx file.

Thanks
<%@ Page language="c#" Codebehind="Error.aspx.cs" AutoEventWireup="false" Inherits="Microsoft.Exchange.Clients.Owa.Core.Error" %>
<%@ Import Namespace="Microsoft.Exchange.Clients" %>
<%@ Import Namespace="Microsoft.Exchange.Clients.Owa.Core" %>
<%@ Import Namespace="Microsoft.Exchange.Clients.Owa.Premium" %>
<!-- {698798E9-889B-4145-ACFC-474C378C7B4F} -->
<html dir="<%=(SessionContext != null && SessionContext.IsRtl) ? "rtl" : "ltr"%>">

<% 	// Any urls to resources in this file, must be absolute urls.  The error page can load as a response to any request
	// made by the client, since it does by an internal redirect on the server and not as a 302 issued to the client.  
	// Therefore, there is no way of knowing where a relative url will take you.  For example, this page can load as a 
	// result of this request "http://servername/owa/auth/logon.aspx" or this request 
	// "http://servername/owa/ev.owa?oeh=1&ae=dostuff"
	//	
%>

<head>
	<meta http-equiv="Content-Type" content="text/html; CHARSET=utf-8">
	<title><%= LocalizedStrings.GetHtmlEncoded(Strings.IDs.ErrorTitle) %></title>
	<link type="text/css" rel="stylesheet" href="<%=ResourcePath%>14.1.287.0/themes/base/premium.css">
	<link type="text/css" rel="stylesheet" href="<%=ResourcePath%>14.1.287.0/themes/resources/<%= Utilities.GetDefaultCultureFontCssFileUrl(OwaContext) %>">
	<style>
		<% if (Utilities.IsViet()) { %>
			body, html
			{
				font-family:Helvetica, Tahoma !important;
			}
		<% } %>
	</style>
	
	<% if (ShowSendReport || RedirectForFailover)
	{ %>
		<script type="text/javascript">
		<% Utilities.RenderOWAFlag(Response.Output); %>
		</script>
		<script type="text/javascript" src="14.1.287.0/scripts/premium/uglobal.js"></script>
		<script type="text/javascript">

		<% if (ShowSendReport) { %>
				<% RenderingUtilities.RenderCanaryParameters(Response.Output); %>

				<% /* Send error report only for premium */%>
				function rprt()
				{
					var oDivSR = $("divSR");

					oDivSR.detachAllEvents("click");

					var sE = null;
					var rgE = items("exceptionType");

					if (0 < rgE.length)
						sE = Owa.Dom.Node.wrapDomNode(rgE[0]).get_TextContent();
					else
						sE = "no exception";

					var oR = new oeReq("Error", "SendReport", null, cbRprt);
					oR.add("s", "Error Report: " + sE);
					oR.add("b", $("divDtls").get_TextContent());

					$("spnRS").set_TextContent("<%=LocalizedStrings.GetJavascriptEncoded(Strings.IDs.SendingReport)%>");

					var oImgSts = $("imgSts");
					var sSrc = oImgSts.getAttribute("src");

					oImgSts.setAttribute("src", oImgSts.getAttribute("prgrs"));
					oImgSts.setAttribute("prgrs", sSrc);
					oR.send();
				}

				function cbRprt(oR)
				{
					if (oR.sErr)
						$("spnRS").set_TextContent(oR.sErr);
					else
						$("spnRS").set_TextContent("<%=LocalizedStrings.GetJavascriptEncoded(Strings.IDs.ReportSent)%>");

					$("imgSts").setAttribute("src", $("imgSts").getAttribute("prgrs"));
				}
			<% } %>
			
			<% if (RedirectForFailover) { %>
			window.onload = function window$onload()
			{
				var oSpRedir = document.getElementById("spRedirUrl");
				if (oSpRedir)
				{
					setFlrReTimer(
						(typeof(oSpRedir.textContent) == "undefined") ? oSpRedir.innerText : oSpRedir.textContent);
				}
			}
			<% } %>
		</script>
	<%}%>
</head>
<body id="errorAspx" class="err">
<% if (SessionContext != null && !SessionContext.IsProxy && SessionContext.IsBasicExperience){ %>
<table id="tblErr" cellspacing=0 cellpadding=0>
	<tr>
		<td>
			<table cellpadding=0 cellspacing=0>
				<tr>
					<td align="center" valign="middle"><img src="<% Microsoft.Exchange.Clients.Owa.Basic.RenderingUtilities.RenderOwaBasicLogo(Response.Output, SessionContext); %>"></td>
					<td class="w100"></td>
					<% if (ErrorInformation.ShowLogoffAndWorkButton) { %> 
						<td nowrap id="tdErrLgf"><a href="logoff.owa?canary=<% Utilities.HtmlEncode(Utilities.UrlEncode(Utilities.GetCurrentCanary(SessionContext)), Response.Output); %>"><%= LocalizedStrings.GetHtmlEncoded(Strings.IDs.LogOff) %></a></td>
					<% } %>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table class="w100" cellpadding=0 cellspacing=0>
				<tr>
					<td><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.CornerTopLeft); %>"></td>
					<td id="tdErrHdTp"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
					<td><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.CornerTopRight); %>"></td>
				</tr>
				<tr>
					<td colspan=3 id="tdErrHdCt">
						<div class="errHd" id="errMsg"><b><% RenderError(); %></b></div>
					<% if (SessionContext is UserContext && ErrorInformation.ShowLogoffAndWorkButton && !RedirectForFailover) { %>
						<div class="errHd"><a href="<%= UserContext.LastClientViewState.ToQueryString() %>"><%= LocalizedStrings.GetHtmlEncoded(Strings.IDs.ErrorClickToContinueWorking)%></a></div>
					<% } %>
<% if (HasErrorDetails){ %>
						<div>
							<table id="tblErrHdDsc">
								<tr>
									<td><img src="<% Response.Write(ResourcePath); RenderIcon(); %>"></td>
									<td class="w100" id="errDt"><% RenderErrorDetails(); %></td>
								</tr>
							</table>
						</div>
<% } %>
					</td>
				</tr>
				<tr>
					<td colspan=3 class="errHk"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td id="tdErrDbg">
<% } else { %>
<table class="errDesc" style="margin-top:24px"> <% /*The margin-top here is a hack so that the error string doesn't cover the notification bar. This would be fixed once we change the IFrame layout*/ %>
<tr>
	<td style="width:1%"><img src="<%=ResourcePath%><%RenderIcon();%>"></td>
	<td id="errMsg"><% RenderError(); %></td>
</tr>
<% if (HasErrorDetails) { %>
<tr>
	<td id="errDt" colspan=2>
		<% RenderErrorDetails(); %>
		<% if (IsExternalLinkPresent) { %>
			<br><% RenderExternalLink(); %><br>
		<% } %>
	</td>
</tr>
<% } else  if (!HasErrorDetails && IsExternalLinkPresent) { %>
<tr>
	<td id="errDt" colspan=2><% RenderExternalLink(); %></td>
</tr>
<% } %>
</table>
<hr class="line" size="2">
<% } %>
<% if (ShowDebugInformation) { %>
	<% if (!IsDownLevelClient) { %>
		<% if (ShowSendReport) { %>
			<div class=act onclick="rprt()" id=divSR>
				<img id=imgSts src="<%=ResourcePath%>14.1.287.0/themes/basic/send.gif" 
				prgrs="<%=ResourcePath%>14.1.287.0/themes/base/pgrs-sm.gif"> 
				<span id=spnRS><%=LocalizedStrings.GetHtmlEncoded(Strings.IDs.SendReport)%></span>
			</div>
		<%}%>
		<% if (Utilities.GetBrowserType(OwaContext.HttpContext.Request.UserAgent) == BrowserType.IE) { %>
			<div class=act onclick="window.clipboardData.setData('Text', document.getElementById('divDtls').innerText)"><img src="<%=ResourcePath%>14.1.287.0/themes/resources/copy.gif"> <%=LocalizedStrings.GetHtmlEncoded(Strings.IDs.CopyErrorDetails)%></div>
		<%}%>
	<%}%>

	<div class=act onclick="document.getElementById('divDtls').style.display='';this.style.display='none';"><img src="<%=ResourcePath%>14.1.287.0/themes/resources/expnd.gif"> <%=LocalizedStrings.GetHtmlEncoded(Strings.IDs.ShowDetails)%></div>
	<br>
	<div id=divDtls style="display:none"><% RenderDebugInformation(); %></div>
<% } %>
<% if (SessionContext != null && !SessionContext.IsProxy && SessionContext.IsBasicExperience){ %>
		</td>
	</tr>
	<tr>
		<td>
			<table class="w100" cellpadding=0 cellspacing=0>
				<tr>
					<td colspan=3 class="errHk"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
				</tr>
				<tr>
					<td colspan=3 id="tdErrFtCt"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
				</tr>
				<tr>
					<td><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.CornerBottomLeft); %>"></td>
					<td id="tdErrFtBt"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
					<td><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.CornerBottomRight); %>"></td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<% } %>
</body>
</html>

Open in new window

0
Comment
Question by:PeterSinger
  • 5
  • 2
7 Comments
 
LVL 4

Author Comment

by:PeterSinger
ID: 36577138
Attached is the source of the message that the user does get that I wnat to work with.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Copyright (c) 2006 Microsoft Corporation.  All rights reserved. -->
<!-- OwaPage = ASP.auth_error_aspx -->

<!-- {698798E9-889B-4145-ACFC-474C378C7B4F} -->
<html dir="ltr">



<head>
	<meta http-equiv="Content-Type" content="text/html; CHARSET=utf-8">
	<title>Error</title>
	<link type="text/css" rel="stylesheet" href="/owa/14.1.287.0/themes/base/premium.css">
	<link type="text/css" rel="stylesheet" href="/owa/14.1.287.0/themes/resources/owafont.css">
	<style>
		
	</style>
	
	
</head>
<body id="errorAspx" class="err">

<table class="errDesc" style="margin-top:24px"> 
<tr>
	<td style="width:1%"><img src="/owa/14.1.287.0/themes/base/warn.png"></td>
	<td id="errMsg">A mailbox couldn't be found for PROD\Username. If the problem continues, contact your helpdesk.</td>
</tr>

</table>
<hr class="line" size="2">

			<div class=act onclick="window.clipboardData.setData('Text', document.getElementById('divDtls').innerText)"><img src="/owa/14.1.287.0/themes/resources/copy.gif"> Copy error details to clipboard</div>
		

	<div class=act onclick="document.getElementById('divDtls').style.display='';this.style.display='none';"><img src="/owa/14.1.287.0/themes/resources/expnd.gif"> Show details</div>
	<br>
	<div id=divDtls style="display:none"><br><b>Request</b><br>Url: <span id=requestUrl>https://audcs01mcp08w:443/owa/auth/error.aspx</span><br>User host address: <span id=userHostAddress>10.1.41.121</span><br>OWA version: <span id=owaVersion>14.1.287.0</span><br></div>

</body>
</html>

Open in new window

0
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 36580658
It's a bit tricky, because the error message is produced by compiled code that you can't see.  As you can probably guess, it is produced by the function RenderError(), but it isn't likely that you can get to see the actual error code for yourself.  One thing you might try is to use JavaScript to inspect the text once the page has been sent to the user.  To see if this is likely to work, try adding this just before the </body> tag at the bottom:

<script language="JavaScript">
alert(document.all.errMsg.innerText);
</script>

Hopefully, it will show a popup box with the same error text in it.
0
 
LVL 4

Author Comment

by:PeterSinger
ID: 36583747
Thank you so much for you reply. That did pop up a box with the error
 Error box picture
So could I now jast say if the error contains the words "A mailbox couldn't be found for PROD\ whatever is next" do a refirect to :https://something?

How would I do that with a javaScript?
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 31

Accepted Solution

by:
LeeDerbyshire earned 500 total points
ID: 36586442
Okay, that's good.  I would try replacing the script with:

<script language="JavaScript">
if(document.all.errMsg.innerText.indexOf("A mailbox coudn't be found") != -1)
  window.location = "http://servername/docname.htm";
</script>

use your own URL, of course.
0
 
LVL 4

Author Comment

by:PeterSinger
ID: 36591980
HI. It did not do anything.  Do I need a * or something to get the part of the error?  Also do I need to use an absolute url or can i use https://servernams/dir/

 
0
 
LVL 4

Author Comment

by:PeterSinger
ID: 36592053
<script language="JavaScript">
if(document.all.errMsg.innerText.indexOf("A mailbox couldn\'t be found") != -1)
 window.location = "https://owa.ugllimited.com/owa";
</script>

It needed an escape for the '.

Working now.  Thank you so much :)
0
 
LVL 4

Author Closing Comment

by:PeterSinger
ID: 36592055
Fantastic
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to install and use the NTBackup utility that comes with Windows Server.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now