Solved

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

Posted on 2015-01-06
6
221 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: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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

710 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