public bool CheckUserCreated(ConfigClass configClass) { try { configClass.GetScriptHandling.putAllLocalUsersToList(); if (!configClass.GetScriptHandling.CheckUserCreated(_newUsers)) { _checkUsers = false; } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check if user is created", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check if user is created", ex.Message)); } return(_checkUsers); }
public void AddUserGroups(ConfigClass configClass) { string name = ""; try { foreach (UserGroup newGroup in NewUserGroups) { name = newGroup.Name; configClass.GetScriptHandling.CreateUserGroups(newGroup.Name, newGroup.Description); } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Create Usergroup", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "", "Group " + name + " " + ex.Message)); } }
public void DeleteUserGroups(ConfigClass configClass) { string name = ""; try { foreach (UserGroup deleteGroup in DeletedUserGroups) { name = deleteGroup.Name; configClass.GetScriptHandling.DeleteUserGroup(deleteGroup.Name); } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Delete usergroup " + name, CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Delete usergroup " + name, ex.Message)); } }
public void RemoveModifiedUserFromList(ModfiedUser itemToRemove, ConfigClass configClass) { try { foreach (ModfiedUser item in _modifiedUsers) { if (item.Name == itemToRemove.Name) { _modifiedUsers.Remove(item); break; } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Remove user from modified user list", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Remove user from modified user list", ex.Message)); } }
public void ReadMBSAlog(ConfigClass configClass) { try { string mbsaLog = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\MBSAlog.txt"; if (File.Exists(mbsaLog)) { FileHandling _fileHandling = new FileHandling(); foreach (string str in _fileHandling.ReadWholeFile(mbsaLog)) { MBSAlogs.Add(new MBSAlogItem(str)); } } } catch (Exception ex) { configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Read MBSA log", ex.Message)); } }
public bool CheckPasswordPolicy(ConfigClass configClass) { bool totalcheck = true; try { Trace.WriteVerbose("()", "MainCheckPasswordPolicy", CLASSNAME); FileHandling _fileHandling = new FileHandling(); string _INFfile = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\PasswordPolicySettings.INF"; List <string> passwordPolicy = new List <string>(); passwordPolicy = _fileHandling.ReadInLogFile(_INFfile, "[System Access]", ""); foreach (string str in passwordPolicy) { if (_checkStringsInPassWordPolicy_INFfile.Contains(str)) { _checkPasswordPolicy.Add(true); } else { _checkPasswordPolicy.Add(false); } } //File.Delete(_INFfile); foreach (bool b in _checkPasswordPolicy) { if (!b) { totalcheck = false; return(totalcheck); } } return(totalcheck); } catch (Exception ex) { Trace.WriteError("({0})", "Check password policy", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check password policy", ex.Message)); totalcheck = false; return(totalcheck); } }
public bool CheckAuditPolicy(ConfigClass configClass) { bool totalcheck = true; try { Actemium.Diagnostics.Trace.WriteVerbose("()", "CheckAuditPolicy", CLASSNAME); FileHandling _fh = new FileHandling(); List <string> auditPolicy = new List <string>(); auditPolicy = _fh.ReadInLogFile(_INFfile, "[Event Audit]", ""); foreach (string str in auditPolicy) { if (_checkStringsInAuditPolicyINFfile.Contains(str)) { _checkAuditPolicy.Add(true); } else { _checkAuditPolicy.Add(false); } } //File.Delete(_INFfile); foreach (bool b in _checkAuditPolicy) { if (!b) { totalcheck = false; return(totalcheck); } } return(totalcheck); } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check Audit policy", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check Audit policy", ex.Message)); totalcheck = false; return(totalcheck); } }
/// <summary> /// Get or set ListOfNewSharedFolder /// </summary> public void AddSharedFolder(ConfigClass configClass) { const string FUNCTIONNAME = "AddSharedFolder"; try { Trace.WriteVerbose("()", FUNCTIONNAME, CLASSNAME); string sharedFolderName = ""; string sharedFolderPath = ""; string sharedSimultaneousUserLimit = ""; string sharedFolderComment = ""; foreach (NewSharedFolder NSF in _listOfNewSharedFolder) { if (NSF.Name.Length != 0) { sharedFolderName = NSF.Name; } if (NSF.FolderPath.Length != 0) { sharedFolderPath = NSF.FolderPath; } if (NSF.CommentShare.Length != 0) { sharedFolderComment = NSF.CommentShare; } if (NSF.SimultaneousUserLimit.Length != 0) { sharedSimultaneousUserLimit = NSF.SimultaneousUserLimit; } configClass.GetScriptHandling.AddSharedFolder(sharedFolderPath, sharedFolderName, sharedSimultaneousUserLimit, sharedFolderComment); } } catch (Exception ex) { Trace.WriteError("()", FUNCTIONNAME, CLASSNAME, ex); throw; } }
public void ModifyFirewallRules(ConfigClass configClass) { const string FUNCTIONNAME = "ModifyFirewallRule"; try { Actemium.Diagnostics.Trace.WriteVerbose("()", FUNCTIONNAME, CLASSNAME); for (int i = 0; i <= _modifyFirewallRule.Count - 1; i++) { configClass.GetScriptHandling.ModifyFirewallRule(_modifyFirewallRule[i].oldRuleName, _modifyFirewallRule[i].NewRuleName, _modifyFirewallRule[i].IsRuleEnable, _modifyFirewallRule[i].RuleDirection, _modifyFirewallRule[i].RuleProtocol, _modifyFirewallRule[i].RulePort, _modifyFirewallRule[i].RuleAction); } //foreach (ModifyFirewall firewallRuleToModify in _modifyFirewallRule) //{ // configClass.GetScriptHandling.ModifyFirewallRule(firewallRuleToModify.oldRuleName, firewallRuleToModify.NewRuleName, firewallRuleToModify.IsRuleEnable, firewallRuleToModify.RuleDirection, firewallRuleToModify.RuleProtocol, firewallRuleToModify.RulePort, firewallRuleToModify.RuleAction); //} } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("()", FUNCTIONNAME, CLASSNAME, ex); throw; } }
//methods public bool SetMBSA(ConfigClass configClass) { bool check = false; try { string mbsaLog = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\MBSAlog.txt"; if (File.Exists(mbsaLog)) { File.Delete(mbsaLog); } _MBSAisRunning = "start"; if (_runMBSA) { _MBSAisRunning = _pathMBSA + "\\mbsacli.exe"; configClass.GetScriptHandling.RunMBSA(_pathMBSA, "\"" + mbsaLog + "\""); if (_MBSAkilled) { _MBSAisRunning = null; return(false); } else { _MBSAisRunning = null; return(true); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Run MBSA", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Run mbsa", ex.Message)); } return(check); }
public bool CheckUsergroupCreated(ConfigClass configClass) { string name = ""; try { foreach (UserGroup group in NewUserGroups) { name = group.Name; if (!CheckIfUserGroupExist(group.Name, configClass)) { _checkUsersgroups = false; break; } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check if usergroup " + name + " is created", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check if usergroup " + name + " is created", ex.Message)); } return(_checkUsersgroups); }
public bool CheckIfUserGroupExist(string name, ConfigClass configClass) { bool check = false; try { foreach (UserGroup user in ExistedUserGroups(configClass)) { if (string.Equals(user.Name, name, StringComparison.OrdinalIgnoreCase)) { check = true; break; } } return(check); } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check if usergroup " + name + " Exist", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check if usergroup " + name + " Exist", ex.Message)); return(check); } }
public string FindMBSAexePath(string folderInProgramFiles, ConfigClass configClass) { try { string programFiles = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles); string folderName = ""; List <string> programs = new List <string>(); DirectoryInfo dir = new DirectoryInfo(programFiles); foreach (DirectoryInfo f in dir.GetDirectories()) { if (f.Name.Contains(folderInProgramFiles)) { folderName = f.Name; return(programFiles + "\\" + folderName); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Find path from MBSA executable", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "", ex.Message)); } return(null); }
public bool CheckSetShutDownEventTracker(OSVersions os, ConfigClass configClass) { try { string regPath = ""; string regKey = ""; string value = ""; if (_shutDownEventTrackerInUse) { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegPath"); } #endregion RegPath #region RegKeyShutdownReason if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyShutdownReason") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyShutdownReason"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegKeyShutdownReason"); } value = "1"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkShutdownEventTracker.Add(true); } else { _checkShutdownEventTracker.Add(false); } #endregion RegKeyShutdownReason #region OnShutdownReasonUI if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyOnShutdownReasonUI") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyOnShutdownReasonUI"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegKeyOnShutdownReasonUI"); } value = "1"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkShutdownEventTracker.Add(true); } else { _checkShutdownEventTracker.Add(false); } #endregion OnShutdownReasonUI } else { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegPath"); } #endregion RegPath #region RegKeyShutdownReason if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyShutdownReason") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyShutdownReason"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegKeyShutdownReason"); } value = "0"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkShutdownEventTracker.Add(true); } else { _checkShutdownEventTracker.Add(false); } #endregion RegKeyShutdownReason #region OnShutdownReasonUI if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyOnShutdownReasonUI") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyOnShutdownReasonUI"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegKeyOnShutdownReasonUI"); } value = "0"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkShutdownEventTracker.Add(true); } else { _checkShutdownEventTracker.Add(false); } #endregion OnShutdownReasonUI } foreach (bool b in _checkShutdownEventTracker) { if (!b) { _shutDownEventTrackerCheck = false; return(_shutDownEventTrackerCheck); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Shutdown eventtracker", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Shutdown eventtracker", ex.Message)); ShutDownEventTrackerCheck = false; } return(_shutDownEventTrackerCheck); }
public void SetShutDownEventTracker(OSVersions os, ConfigClass configClass) { try { string regPath = ""; string regKey = ""; string value = ""; string propertyType = "DWORD"; if (_shutDownEventTrackerInUse) { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegPath"); } #endregion RegPath #region RegKeyShutdownReason if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyShutdownReason") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyShutdownReason"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegKeyShutdownReason"); } value = "1"; configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion RegKeyShutdownReason #region OnShutdownReasonUI if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyOnShutdownReasonUI") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyOnShutdownReasonUI"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegKeyOnShutdownReasonUI"); } value = "1"; configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion OnShutdownReasonUI } else { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegPath"); } #endregion RegPath #region RegKeyShutdownReason if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyShutdownReason") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyShutdownReason"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegKeyShutdownReason"); } value = "0"; configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion RegKeyShutdownReason #region OnShutdownReasonUI if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyOnShutdownReasonUI") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "SDEVTRegKeyOnShutdownReasonUI"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "SDEVTRegKeyOnShutdownReasonUI"); } value = "0"; configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion OnShutdownReasonUI } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Set Shutdown event tracker", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Set Shutdown event tracker", ex.Message)); ShutDownEventTrackerCheck = false; } }
public bool CheckAutoLogonSettings(OSVersions os, ConfigClass configClass) { try { string regPath = ""; string regKey = ""; string value = ""; #region Automatic login setting if (_autologonInUse) { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonRegPath"); } #endregion RegPath #region Username if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonUsername") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonUsername"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonUsername"); } value = _usernameAutoLogon; // name if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkAutoLogonSettings.Add(true); } else { _checkAutoLogonSettings.Add(false); } #endregion Username //TODO: Powershell kan geen string vergelijken met speciale tekens /* #region Pasword * string password = ""; * if (_passwordAutoLogon == "PassWordIsEncrypted") * { * EncryptionPassword enc = new EncryptionPassword(configClass); * password = enc.GetKey("AutoLogon"); * } * else * { * password = _passwordAutoLogon; * } * if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonPassword") != null) * { * regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonPassword"); * } * else * { * regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonPassword"); * } * value = password; //password * if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) TODO: Powershell kan gen string vergelijken met speciale tekens * { * _checkAutoLogonSettings.Add(true); * } * else * { * _checkAutoLogonSettings.Add(false); * } * #endregion Pasword*/ #region DomainName if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonDomainName") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonDomainName"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonDomainName"); } value = System.Environment.MachineName;//Domain if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkAutoLogonSettings.Add(true); } else { _checkAutoLogonSettings.Add(false); } #endregion DomainName #region SetAutoLogon if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoAdminLogon") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoAdminLogon"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoAdminLogon"); } value = "1"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkAutoLogonSettings.Add(true); } else { _checkAutoLogonSettings.Add(false); } #endregion SetAutoLogon } #endregion Automatic login setting #region Disable auto login else { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonRegPath"); } #endregion RegPath #region Pasword if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonPassword") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonPassword"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonPassword"); } value = "null"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkAutoLogonSettings.Add(false); } else { _checkAutoLogonSettings.Add(true); } #endregion Pasword #region SetAutoLogon if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoAdminLogon") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoAdminLogon"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoAdminLogon"); } value = "0"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkAutoLogonSettings.Add(true); } else { _checkAutoLogonSettings.Add(false); } #endregion SetAutoLogon } #endregion Disable auto login foreach (bool b in _checkAutoLogonSettings) { if (!b) { AutoLogonCheck = false; return(AutoLogonCheck); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check autologin settings", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check autologin settings", ex.Message)); AutoLogonCheck = false; } return(AutoLogonCheck); }
public bool CheckRemoteDesktopSettings(OSVersions os, ConfigClass configClass) { bool totalcheck = true; try { string regPath = ""; string regKey = ""; string value = ""; if (_remoteDesktopDisabled) { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableLessSecureRegPath"); } #endregion RegPath #region RegKeyRemoteDesktop if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegKey") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegKey"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableLessSecureRegKey"); } value = "1"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkRemoteDesktop.Add(true); } else { _checkRemoteDesktop.Add(false); } #endregion RegKeyRemoteDesktop if (os != OSVersions.WindowsXP && os != OSVersions.WindowsXP32 && os != OSVersions.WindowsXP64 && os != OSVersions.W2003 && os != OSVersions.W2003R2) { #region RegPath Netwerk level authentication if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableMoreSecureRegPath"); } #endregion RegPath Netwerk level authentication #region RegKeyRemoteDesktop Netwerk level authentication if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegKey") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegKey"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableMoreSecureRegKey"); } value = "0"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkRemoteDesktop.Add(true); } else { _checkRemoteDesktop.Add(false); } #endregion RegKeyRemoteDesktop Netwerk level authentication } } if (_remoteDesktopEnabledForAllPCs && !_remoteDesktopEnabledOnlyForPCsWithNLA) { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableLessSecureRegPath"); } #endregion RegPath #region RegKeyRemoteDesktop if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegKey") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegKey"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableLessSecureRegKey"); } value = "0"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkRemoteDesktop.Add(true); } else { _checkRemoteDesktop.Add(false); } #endregion RegKeyRemoteDesktop if (os != OSVersions.WindowsXP && os != OSVersions.WindowsXP32 && os != OSVersions.WindowsXP64 && os != OSVersions.W2003 && os != OSVersions.W2003R2) { #region RegPath Netwerk level authentication if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableMoreSecureRegPath"); } #endregion RegPath Netwerk level authentication #region RegKeyRemoteDesktop Netwerk level authentication if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegKey") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegKey"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableMoreSecureRegKey"); } value = "0"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkRemoteDesktop.Add(true); } else { _checkRemoteDesktop.Add(false); } #endregion RegKeyRemoteDesktop Netwerk level authentication } } if (_remoteDesktopEnabledForAllPCs && _remoteDesktopEnabledOnlyForPCsWithNLA) { #region RegPath Enable/Disable if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableLessSecureRegPath"); } #endregion RegPath Enable/Disable #region RegKeyRemoteDesktop if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegKey") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableLessSecureRegKey"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableLessSecureRegKey"); } value = "0"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkRemoteDesktop.Add(true); } else { _checkRemoteDesktop.Add(false); } #endregion RegKeyRemoteDesktop #region RegPath Netwerk level authentication if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableMoreSecureRegPath"); } #endregion RegPath Netwerk level authentication #region RegKeyRemoteDesktop Netwerk level authentication if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegKey") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "RemoteDesktopEnableMoreSecureRegKey"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "RemoteDesktopEnableMoreSecureRegKey"); } value = "1"; if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkRemoteDesktop.Add(true); } else { _checkRemoteDesktop.Add(false); } #endregion RegKeyRemoteDesktop Netwerk level authentication } if (configClass.GetScriptHandling.CheckIfUserinGroupExist(_remoteDesktopUsers)) { _checkRemoteDesktop.Add(true); } else { _checkRemoteDesktop.Add(false); } //if (configClass.GetScriptHandling.CheckIfGroupInGroupExist(_remoteDesktopGroups)) //{ // _checkRemoteDesktop.Add(true); //} //else //{ // _checkRemoteDesktop.Add(false); //} foreach (bool b in _checkRemoteDesktop) { if (!b) { return(totalcheck); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check remotedesktop settings", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check remotedesktop settings", ex.Message)); } return(totalcheck); }
//methods public void CreateRegFileAndStartupBatchFile(OSVersions os, ConfigClass configClass) { try { string driveLetter = Environment.GetEnvironmentVariable("SystemRoot"); driveLetter = driveLetter.Substring(0, 3); _regFilepath = driveLetter + "Actemium"; DirectoryInfo di = Directory.CreateDirectory(_regFilepath); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; configClass.GetScriptHandling.AddRegistrySettingsToFile(_regFilepath + @"\firstLogon.reg"); string firstLogonEXEpath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\ConfigFiles\FirstLogon\firstLogon.exe"; string firstLogonBATpath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\ConfigFiles\FirstLogon\firstLogon.bat"; if (!File.Exists(firstLogonEXEpath)) { DialogResult result = MessageBox.Show("firstLogon.exe is not found in the root of this application", "Executable not found", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (result == DialogResult.Retry) { CreateRegFileAndStartupBatchFile(os, configClass); } } if (!File.Exists(firstLogonBATpath)) { DialogResult result = MessageBox.Show("firstLogon.bat is not found in the root of this application", "Executable not found", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (result == DialogResult.Retry) { CreateRegFileAndStartupBatchFile(os, configClass); } } if (!File.Exists(_regFilepath + @"\firstLogon.exe")) { File.Copy(firstLogonEXEpath, _regFilepath + @"\firstLogon.exe"); } if (!File.Exists(_regFilepath + @"\firstLogon.bat")) { File.Copy(firstLogonBATpath, _regFilepath + @"\firstLogon.bat"); } string regPath = ""; string regKey = ""; string value = _regFilepath + @"\firstLogon.exe"; string propertyType = "String"; if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "FirstLogonPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "FirstLogonPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "FirstLogonPath"); } regKey = "SetCurrentUserSettingsActemium"; configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0},{1})", "MainEndCreateRegFileAndStartupBatchFile", CLASSNAME, ex, os); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Create start up files for other accounts", ex.Message)); } }
public void ModifyUsers(ConfigClass configClass, EncryptionPassword enc) { string name = ""; string fullname = ""; string description = ""; List <string> group = new List <string>(); bool changePwNextLogon = false; bool passwordCantBeChanged = false; bool passwordNeverExpires = false; bool accountDisabled = false; string password = ""; bool modifyOtherSettings = false; try { foreach (ModfiedUser modifiedUser in _modifiedUsers) { name = modifiedUser.Name; if (modifiedUser.Fullname.Length != 0) { fullname = modifiedUser.Fullname; } if (modifiedUser.Description.Length != 0) { description = modifiedUser.Description; } if (modifiedUser.UserGroupList.Count != 0) { group = modifiedUser.UserGroupList; } if (modifiedUser.ChangePwNextLogon == "Yes") { changePwNextLogon = true; } else if (modifiedUser.ChangePwNextLogon == "No") { changePwNextLogon = false; } if (modifiedUser.PasswordCantBeChanged == "Yes") { passwordCantBeChanged = true; } else if (modifiedUser.PasswordCantBeChanged == "No") { passwordCantBeChanged = false; } if (modifiedUser.PasswordNeverExpires == "Yes") { passwordNeverExpires = true; } else if (modifiedUser.PasswordNeverExpires == "No") { passwordNeverExpires = false; } if (modifiedUser.AccountDisabled == "Yes") { accountDisabled = true; } else if (modifiedUser.AccountDisabled == "No") { accountDisabled = false; } if (modifiedUser.Password.Length != 0) { if (modifiedUser.Password == "PassWordIsEncrypted") { password = enc.GetKey(name); } else { password = modifiedUser.Password; } } if (modifiedUser.ModifyOtherSettings == "Yes") { modifyOtherSettings = true; } else if (modifiedUser.ModifyOtherSettings == "No") { modifyOtherSettings = false; } configClass.GetScriptHandling.ModifyUser(name, fullname, description, changePwNextLogon, passwordCantBeChanged, passwordNeverExpires, accountDisabled, password, modifyOtherSettings); foreach (string groupString in group) { configClass.GetScriptHandling.AddUserToGroup(modifiedUser.Name, groupString); } } } catch (Exception ex) { Trace.WriteError(ex.Message, "ModifyUser " + name, CLASSNAME); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Modifyuser " + name, ex.Message)); } }
public void AddUsers(ConfigClass configClass, EncryptionPassword enc) { string name = ""; try { string fullname = ""; string description = ""; List <string> group = new List <string>(); int changePwNextLogon = -1; int passwordCantBeChanged = -1; int passwordNeverExpires = -1; int accountDisabled = -1; string password = ""; foreach (NewUser newUser in _newUsers) { name = newUser.Name; if (newUser.Fullname.Length != 0) { fullname = newUser.Fullname; } if (newUser.Description.Length != 0) { description = newUser.Description; } if (newUser.UserGroupList.Count != 0) { group = newUser.UserGroupList; } if (newUser.ChangePwNextLogon == "Yes") { changePwNextLogon = 1; } else if (newUser.ChangePwNextLogon == "No") { changePwNextLogon = 0; } if (newUser.PasswordCantBeChanged == "Yes") { passwordCantBeChanged = 1; } else if (newUser.PasswordCantBeChanged == "No") { passwordCantBeChanged = 0; } if (newUser.PasswordNeverExpires == "Yes") { passwordNeverExpires = 1; } else if (newUser.PasswordNeverExpires == "No") { passwordNeverExpires = 0; } if (newUser.AccountDisabled == "Yes") { accountDisabled = 1; } else if (newUser.AccountDisabled == "No") { accountDisabled = 0; } if (newUser.Password.Length != 0) { if (newUser.Password == "PassWordIsEncrypted") { password = enc.GetKey(name); } else { password = newUser.Password; } } configClass.GetScriptHandling.CreateUser(name, fullname, description, group, changePwNextLogon, passwordCantBeChanged, passwordNeverExpires, accountDisabled, password); foreach (string groupString in group) { configClass.GetScriptHandling.AddUserToGroup(newUser.Name, groupString); } } } catch (Exception ex) { Trace.WriteError(ex.Message, "NewUser", CLASSNAME); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Create user " + name, ex.Message)); } }
public List <ExistedUser> ExistedUsers(ConfigClass configClass) { configClass.GetScriptHandling.putAllLocalUsersToList(); _existedUsers = configClass.GetScriptHandling.GetAllLocalUsers; return(_existedUsers); }
public void GetAllCurrentWindowsSettings(ConfigClass configClass) { const string FUNCTIONNAME = "GetAllCurrentWindowsSettings"; try { Trace.WriteVerbose("()", FUNCTIONNAME, CLASSNAME); ScriptHandling _sh = new ScriptHandling(); _sh.ShowCurrentWindowsSettings(); foreach (string str in _sh.ShowAllCurrentWindowsSettings) { int seperationIndex = str.IndexOf(":"); string windowsSettingsName = str.Substring(0, seperationIndex + 1); string windowsSettingsValue = str.Substring(seperationIndex + 1, str.Length - seperationIndex - 1); bool windowsValue = false; int temp = 0; switch (windowsSettingsName) { case AUTOPLAY: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } AutoplayCD = windowsValue; break; case SHOW_THE_CONTENT_OF_SYSTEM_FOLDER: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } DisplayContentOfSystemFolder = windowsValue; break; case DISPLAY_THE_FULL_PATH_IN_THE_ADDRESS_BAR: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } DisplayFullPathInAddressBar = windowsValue; break; case SHOW_HIDDEN_FILES_AND_FOLDERS: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } ShowHiddenFolders = windowsValue; break; case AUTOMATIC_SEARCH_FOR_NETWORK_FOLDERS_AND_PRINTERS: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } AutomaticallySearchNetworkFoldersAndPrinters = windowsValue; break; case HIDE_FILE_EXTENSIONS: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } HideExtensions = windowsValue; break; case SHOW_SYSTEM_FILES_AND_FOLDERS: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } HideProtectedOSFiles = windowsValue; break; case THE_VIEW_SETTINGS_FOR_EACH_FOLDER: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } RememberEachFoldersViewSetting = windowsValue; break; case SHOW_ENCRYPTED_OR_COMPRESSED_NTFS_FILES_IN_COLOR: temp = int.Parse(windowsSettingsValue); switch (temp) { case 0: windowsValue = false; break; case 1: windowsValue = true; break; } ShowNTFSFilesInColor = windowsValue; break; default: Trace.WriteInformation("'{0}' is not a supported value for Windows Settings", FUNCTIONNAME, CLASSNAME, windowsSettingsName); break; } } } catch (Exception ex) { Trace.WriteError("()", FUNCTIONNAME, CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "GetAllAuditPolicy", ex.Message)); } }
public bool CheckexplorerMapOptions(OSVersions os, ConfigClass configClass) { bool totalcheck = true; try { string regPath = ""; string regKey = ""; string value = ""; _checkWindowsExplorerFolderOptions.Clear(); #region Automatically search for network folders and printers if (ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced") != null) { regPath = ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced"); } else { regPath = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOregPathfolderOptionsAdvanced"); } if (ResourceHelper.GetOSOperations(os, "EMONoNetCrawling") != null) { regKey = ResourceHelper.GetOSOperations(os, "EMONoNetCrawling"); } else { regKey = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMONoNetCrawling"); } if (_automaticallySearchNetworkFoldersAndPrinters) { value = "0"; } else { value = "1"; } if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkWindowsExplorerFolderOptions.Add(true); } else { _checkWindowsExplorerFolderOptions.Add(false); } #endregion #region Display the contents of system folders if (ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced") != null) { regPath = ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced"); } else { regPath = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOregPathfolderOptionsAdvanced"); } if (ResourceHelper.GetOSOperations(os, "EMOWebViewBarricade") != null) { regKey = ResourceHelper.GetOSOperations(os, "EMOWebViewBarricade"); } else { regKey = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOWebViewBarricade"); } if (_displayContentOfSystemFolder) { value = "1"; } else { value = "0"; } if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkWindowsExplorerFolderOptions.Add(true); } else { _checkWindowsExplorerFolderOptions.Add(false); } #endregion #region Display the full path in the Address bar if (ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsCabinetState") != null) { regPath = ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsCabinetState"); } else { regPath = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOregPathfolderOptionsCabinetState"); } if (ResourceHelper.GetOSOperations(os, "EMOFullPathAddress") != null) { regKey = ResourceHelper.GetOSOperations(os, "EMOFullPathAddress"); } else { regKey = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOFullPathAddress"); } if (_displayFullPathInAddressBar) { value = "1"; } else { value = "0"; } if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkWindowsExplorerFolderOptions.Add(true); } else { _checkWindowsExplorerFolderOptions.Add(false); } #endregion #region Show hidden files and folders if (ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced") != null) { regPath = ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced"); } else { regPath = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOregPathfolderOptionsAdvanced"); } if (ResourceHelper.GetOSOperations(os, "EMOHidden") != null) { regKey = ResourceHelper.GetOSOperations(os, "EMOHidden"); } else { regKey = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOHidden"); } if (_showHiddenFolders) { value = "1"; } else { value = "2"; } if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkWindowsExplorerFolderOptions.Add(true); } else { _checkWindowsExplorerFolderOptions.Add(false); } #endregion #region Hide extensions for known file types if (ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced") != null) { regPath = ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced"); } else { regPath = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOregPathfolderOptionsAdvanced"); } if (ResourceHelper.GetOSOperations(os, "EMOHideFileExt") != null) { regKey = ResourceHelper.GetOSOperations(os, "EMOHideFileExt"); } else { regKey = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOHideFileExt"); } if (_hideExtensions) { value = "1"; } else { value = "0"; } if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkWindowsExplorerFolderOptions.Add(true); } else { _checkWindowsExplorerFolderOptions.Add(false); } #endregion #region Hide protected operating system files if (ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced") != null) { regPath = ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced"); } else { regPath = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOregPathfolderOptionsAdvanced"); } if (ResourceHelper.GetOSOperations(os, "EMOShowSuperHidden") != null) { regKey = ResourceHelper.GetOSOperations(os, "EMOShowSuperHidden"); } else { regKey = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOShowSuperHidden"); } if (_hideProtectedOSFiles) { value = "0"; } else { value = "1"; } if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkWindowsExplorerFolderOptions.Add(true); } else { _checkWindowsExplorerFolderOptions.Add(false); } #endregion #region The view settings for each folder if (ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced") != null) { regPath = ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced"); } else { regPath = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOregPathfolderOptionsAdvanced"); } if (ResourceHelper.GetOSOperations(os, "EMOClassicViewState") != null) { regKey = ResourceHelper.GetOSOperations(os, "EMOClassicViewState"); } else { regKey = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOClassicViewState"); } if (_rememberEachFoldersViewSetting) { value = "0"; } else { value = "1"; } if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkWindowsExplorerFolderOptions.Add(true); } else { _checkWindowsExplorerFolderOptions.Add(false); } #endregion #region Show encrypted or compressed NTFS files in color if (ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced") != null) { regPath = ResourceHelper.GetOSOperations(os, "EMOregPathfolderOptionsAdvanced"); } else { regPath = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOregPathfolderOptionsAdvanced"); } if (ResourceHelper.GetOSOperations(os, "EMOShowCompColor") != null) { regKey = ResourceHelper.GetOSOperations(os, "EMOShowCompColor"); } else { regKey = ResourceHelper.GetOSOperations(OSVersions.AllOS, "EMOShowCompColor"); } if (_showNTFSFilesInColor) { value = "1"; } else { value = "0"; } if (configClass.GetScriptHandling.CheckRegKeyExist(regPath, regKey, value)) { _checkWindowsExplorerFolderOptions.Add(true); } else { _checkWindowsExplorerFolderOptions.Add(false); } #endregion foreach (bool b in _checkWindowsExplorerFolderOptions) { if (!b) { totalcheck = false; return(totalcheck); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Set Windows explorer folder options", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Set Windows explorer folder options", ex.Message)); } return(totalcheck); }
public static void WriteConfigToFile(string StyleSheetType, string FileNamePath, string FileFolder, ConfigClass configClass) { try { FileHandling fileHandling = new FileHandling(configClass); if (!File.Exists(FileNamePath)) { fileHandling.CreateFile(FileNamePath); } //string stylesheetPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\stylesheets\Actemium.xsl"; if (StyleSheetType == "ConfigOverview") { string stylesheetPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\stylesheets\Actemium.xsl"; if (!File.Exists(FileFolder + "ActemiumStyleSheet.xsl")) { File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } else { File.Delete(FileFolder + "ActemiumStyleSheet.xsl"); File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } } else if (StyleSheetType == "ErrorOverview") { string stylesheetPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\stylesheets\Error.xsl"; string file = FileFolder + "ActemiumStyleSheet.xsl"; if (!File.Exists(file)) { File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } else { File.Delete(FileFolder + "ActemiumStyleSheet.xsl"); File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } } else if (StyleSheetType == "TotalOverview") { string stylesheetPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\stylesheets\TotalOverviewActemium.xsl"; if (!File.Exists(FileFolder + "ActemiumStyleSheet.xsl")) { File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } else { File.Delete(FileFolder + "ActemiumStyleSheet.xsl"); File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } } using (StreamWriter streamWriter = new StreamWriter(FileNamePath)) { string blockKeysSettingsRaw = CtrlHome.GetConfigClass.Serialize(StyleSheetType); streamWriter.Write(blockKeysSettingsRaw); streamWriter.Flush(); } } catch (Exception ex) { throw new Exception("Writing configuration to configuration file failed.", ex); } }
public void SetPasswordPolicy(ConfigClass configClass) { try { Trace.WriteVerbose("({0})", "MainPasswordPolicy", CLASSNAME); string write = ""; File.Delete(_INFfile); FileHandling _fileHandling = new FileHandling(); _fileHandling.CreateFile(_INFfile); _fileHandling.AddLineToEndFile(_INFfile, "[Version]"); _fileHandling.AddLineToEndFile(_INFfile, "signature=\"$CHICAGO$\""); _fileHandling.AddLineToEndFile(_INFfile, "Revision=1"); _fileHandling.AddLineToEndFile(_INFfile, ""); write = "[System Access]"; _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); if (MaximumPasswordAge != -1) #region { write = "MaximumPasswordAge = " + _maximumPasswordAge.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_minimumPasswordAge != -1) #region { write = "MinimumPasswordAge = " + _minimumPasswordAge.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_minimumPasswordLength != -1) #region { write = "MinimumPasswordLength = " + _minimumPasswordLength.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_passwordHistorySize != -1) #region { write = "PasswordHistorySize = " + _passwordHistorySize.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_passwordComplexity != -1) #region { write = "PasswordComplexity = " + _passwordComplexity.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_clearTextPassword != -1) #region { write = "ClearTextPassword = "******"({0})", "Make password policy settings", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Make password policy settings", ex.Message)); } }
public FileHandling(ConfigClass configClass) { _configClass = configClass; }
public void SetNetworkStaticConfigure(OSVersions os, ConfigClass configClass) { const string FUNCTIONNAME = "SetNetworkConfigure"; Trace.WriteVerbose("()", FUNCTIONNAME, CLASSNAME); try { string staticIpAddress = ""; string staticSubnetMask = ""; string staticDefaultGateway = ""; string staticCaption = ""; List <string> ListOfDnsServers = new List <string>(); foreach (NewNetwork nn in _newNetwork) { if (nn.IpAddress.Length != 0) { staticIpAddress = nn.IpAddress; } if (nn.SubnetMask.Length != 0) { staticSubnetMask = nn.SubnetMask; } if (nn.Gateway.Length != 0) { staticDefaultGateway = nn.Gateway; } if (nn.SetDnsServers.Count != 0) { ListOfDnsServers = nn.SetDnsServers; } if (nn.NetCaption.Length != 0) { staticCaption = nn.NetCaption; } if (_ipAutoAssign == false) { _dnsAutoAssign = false; } if (_ipAutoAssign == false) { configClass.GetScriptHandling.SetStaticIPAddresses(staticIpAddress, staticSubnetMask, staticDefaultGateway, ListOfDnsServers, staticCaption); } else if (_ipAutoAssign == true && _dnsAutoAssign == true) { configClass.GetScriptHandling.SetAutoIpAddresses(staticCaption); } else if (_ipAutoAssign == true && _dnsAutoAssign == false) { foreach (string dnsString in ListOfDnsServers) { configClass.GetScriptHandling.SetStaticDnsAddresses(dnsString, staticCaption); } } } } catch (Exception ex) { Trace.WriteError("({0})", FUNCTIONNAME, CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Set IP settings", ex.Message)); } }
//methods public void AutlogonSettings(OSVersions os, ConfigClass configClass) { try { string regPath = ""; string regKey = ""; string value = ""; string propertyType = "String"; #region Auto-login set for user if (_autologonInUse) { if (configClass.ConfSetWindowsUsers.CheckIfUserExist(UsernameAutoLogon, configClass)) { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonRegPath"); } #endregion RegPath #region Username if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonUsername") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonUsername"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonUsername"); } value = _usernameAutoLogon; // name configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion Username #region Pasword string password = ""; if (_passwordAutoLogon == "PassWordIsEncrypted") { EncryptionPassword enc = new EncryptionPassword(configClass); password = enc.GetKey("AutoLogon"); } else { password = _passwordAutoLogon; } if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonPassword") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonPassword"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonPassword"); } value = password; //password configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion Pasword #region DomainName if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonDomainName") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonDomainName"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonDomainName"); } value = System.Environment.MachineName;//Domain configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion DomainName #region SetAutoLogon if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoAdminLogon") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoAdminLogon"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoAdminLogon"); } value = "1"; configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion SetAutoLogon } else { configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Autologon settings", "Gebruikers account niet beschikbaar")); AutoLogonCheck = false; } } #endregion Auto-login set for user #region Disable Auto login else { #region RegPath if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonRegPath") != null) { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonRegPath"); } else { regPath = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonRegPath"); } #endregion RegPath #region Pasword if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonPassword") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoLogonPassword"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoLogonPassword"); } configClass.GetScriptHandling.RemoveRegisterKey(regPath, regKey); #endregion Pasword #region SetAutoLogon if (Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoAdminLogon") != null) { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(os, "AutoAdminLogon"); } else { regKey = Actemium.WiSSWizard.Support.ResourceHelper.GetOSOperations(OSVersions.AllOS, "AutoAdminLogon"); } value = "0"; configClass.GetScriptHandling.SetRegisterKey(regPath, regKey, value, propertyType); #endregion SetAutoLogon } #endregion Disable Auto login } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Autologon settings", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Autologon settings", ex.Message)); AutoLogonCheck = false; } }
public EncryptionPassword(ConfigClass configClass) { _configClass = configClass; _fhEncr = new FileHandling(_configClass); }
//methoden public void CompleteAuditPolicy(ConfigClass configClass) { try { Actemium.Diagnostics.Trace.WriteVerbose("({0})", "CompleteAuditPolicy", CLASSNAME); string write = ""; if (File.Exists(_INFfile)) { File.Delete(_INFfile); } FileHandling _fh = new FileHandling(); _fh.CreateFile(_INFfile); _fh.AddLineToEndFile(_INFfile, "[Version]"); _fh.AddLineToEndFile(_INFfile, "signature=\"$CHICAGO$\""); _fh.AddLineToEndFile(_INFfile, "Revision=1"); _fh.AddLineToEndFile(_INFfile, ""); write = "[Event Audit]"; _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); #region Control Policy if (_auditLogonEvents != -1) #region { if (_auditLogonEvents == 0) { write = "AuditLogonEvents = 0"; } if (_auditLogonEvents == 1) { write = "AuditLogonEvents = 1"; } if (_auditLogonEvents == 2) { write = "AuditLogonEvents = 2"; } if (_auditLogonEvents == 3) { write = "AuditLogonEvents = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditAccountLogon != -1) #region { if (_auditAccountLogon == 0) { write = "AuditAccountLogon = 0"; } if (_auditAccountLogon == 1) { write = "AuditAccountLogon = 1"; } if (_auditAccountLogon == 2) { write = "AuditAccountLogon = 2"; } if (_auditAccountLogon == 3) { write = "AuditAccountLogon = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditAccountManage != -1) #region { if (_auditAccountManage == 0) { write = "AuditAccountManage = 0"; } if (_auditAccountManage == 1) { write = "AuditAccountManage = 1"; } if (_auditAccountManage == 2) { write = "AuditAccountManage = 2"; } if (_auditAccountManage == 3) { write = "AuditAccountManage = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditDSAccess != -1) #region { if (_auditDSAccess == 0) { write = "AuditDSAccess = 0"; } if (_auditDSAccess == 1) { write = "AuditDSAccess = 1"; } if (_auditDSAccess == 2) { write = "AuditDSAccess = 2"; } if (_auditDSAccess == 3) { write = "AuditDSAccess = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditPolicyChange != -1) #region { if (_auditPolicyChange == 0) { write = "AuditPolicyChange = 0"; } if (_auditLogonEvents == 1) { write = "AuditPolicyChange = 1"; } if (_auditLogonEvents == 2) { write = "AuditPolicyChange = 2"; } if (_auditLogonEvents == 3) { write = "AuditPolicyChange = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditPrivilegeUse != -1) #region { if (_auditPrivilegeUse == 0) { write = "AuditPrivilegeUse = 0"; } if (_auditPrivilegeUse == 1) { write = "AuditPrivilegeUse = 1"; } if (_auditPrivilegeUse == 2) { write = "AuditPrivilegeUse = 2"; } if (_auditPrivilegeUse == 3) { write = "AuditPrivilegeUse = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditObjectAccess != -1) #region { if (_auditObjectAccess == 0) { write = "AuditObjectAccess= 0"; } if (_auditObjectAccess == 1) { write = "AuditObjectAccess = 1"; } if (_auditObjectAccess == 2) { write = "AuditObjectAccess = 2"; } if (_auditObjectAccess == 3) { write = "AuditObjectAccess = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditProcessTracking != -1) #region { if (_auditProcessTracking == 0) { write = "AuditProcessTracking = 0"; } if (_auditProcessTracking == 1) { write = "AuditProcessTracking = 1"; } if (_auditProcessTracking == 2) { write = "AuditProcessTracking = 2"; } if (_auditProcessTracking == 3) { write = "AuditProcessTracking = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditSystemEvents != -1) #region { if (_auditSystemEvents == 0) { write = "AuditSystemEvents = 0"; } if (_auditSystemEvents == 1) { write = "AuditSystemEvents = 1"; } if (_auditSystemEvents == 2) { write = "AuditSystemEvents = 2"; } if (_auditSystemEvents == 3) { write = "AuditSystemEvents = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion #endregion Control Policy _checkAuditPolicy.Add(configClass.GetScriptHandling.RunINFfilePasswordAndControlPolicy(_INFfile)); } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Make audit policy Settings", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Make audit policy Settings", ex.Message)); } }