Skip to content

ASP.NET MVC 5 windows authentication

tola Ibironke

Asked Sep 26, 2014, 6:26 AM EDT2 answers
Share
LinkedInX
 I want to get the user domain name, username, login and password from Active Directory in my organization intranet.

Here is my web config file:


<system.web>
    <authentication mode="Windows"></authentication>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>


HERE IS MY INDEX ACTION
public ActionResult Index()
        {
            var requestContext = new RequestContext();      
    string ntLogin = requestContext.HttpContext.User.Identity.Name


}

HERE IS THE ERROR I GET:

Object reference not set to an instance of an object.


What is it that I'm doing wrong. I want to get the user login and password from Active Directory in my organization intranet. What do I need to do next. Please help out.

Thanks

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    ok 
    view page also show ..
    after tell this answer 
    0
  • 0
    The user does not need a view page to login. The user will use windows login and I will read the login details from the window active directory to authenticate the user. No view is needed. Hence I'm using windows authentication and not forms authentication.
    0