locked
Windows Authentication in Asp.Net RRS feed

  • Question

  • User119800883 posted

    Hi Experts,

    In my Asp.Net intranet application, whenever user open a web site link, I want to get the LoginId of the currently logged user on the client machine and with this LoginId I want to get the emailaddress from AD. I do not want show the window popup. instead I want to pick up the LoginId of client machine and perform further. See the code below. Can you tell me the settings I have to do to make it works.  I made Authentication mode="Windows".

    Thanks in advance

    using (var dssearch = new DirectorySearcher("domainname"))
    {                  
        dssearch.Filter = string.Format("(sAMAccountName={0})", User.Identity.Name.Split('\\')[1]);
    
        var sresult = dssearch.FindOne();
    
        if (sresult != null)
        {
            using (dsresult = sresult.GetDirectoryEntry())
            {
                str = dsresult.Properties["mail"].Value.ToString();
            }
        }
    }
    

    Friday, July 18, 2014 4:46 AM

Answers

  • User-760709272 posted

    http://technet.microsoft.com/en-gb/library/cc754628(v=ws.10).aspx

    Remember also that windows auth doesn't work everywhere, it won't work over the internet and you might have issues when the web server is on a different domain to the client, and the browser has to support it (though I think the major browsers support it on Windows at least).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 18, 2014 10:20 AM

All replies

  • User-802546231 posted

    you need to also disable anonymous authentication

    Friday, July 18, 2014 6:09 AM
  • User119800883 posted

    When I disable anonymous authentication then it shows windows pop up which i do not want.

    Friday, July 18, 2014 8:57 AM
  • User-760709272 posted

    Google how to enable Windows Authentiaction in IIS, there are lots of articles.  If you disable anon access and you get the pop-up, that means you are using basic authentication so your windows auth isn't kicking in.  You're going to have to leave anonymous access disabled in order to use windows auth, but you're also going to have to properly configure it.

    Friday, July 18, 2014 9:11 AM
  • User119800883 posted

    I have tried so many articles but none could provide me the desired settings. I left the anonymous access as disabled but not able to figure out what other settings are required ?

    Friday, July 18, 2014 10:08 AM
  • User-760709272 posted

    http://technet.microsoft.com/en-gb/library/cc754628(v=ws.10).aspx

    Remember also that windows auth doesn't work everywhere, it won't work over the internet and you might have issues when the web server is on a different domain to the client, and the browser has to support it (though I think the major browsers support it on Windows at least).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 18, 2014 10:20 AM