| HOME NEWS TESTIMONIALS CONTACT | |
|
OWA FOR PDA OWA FOR WAP BUY ONLINE DOWNLOADS |
|
|
Block Or Allow Selected Users Depending On Location In Microsoft Outlook Web Access 2007
Occasionally, someone will ask if it is possible to block or allow certain users from using OWA depending on their location. For example, is it possible to only allow certain users access if they are on the LAN, but not from the Internet? There is currently no built-in way of doing this, but it's possible if you are prepared to make a small change to one of the .aspx pages. Note: this only works with the Premium GUI (i.e. Internet Explorer). Let me know if you really need something for non-IE users, and I'll try to think of something.
First, locate the startpage.aspx file
in <%@ Import Namespace="Microsoft.Exchange.Clients.Owa.Premium.Controls" %>Immediately after it, insert a block of code, like this:
<%
string strIP = Request.ServerVariables["REMOTE_ADDR"];
if(strIP.Substring(0, 8) != "192.168.")
{
string strUser = Request.ServerVariables["REMOTE_USER"].ToUpper();
int p = strUser.IndexOf("\\");
if(p != -1)
strUser = strUser.Substring(p + 1);
Boolean blnFound = false;
if(
(strUser == "USER1")
|| (strUser == "USER2")
)
blnFound = true;
if(!blnFound)
{
Response.Write("Sorry, you are not allowed to access OWA from this location");
Response.End();
}
}
%>
There are a few things to note in this code.
In the third line, a check is made on the IP address of the client.
In this example, the server is checking to see if the IP
address begins with "192.168." (i.e. it is within the private IP
addressing range 192.168.x.x . If your addressing scheme is different (e.g.
you use something beginning with 10.), you will need to change this line.
The second number passed to the .Substring function must match the
number of digits you are checking.
The second thing to note is the list of user names:
if(
(strUser == "USER1")
|| (strUser == "USER2")
)
this will obviously be different for you.
I have formatted it so that you can easily add lines
for extra permitted users by inserting something like:
|| (strUser == "USER3")
|| (strUser == "USER4")
inserted lines must begin with || (the c sharp OR operator),
and they must come before the final closing bracket at the end of the list.
The last thing to note is that this is a list of permitted users. To make it a list of blocked users, change the line
if(!blnFound)
to
if(blnFound)
As with most of these type of modifications, you will need to check that they still function after each product update. Sometimes your modified file will be replaced by a new one from the update.
|
| Copyright © 2003 - 2010 Lee Derbyshire. All rights reserved. | |