locked
Username and password in Controller RRS feed

  • Question

  • User982203039 posted

    How can I use the below code, without using a password, or is it OK to have this information in the controller? I have created a page to do some AD updates which work fine, just want to make sure this is the best way to do it?

    PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "Domain.local", "User", "Password");

    Thanks,

    EB

    Monday, August 26, 2019 8:02 PM

Answers

  • User665608656 posted

    Hi Baze,

    How can I use the below code, without using a password, or is it OK to have this information in the controller?

    If you have used windows authentication in your web.config, you can use the PrincipalContext without password to get information.

    You can refer to this link : Accessing Active Directory Records Via ASP.NET

    PrincipalContext Class

    Here is my result when using PrincipalContext :

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 27, 2019 9:37 AM