How to authenticate user by using active directory group(s)? RRS feed

  • Question

  • User-1795253164 posted

    I have a C# ASP.NET 4.0 web site and would like to limit access to the web site to users in one or more active directory groups.  I have been able to configure my web.config so that only users with a valid active directory user names and passwords can access the web site but I have not been able to figure out how to limit access to users in an active directory group or groups.  I'm using Visual Studio 2010.  I've done Google searches for the last several days have have only found complex code samples of how to perhaps get this to work.  I don't understant why Microsoft hasn't made this simple to implement.  Seems like it should only require relatively simple changes to the web.config file.  Is it possible to get this authentication to work by only making changes to the web.config file?  Somebody please enlighten me on why Microsoft has made this so difficult to do.  I would appreciate any help or advice on the easiest way to implement this authentication.  Thanks!

    Tuesday, January 20, 2015 7:36 PM


  • User-1151753377 posted

    Hi mkhuebner9,

    Thank you for your post.

    According to your descritpion. I konw you want to authenticate user by using active directory group.

    As far as I know, I think you could try to use the below method and have a try.

    private void LoadSourceAccessContextInfo()
        if (Context.User.IsInRole("ActiveDirectory"))
            //Do something
            Response.Redirect("./NoAccess.html", true);

    More further information please refer to the link below.


    Best regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 10:14 PM