/// <summary> /// Retrieves web sites. /// </summary> /// <returns>Web sites.</returns> internal static WebSiteItem[] GetWebSites() { List <WebSiteItem> sites = new List <WebSiteItem>(); // get all sites ManagementObjectCollection objSites = wmi.ExecuteQuery("SELECT * FROM IIsWebServerSetting"); foreach (ManagementObject objSite in objSites) { WebSiteItem site = new WebSiteItem(); FillWebSiteFromWmiObject(site, objSite); sites.Add(site); } return(sites.ToArray()); }
/// <summary> /// Checks whether application pool exists /// </summary> /// <param name="name"></param> /// <returns></returns> public static bool ApplicationPoolExists(string name) { WmiHelper wmi = new WmiHelper("root\\MicrosoftIISv2"); return(wmi.ExecuteQuery( String.Format("SELECT * FROM IIsApplicationPool WHERE Name='W3SVC/AppPools/{0}'", name)).Count > 0); }
private static bool IsAspNetRoleServiceInstalled() { WmiHelper wmi = new WmiHelper("root\\cimv2"); using (ManagementObjectCollection roles = wmi.ExecuteQuery("SELECT NAME FROM Win32_ServerFeature WHERE ID=148")) { return(roles.Count > 0); } }
/// <summary> /// Check for existing user /// </summary> internal static bool UserExists(string domain, string userName) { bool found = false; // check whether user account already exists if (string.IsNullOrEmpty(domain)) { found = (wmi.ExecuteQuery( String.Format("SELECT * FROM Win32_UserAccount WHERE Domain='{0}' AND Name='{1}'", Environment.MachineName, userName))).Count > 0; } else { string path = GetUserDN(domain, userName); if (!string.IsNullOrEmpty(path)) { found = ADObjectExists(path); } } return(found); }
internal static string[] GetIPv4Addresses() { List <string> list = new List <string>(); WmiHelper wmi = new WmiHelper("root\\cimv2"); ManagementObjectCollection collection = wmi.ExecuteQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'"); foreach (ManagementObject obj in collection) { string[] ips = obj["IPAddress"] as string[]; if (ips != null) { foreach (string ip in ips) { if (!list.Contains(ip) && IsValidIPv4(ip)) { list.Add(ip); } } } } return(list.ToArray()); }
/// <summary> /// Checks whether application pool exists /// </summary> /// <param name="name"></param> /// <returns></returns> internal static bool ApplicationPoolExists(string name) { WmiHelper wmi = new WmiHelper("root\\MicrosoftIISv2"); return(wmi.ExecuteQuery( String.Format("SELECT * FROM IIsApplicationPool WHERE Name='W3SVC/AppPools/{0}'", name)).Count > 0); }
internal static string[] GetIPv4Addresses() { List<string> list = new List<string>(); WmiHelper wmi = new WmiHelper("root\\cimv2"); ManagementObjectCollection collection = wmi.ExecuteQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'"); foreach (ManagementObject obj in collection) { string[] ips = obj["IPAddress"] as string[]; if (ips != null) { foreach (string ip in ips) { if (!list.Contains(ip) && IsValidIPv4(ip)) list.Add(ip); } } } return list.ToArray(); }
private static bool IsAspNetRoleServiceInstalled() { WmiHelper wmi = new WmiHelper("root\\cimv2"); using (ManagementObjectCollection roles = wmi.ExecuteQuery("SELECT NAME FROM Win32_ServerFeature WHERE ID=148")) { return (roles.Count > 0); } }