473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 15274
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
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
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
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
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
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
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
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
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
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.