473,511 Members | 15,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using web config to allow access to domain users only

Hi all,

is it possible to configute an asp .net app using web config, to allow
access to users within a particular domain only?.

Any help is greatly appreciated.

Thanks in advance,

Carlos
Nov 19 '05 #1
4 15296
I think you want the role tag

<authorization>
<allow users="*" allow role="domain\group" />
<deny users="*" />
</authorization>
--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Carlos" <ch******@yahoo.com> wrote in message
news:uY*************@TK2MSFTNGP09.phx.gbl...
Hi all,

is it possible to configute an asp .net app using web config, to allow
access to users within a particular domain only?.

Any help is greatly appreciated.

Thanks in advance,

Carlos

Nov 19 '05 #2
I'm making the assumption that you're using windows Authentication for
your web application.

I would recommend doing this security check in the Application's
AuthorizeRequest event. You can set the domain in an appSetting in your
web.config file. The following code is untested:

Web.config:

<configuration>
<appSettings>
<add key="AuthorizedDomainName" value="Watusi" />
</appSettings>
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
</system.web>
<location path="notauthorized.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
</configuration>

global.asax

void Application_AuthorizeRequest(object sender, EventArgs e)
{
if
(!User.Identity.Name.StartsWith(ConfigurationSetti ngs.AppSettings["AuthorizedDomainName"]
+ "\\")) HttpContext.Current.Response.Redirect("notauthoriz ed.aspx");
}

-Alan
Carlos wrote:
Hi all,

is it possible to configute an asp .net app using web config, to allow
access to users within a particular domain only?.

Any help is greatly appreciated.

Thanks in advance,

Carlos


Nov 19 '05 #3

Alan,

Thank you for your prompt response. When testing the code
I found out that it takes a long time to redirect from within
Application_AuthenticateRequest to the notauthorized page.

Is there any reason for that?

Thanks,

Carlos

"Alan Samet" <al*******@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I'm making the assumption that you're using windows Authentication for
your web application.

I would recommend doing this security check in the Application's
AuthorizeRequest event. You can set the domain in an appSetting in your
web.config file. The following code is untested:

Web.config:

<configuration>
<appSettings>
<add key="AuthorizedDomainName" value="Watusi" />
</appSettings>
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
</system.web>
<location path="notauthorized.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
</configuration>

global.asax

void Application_AuthorizeRequest(object sender, EventArgs e)
{
if
(!User.Identity.Name.StartsWith(ConfigurationSetti ngs.AppSettings["AuthorizedDomainName"]
+ "\\")) HttpContext.Current.Response.Redirect("notauthoriz ed.aspx");
}

-Alan
Carlos wrote:
Hi all,

is it possible to configute an asp .net app using web config, to allow
access to users within a particular domain only?.

Any help is greatly appreciated.

Thanks in advance,

Carlos

Nov 19 '05 #4
That I don't know. An HttpResponse.Redirect sends a header to the
browser requesting that the browser do the redirect. It may be the
browser you're using taking its time to do the redirect; the first
time, of course, you'd have to deal with the delay of the page
compiling. Perhaps the first time the WindowsPrincipal is queried for
the identity it may have to do some kind of domain lookup. I'm not
sure.

-Alan

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4797
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
43
2567
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
1
2111
by: poi | last post by:
I have a Win2K and Win2K web servers with Local Groups that contain domain users and domain groups from a foreign trusted domain. In the web config for the application, the web.config has this: ...
3
1915
by: Sharat Koya | last post by:
Please can you help with a problem I am having. My web config is set to... <authorization><deny users="?"/> <authentication mode="Forms"> <forms name=".COOKIE" loginUrl="login.aspx"...
1
3623
by: Dave | last post by:
We have an intranet application that is under Integrated security. So in theory, anyone who has an Active Directory account in the company can access my app. So, to allow only certain users, I...
9
3417
by: Matt | last post by:
Hello, I'm working on a portal based on IBuySpy, where the main page is desktopdefault.aspx and all content is stored in www.domain.com/content/html/nnn or www.domain.com/content/images/nnn and...
5
16415
by: profdotnet | last post by:
Below is the code of web.config file: <configuration> <system.web> <authentication mode="Forms" /> <authorization> <allow users="Admin"/> <deny users="Jack,Mary" /> <deny users="?">...
3
2608
by: Jay-nospam | last post by:
Hi there, I am having trouble getting an ASP.NET web application to connect to another computer and passing the proper credentials and I hope someone can help me. I have a stand-alone Windows...
1
1480
by: DK | last post by:
I have an intranet application I've built using asp.net 3.5 / running on IIS6 I want to use BUILTIN groups on the server that contain domain users. So I set up my web.config like so for example:...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.