none
Authentication using active directory RRS feed

  • Question

  • Hi all,

    I am hoping someone can help me. Basically I am unsure exactly how to provide windows authentication to a website.

    Here is a sample of the code:

                HttpWebRequest httpRequest = (HttpWebRequest)
                    WebRequest.Create("testWeb");
                httpRequest.Credentials = CredentialCache.DefaultCredentials;
                httpRequest.Method = WebRequestMethods.Http.Get;
    
                HttpWebResponse httpResponse
                    = (HttpWebResponse)httpRequest.GetResponse();
                Stream httpResponseStream = httpResponse.GetResponseStream();

    So my company has an AD and the above works fine when using the VPN because it can cache the windows credentials. But this is only when using the VPN not all end users have access to this.

    Is there another way I can do this? I am unsure of how to find a solution for this.

    Please note I do have control over the website in question but I do not want to use basic authentication. IIS is currenctly configured to only use windows authentication.

    If relevant all end users have Windows 10 and my company uses office 365 & Azure.

    Thanks for the help.

    Wednesday, October 9, 2019 10:20 PM

All replies

  • Sorry one more point if relevant I am creating a WPF app
    Wednesday, October 9, 2019 10:38 PM
  • Hi SargeLY,

    >So my company has an AD and the above works fine when using the VPN because it can cache the windows credentials. But this is only when using the VPN not all end users have access to this.
    Is there any error message when users don't use VPN to access the website? How did you configure your Web.config file? Did you authorize the domain in your controller? 

    Best regards

    Daisy  Tian


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 10, 2019 9:43 AM
  • Hi Daisy Tian,

    Thanks for the reply.

    So web config is set to use Windows Authentication only. ASP.Net Impersonation, basic etc are all disabled.

    When you say authorize the domain in my controller... do you mean server side? If so I haven't set anything specific up, the server has access to the domain controller and can validate credentials.

    Many thanks

    Thursday, October 10, 2019 8:33 PM
  • Hi all,

    I am hoping someone can help me. Basically I am unsure exactly how to provide windows authentication to a website.

    Here is a sample of the code:

                HttpWebRequest httpRequest = (HttpWebRequest)
                    WebRequest.Create("testWeb");
                httpRequest.Credentials = CredentialCache.DefaultCredentials;
                httpRequest.Method = WebRequestMethods.Http.Get;
    
                HttpWebResponse httpResponse
                    = (HttpWebResponse)httpRequest.GetResponse();
                Stream httpResponseStream = httpResponse.GetResponseStream();

    So my company has an AD and the above works fine when using the VPN because it can cache the windows credentials. But this is only when using the VPN not all end users have access to this.

    Is there another way I can do this? I am unsure of how to find a solution for this.

    Please note I do have control over the website in question but I do not want to use basic authentication. IIS is currenctly configured to only use windows authentication.

    If relevant all end users have Windows 10 and my company uses office 365 & Azure.

    Thanks for the help.

    Hi    SargeLY,

    Your issue is more related to the Http request and Authentication. So, I suggest you can go to the ASP.net forum for getting suitable.


    Thank you for your understanding.


    Best regards

    Yong Lu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 22, 2019 8:07 AM