c# - Reliable way of determining whether an user account requires a password? -


i wrote code snippet listing local users , whether account uses password (credits leniel macaferi)

var users = (from managementobject user in new managementobjectsearcher(@"select * win32_useraccount").get()              (uint)user["accounttype"] == uf_normal_account && (bool)user["localaccount"] && !(bool)user["disabled"] && (bool)user["localaccount"] && !(bool)user["lockout"]              orderby (string)user["name"] ascending              select new { username = (string)user["name"], passwordrequired = (bool)user["passwordrequired"] }).toarray();  foreach (var user in users)     console.writeline("{0} (requires password: {1})", user.username, user.passwordrequired ? "yes" : "no"); 

using code there 1 specific user, win32_useraccount.passwordrequired field set false though user using password. changing password via system control setting empty password , resetting didn't affect flag, neither logging out , in again nor rebooting refreshed flag. on other hand user account control says "password protected" beneath user though passwordrequired set false.

i netusersetinfoed flag true removing uf_passwd_notreqd flag user's user_info_2.usri2_flags field. in turn changed value of win32_useraccount.passwordrequired, didn't affect system's behavior. in fact have enter password regardless of flag saying, can flip flag day long , doesn't affect anything, question: is there reliable way of determining whether 1 specific user using password? (the solution preferable shouldn't require administrative privileges.)


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -