Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9225613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:37:21+00:00 2026-06-18T04:37:21+00:00

I am currently trying to create a website that authenticates users against AD but

  • 0

I am currently trying to create a website that authenticates users against AD but I cannot seem to find a good resource for examples. To start with I would just like to give all AD users access to the site. I have a Windows 2008 r2 server running IIS and Active Directory roles for testing purposes.

I know that you must add a connection string as shown in ASP.NET MVC – Authenticate users against Active Directory, but require username and password to be inputted. But some sort of example showing models, views and controllers as well as the web.config file would help greatly.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:37:22+00:00Added an answer on June 18, 2026 at 4:37 am

    I’m going to go ahead and answer since I’m doing precisely this on our company’s internal web app and if I’m doing it wrong, this is how I’m going to find out.

    When the user comes to your web site, you’ll have UserPrincipal.Current.SamAccountName. So all you need to do is something like this:

    DirectoryEntry de = new DirectoryEntry("LDAP://" + adDomain);
    DirectorySearcher ds = new DirectorySearcher(de);
    ds.Filter = "(sAMAccountName=" + UserPrincipal.Current.SamAccountName + ")";
    ds.PropertiesToLoad.Add("cn");
    ds.PropertiesToLoad.Add("name");
    ds.PropertiesToLoad.Add("mail");
    SearchResult sr = ds.FindOne();
    if (sr == null)
    {
        // not found
    }
    ...
    

    So if you don’t get a SearchResult returned, they wouldn’t be authenticated against your AD domain… Hope I’m doing it right 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a website that allows users to login with their Facebook
I'm currently trying to create a program that estimates location based on signal strength.
I am currently trying to create an Android application that loops Audio from the
I am currently trying to create a site that filter the content based on
Currently I'm trying to create some coding short cuts for our website. Right now
I'm currently trying to build a personal website to create a presence on the
I am currently trying to get some statistics for my website but i cant
I am trying to create a login form on my ASP.NET website. Currently, there's
I've been trying to find example of EF per request patterns. I currently create
I'm currently trying create a service that will return results of a OLAP cube

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.