Solved

For my Intranet web application, how to limited only certain authenticated users and user gruops?

Posted on 2015-01-06
6
215 Views
Last Modified: 2015-01-06
Hi, I'm using VS2012, asp.net, C# and IIS 7
in my web.config file, I want to limit my userid and a user group(AD Security group), and then deny all other users. Running in debug mode from my VS at my local PC gives me access deny error.  Please advise what could be the error here, thank you.

   <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
      </namespaces>
    <controls><add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" /></controls></pages>
    <authentication mode="Windows">        
    </authentication>
    <authorization>
      <allow users="myUserId"/>
      <allow roles="adUserGroup"/>
      <deny users="*"/>
    </authorization>
    <profile defaultProvider="DefaultProfileProvider">
0
Comment
Question by:lapucca
  • 3
  • 3
6 Comments
 
LVL 23

Expert Comment

by:Michael74
ID: 40534500
IN System.Web set

<authentication mode="Windows"/>

and then you can add the authorisation section eg

<authorization>
  <allow users="domain\myUserId" />
  <allow roles="domain\adUserGroup" />
  <deny users="*" />
</authorization>

for more information have a look at

http://msdn.microsoft.com/en-us/library/ff647405.aspx
0
 

Author Comment

by:lapucca
ID: 40534571
I got error as below. Is there a certain way that I need to set IIS for this site?  But I'm running it from my local PC, VS.


Server Error in '/' Application.
--------------------------------------------------------------------------------


 Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

Error message 401.2.: Unauthorized: Logon failed due to server configuration.  Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server.  Contact the Web server's administrator for additional assistance.


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
0
 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
ID: 40534597
For testing you can
enable NTLM authentication by right-clicking the name of your project in the Solution Explorer window and selecting Properties. Next, select the Web tab and check the NTLM checkbox

http://www.asp.net/mvc/overview/older-versions-1/security/authenticating-users-with-windows-authentication-cs

For a production website you do set IIS to use Windows Authentication for the site

Open IIS Manager and navigate to the level you want to manage.
On the Authentication page, select Windows Authentication.
In the Actions pane, click Enable to use Windows authentication.
http://technet.microsoft.com/en-us/library/cc754628(v=ws.10).aspx
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:lapucca
ID: 40534618
Awesome!  That worked! Do I need to remove the NTLM check when deploying to Production?  Thank you.
0
 
LVL 23

Expert Comment

by:Michael74
ID: 40534631
No this only applied to local web server used during testing. When deploying it to production this is when you will set up windows authentication in IIS
0
 

Author Closing Comment

by:lapucca
ID: 40534653
Very awesome!  Thank you.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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