How to get password policies from AD in C# RRS feed

All replies

  • Hello,

    Not knowing what has been tried and/or looked at, please look at the following two solutions.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Wednesday, March 25, 2020 2:17 PM
  • Hi Vaidh,
    You can use System.DirectoryServices namespace and it allows to query an AD server directly.
    Here is a simple code example you can refer to.

    using (DirectoryEntry entry = new DirectoryEntry())
        entry.Username = "username";
        entry.Password = "password";
        DirectorySearcher searcher = new DirectorySearcher(entry);
        searcher.Filter = "(objectclass=user)";
        catch (COMException ex)
           // Login or password is incorrect

    More methods you can refer to this thread.
    Best Regards,
    Daniel Zhang

    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

    Thursday, March 26, 2020 8:03 AM