//DesignatedRunAsAdminAccountStatus internal void RefreshDesignatedRunAsAdminAccountStatus() { try { RunningParams.DesignatedRunAsAdminAccountStatus = UniversalStatus.NotOk; var domain = ""; var account = RunningParams.DesignatedRunAsAdminAccountName; var password = RunningParams.DesignatedRunAsAdminAccountPassword; if (string.IsNullOrEmpty(account) | string.IsNullOrEmpty(password)) { return; } if (RunningParams.IsDesignatedRunAsAdminAccountDomainAcct) { new NetworkLocationService().RefreshNetworkDistance(); //? necessary if (RunningParams.NetworkDistance == NetworkDistance.Wan | RunningParams.NetworkDistance == NetworkDistance.Unknown) { return; } if (MachineInfoHelper.GetMachineInfo("domainname") != Configuration.OrganizationSetting.FullDomainName.ToLower()) { return; } domain = Configuration.OrganizationSetting.ShortDomainName; } if (!NetworkAndSystemHelper.IsWinIdAdmin(domain, account, "administrators", "Domain Admins")) { return; } if (LocalAccountHelper.IsValidAccountAndPassword(domain, account, password)) { RunningParams.DesignatedRunAsAdminAccountStatus = UniversalStatus.Ok; if (RunningParams.CurrentWinIdAsRunAsAdminAccountStatus == UniversalStatus.NotOk) { //RunningParams.CurrentRunAsAdminAccountDomain = domain; //RunningParams.CurrentRunAsAdminAccountName = account; //RunningParams.CurrentRunAsAdminAccountPassword = password; } if (RunningParams.Win10CompatibilityStatus == UniversalStatus.Ok && RunningParams.SeclogonWinServiceStatus == UniversalStatus.Ok) { RunningParams.CurrentRunAsAdminAccountDomain = domain; RunningParams.CurrentRunAsAdminAccountName = account; RunningParams.CurrentRunAsAdminAccountPassword = password; } } UpdateRunAsAdminAccountStatus(); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".RefreshDesignatedRunAsAdminAccountStatus Error: " + ex.Message); } }
internal void RefreshNetworkDistance() { try { RunningParams.NetworkDistance = NetworkAndSystemHelper.GetNetworkDistance(); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".RefreshNetworkDistance Error: " + ex.Message); } }
//##SeclogonWinServiceStatus internal void RefreshSeclogonWinServiceStatus() { try { if (!NetworkAndSystemHelper.IsSeclogonWinServiceRunning()) { RunningParams.SeclogonWinServiceStatus = UniversalStatus.NotOk; } else { RunningParams.SeclogonWinServiceStatus = UniversalStatus.Ok; } UpdateRunAsAdminAccountStatus(); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".RefreshSeclogonWinServiceStatus Error: " + ex.Message); } }
//##CurrentWinIdAsRunAsAdminAccountStatus internal void RefreshCurrentWinIdAsRunAsAdminAccountStatus() { try { var domainOfCurWinId = ""; var accountNameOfCurWinId = ""; var machineName = Environment.MachineName; var currentWinIdentity = WindowsIdentity.GetCurrent(); var fullAcctNameOfCurWinId = currentWinIdentity.Name; var curWinIdInfoArray = fullAcctNameOfCurWinId.Split('\\'); if (fullAcctNameOfCurWinId.ToLower().StartsWith(machineName.ToLower())) { accountNameOfCurWinId = curWinIdInfoArray[1]; } else { domainOfCurWinId = curWinIdInfoArray[0]; accountNameOfCurWinId = curWinIdInfoArray[1]; } if (NetworkAndSystemHelper.IsWinIdAdmin(domainOfCurWinId, accountNameOfCurWinId, "Administrators", "Domain Admins")) { RunningParams.CurrentWinIdAsRunAsAdminAccountStatus = UniversalStatus.Ok; RunningParams.CurrentRunAsAdminAccountDomain = domainOfCurWinId; RunningParams.CurrentRunAsAdminAccountName = "Current Windows Id: " + accountNameOfCurWinId; RunningParams.CurrentRunAsAdminAccountPassword = ""; } else { RunningParams.CurrentWinIdAsRunAsAdminAccountStatus = UniversalStatus.NotOk; } UpdateRunAsAdminAccountStatus(); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".RefreshCurrentWinIdAsRunAsAdminAccountStatus Error: " + ex.Message); } }
//##DefaultRunAsAdminAccountStatus internal void RefreshDefaultRunAsAdminAccountStatus() { try { var account = ""; var password = ""; RunningParams.DefaultRunAsAdminAccountStatus = UniversalStatus.NotOk; //domain account if (!string.IsNullOrEmpty(Configuration.OrganizationSetting.RunAsAdminDomainAccount)) { new NetworkLocationService().RefreshNetworkDistance(); //? necessary //local account check if (!string.IsNullOrEmpty(Configuration.OrganizationSetting.RunAsAdminLocalAccount)) { account = Configuration.OrganizationSetting.RunAsAdminLocalAccount; var encrptedPassword = Configuration.OrganizationSetting.RunAsAdminLocalAccountPassword; password = encrptedPassword; if (NetworkAndSystemHelper.IsWinIdAdmin("", account, "administrators", "Domain Admins")) { if (LocalAccountHelper.IsValidAccountAndPassword("", account, password)) { RunningParams.DefaultRunAsAdminAccountStatus = UniversalStatus.Ok; if (RunningParams.CurrentWinIdAsRunAsAdminAccountStatus == UniversalStatus.NotOk) { RunningParams.CurrentRunAsAdminAccountDomain = string.Empty; RunningParams.CurrentRunAsAdminAccountName = account; RunningParams.CurrentRunAsAdminAccountPassword = password; } } } return; }//local account check end //domain account check if (RunningParams.NetworkDistance != (int)NetworkDistance.Wan & RunningParams.NetworkDistance != NetworkDistance.Unknown) { if (MachineInfoHelper.GetMachineInfo("domainname") == Configuration.OrganizationSetting.FullDomainName.ToLower()) { var domain = Configuration.OrganizationSetting.ShortDomainName; account = Configuration.OrganizationSetting.RunAsAdminDomainAccount; var encrptedPassword = Configuration.OrganizationSetting.RunAsAdminDomainAccountPassword; password = encrptedPassword; if (NetworkAndSystemHelper.IsWinIdAdmin(domain, account, "administrators", "Domain Admins")) { if (LocalAccountHelper.IsValidAccountAndPassword(domain, account, password)) { RunningParams.DefaultRunAsAdminAccountStatus = UniversalStatus.Ok; if (RunningParams.CurrentWinIdAsRunAsAdminAccountStatus == UniversalStatus.NotOk) { //RunningParams.CurrentRunAsAdminAccountDomain = domain; //RunningParams.CurrentRunAsAdminAccountName = account; //RunningParams.CurrentRunAsAdminAccountPassword = password; } if (RunningParams.Win10CompatibilityStatus == UniversalStatus.Ok && RunningParams.SeclogonWinServiceStatus == UniversalStatus.Ok) { RunningParams.CurrentRunAsAdminAccountDomain = domain; RunningParams.CurrentRunAsAdminAccountName = account; RunningParams.CurrentRunAsAdminAccountPassword = password; } } } }//domain account check ends } } UpdateRunAsAdminAccountStatus(); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".RefreshDefaultRunAsAdminAccountStatus Error: " + ex.Message); } }