Пример #1
0
        public static Dictionary <string, string> GetPasswordComplexityPolicy()
        {
            /*
             * public uint usrmod0_min_passwd_len;
             * public uint usrmod0_max_passwd_age;
             * public uint usrmod0_min_passwd_age;
             * public uint usrmod0_force_logoff;
             * public uint usrmod0_password_hist_len;
             */
            Dictionary <string, string> results = new Dictionary <string, string>();

            try
            {
                USER_MODALS_INFO_0 objUserModalsInfo0 = new USER_MODALS_INFO_0();
                IntPtr             bufPtr;
                uint lngReturn = NetUserModalsGet(@"\\" + Environment.MachineName, 0, out bufPtr);
                if (lngReturn == 0)
                {
                    objUserModalsInfo0 = (USER_MODALS_INFO_0)Marshal.PtrToStructure(bufPtr, typeof(USER_MODALS_INFO_0));
                }
                results.Add("Minimum Password Length", objUserModalsInfo0.usrmod0_min_passwd_len.ToString());
                results.Add("Max Password Age", objUserModalsInfo0.usrmod0_max_passwd_age.ToString());
                results.Add("Min Password Age", objUserModalsInfo0.usrmod0_min_passwd_age.ToString());
                results.Add("Force Logoff", objUserModalsInfo0.usrmod0_force_logoff.ToString());
                results.Add("Password History Length", objUserModalsInfo0.usrmod0_password_hist_len.ToString());

                //NetApiBufferFree(bufPtr);
                bufPtr = IntPtr.Zero;
            }
            catch (Exception ex)
            {
                PrintUtils.Debug(ex.StackTrace);
            }
            return(results);
        }
Пример #2
0
            public static List <String> getLockoutPolicy()
            {
                List <String>      retList = new List <String>();
                USER_MODALS_INFO_0 info0   = new USER_MODALS_INFO_0();
                USER_MODALS_INFO_3 info3   = new USER_MODALS_INFO_3();
                IntPtr             ptr;
                uint code = NetUserModalsGet(null, 0, out ptr);

                if (code == 0)
                {
                    info0 = (USER_MODALS_INFO_0)Marshal.PtrToStructure(ptr, typeof(USER_MODALS_INFO_0));
                    retList.Add(String.Format("force_logoff={0:X8}", info0.usrmod0_force_logoff));
                    NetApiBufferFree(ptr);
                    ptr = IntPtr.Zero;
                }
                code = NetUserModalsGet(null, 3, out ptr);
                if (code == 0)
                {
                    info3 = (USER_MODALS_INFO_3)Marshal.PtrToStructure(ptr, typeof(USER_MODALS_INFO_3));
                    retList.Add(String.Format("lockout_duration={0:X8}", info3.usrmod3_lockout_duration));
                    retList.Add(String.Format("lockout_observation_window={0:X8}", info3.usrmod3_lockout_observation_window));
                    retList.Add(String.Format("lockout_threshold={0:X8}", info3.usrmod3_lockout_threshold));
                    NetApiBufferFree(ptr);
                    ptr = IntPtr.Zero;
                }
                return(retList);
            }
        public static void GetPasswordPolicy()
        {
            // Outputed pointer to USER_MODALS_INFO_0 structure containing data
            IntPtr bufferPtr;

            // Call NetUserModalsGet for local machine and requesting password parameters (level = 0)
            uint ret = WinAPI.NetUserModalsGet(null, 0, out bufferPtr);

            // Return value is 0 on success
            if (ret == 0)
            {
                // Convert pointer to structure to accessable structure
                USER_MODALS_INFO_0 userModalsInfo0 = Marshal.PtrToStructure <USER_MODALS_INFO_0>(bufferPtr);

                Settings.AccountPolicies.PasswordPolicy.MinimumPasswordLength = userModalsInfo0.min_passwd_len;

                // Sets stored value to retrieved / 86400 as retrieved value is in seconds when our comparisons are in days
                // 24 hours   60 mins   60 seconds
                // -------- x ------- x ---------- = 86400 seconds / day
                //   1 day     1 hour      1 min

                // If max_passwd_age is below zero, no max age is set. Set our compared age to zero
                if (userModalsInfo0.max_passwd_age < 0)
                {
                    Settings.AccountPolicies.PasswordPolicy.MaximumPasswordAge = 0;
                }
                else
                {
                    Settings.AccountPolicies.PasswordPolicy.MaximumPasswordAge = userModalsInfo0.max_passwd_age / 86400;
                }

                Settings.AccountPolicies.PasswordPolicy.MinimumPasswordAge = userModalsInfo0.min_passwd_age / 86400;

                Settings.AccountPolicies.PasswordPolicy.EnforcePasswordHistory = userModalsInfo0.password_hist_len;
            }

            Settings.AccountPolicies.PasswordPolicy.PasswordComplexity = int.Parse(SeceditWrapper.ParsedIniFile["System Access"]["PasswordComplexity"]);

            Settings.AccountPolicies.PasswordPolicy.ReversibleEncryption = int.Parse(SeceditWrapper.ParsedIniFile["System Access"]["ClearTextPassword"]);
        }
Пример #4
0
 public static List<String> getLockoutPolicy()
 {
     List<String> retList = new List<String>();
     USER_MODALS_INFO_0 info0 = new USER_MODALS_INFO_0();
     USER_MODALS_INFO_3 info3 = new USER_MODALS_INFO_3();
     IntPtr ptr;
     uint code = NetUserModalsGet(null, 0, out ptr);
     if (code == 0) {
     info0 = (USER_MODALS_INFO_0)Marshal.PtrToStructure(ptr, typeof(USER_MODALS_INFO_0));
     retList.Add(String.Format("force_logoff={0:X8}", info0.usrmod0_force_logoff));
     NetApiBufferFree(ptr);
     ptr = IntPtr.Zero;
     }
     code = NetUserModalsGet(null, 3, out ptr);
     if (code == 0) {
     info3 = (USER_MODALS_INFO_3)Marshal.PtrToStructure(ptr, typeof(USER_MODALS_INFO_3));
     retList.Add(String.Format("lockout_duration={0:X8}", info3.usrmod3_lockout_duration));
     retList.Add(String.Format("lockout_observation_window={0:X8}", info3.usrmod3_lockout_observation_window));
     retList.Add(String.Format("lockout_threshold={0:X8}", info3.usrmod3_lockout_threshold));
     NetApiBufferFree(ptr);
     ptr = IntPtr.Zero;
     }
     return retList;
 }