Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2015-01-06
6
Medium Priority
?
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 23

Expert Comment

by:Michael Fowler
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:
Michael Fowler earned 2000 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
TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

 

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:Michael Fowler
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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