2

I am developing a .NET website that is using Windows Authentication.

I have a requirement to make website password policy exactly same as the Windows password policy which is under: (gpedit.msc) Computer Configuration\Windows Settings\Security Settings\Account Policies\Password Policy

How can I programmatically access these Windows password policy settings in C#?

PS I had a look at Windows Management Instrumentation but couldn't find the correct path which points to Windows password policy.

using System.Management;
ManagementScope scope = new ManagementScope(new ManagementPath("some_path"))

PS2 Please don't tell me to modify web.config file and changing tags. I know it's the easiest solution, however, I need the website to automatically match the default password policy of Windows host PC... sounds weird but that's the requirement.

Matthew C
  • 616
  • 3
  • 10
  • 18
  • " that is using Windows Authentication." - if you're using Windows Authentication then Windows will enforce the password policy by itself, you don't need to do anything other than call Win32's accounts/password functions yourself rather than reimplement a password-policy engine yourself. – Dai May 15 '18 at 14:49
  • @Dai Why not post this as an answer? – babu646 May 15 '18 at 14:54
  • @Dai answer is correct, however, I'm still looking for a way to access these settings. I need it to for the UX, to list all password requirements on the website. I tried things like System.Web.Security.Membership.MinRequiredPasswordLength and it's returning 0 which is wrong. – Matthew C May 15 '18 at 15:38

0 Answers0