示例#1
0
        public WebSiteInfo GetWebsiteInfo(string webSiteID)
        {
            WebSiteInfo    siteInfo  = new WebSiteInfo();
            DirectoryEntry rootEntry = GetDirectoryEntry("");

            foreach (DirectoryEntry ent in rootEntry.Children)
            {
                if (ent.Name == webSiteID && ent.SchemaClassName == "IIsWebServer")
                {
                    siteInfo.SiteName = ent.Properties[WebSiteParameter.ServerComment.ToString()].Value.ToString();
                    siteInfo.Bindings = ent.Properties[WebSiteParameter.ServerBindings.ToString()].Value;
                    siteInfo.State    = (WebSiteState)ent.Properties["ServerState"].Value;
                    siteInfo.LogFileLocaltimeRollover = SmString.StringToBool(ent.Properties[WebSiteParameter.LogFileLocaltimeRollover.ToString()].Value.ToString());
                    siteInfo.LogFileDirectory         = ent.Properties[WebSiteParameter.LogFileDirectory.ToString()].Value.ToString();

                    DirectoryEntry appInfo = ent.Children.Find("root", "IIsWebVirtualDir");
                    siteInfo.AccessUser    = new IdentityAuthInfo(appInfo.Properties[WebVirtualDirParameter.AnonymousUserName.ToString()].Value.ToString(), appInfo.Properties[WebVirtualDirParameter.AnonymousUserPass.ToString()].Value.ToString());
                    siteInfo.AppPoolName   = appInfo.Properties[WebVirtualDirParameter.AppPoolId.ToString()].Value.ToString();
                    siteInfo.DirectoryPath = appInfo.Properties[WebVirtualDirParameter.Path.ToString()].Value.ToString();
                    siteInfo.ScriptMaps    = appInfo.Properties[WebVirtualDirParameter.ScriptMaps.ToString()].Value;

                    return(siteInfo);
                }
            }
            DisposeDirectoryEntry(rootEntry);
            return(siteInfo);
        }
示例#2
0
 private void SetValueIfNotNULL(SmString property, SmString value)
 {
     if (value.Value != null)
     {
         property = value;
     }
 }
示例#3
0
        public static string GetLicenseUserIdentity(string productString)
        {
            NameValueCollection values = GetLicenseEncryptedConfigure(productString);
            string clientString        = values["userIdentity"];

            return(SmString.FixNullString(clientString));
        }
示例#4
0
        /// <summary>
        /// 获取加密授权配置中的一个配置项目
        /// </summary>
        /// <param name="productString">当前产品的标识名称</param>
        /// <returns></returns>
        public static NameValueCollection GetLicenseEncryptedConfigure(string productString)
        {
            NameValueCollection result = new NameValueCollection();
            string s = GetLicenseEncryptedString(productString);

            if (!string.IsNullOrEmpty(s))
            {
                result = SmString.AnalyzeNameValue(s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries), "=");
            }
            return(result);
        }
示例#5
0
        public static string GetWebRootUri()
        {
            string http = "http";

            if (HttpContext.Current.Request.ServerVariables["HTTPS"] != null && SmString.StringToBool(HttpContext.Current.Request.ServerVariables["HTTPS"]))
            {
                http = "https";
            }

            http = http + "://" + HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + HttpHelper.WebRoot;
            return(http);
        }
示例#6
0
        /// <summary>
        /// 检查一个用户名是否存在
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool IsExistUser(string username)
        {
            DataTable dt     = _odbc.GetDataTable("select user from mysql.user");
            ArrayList _array = new ArrayList();

            foreach (DataRow row in dt.Rows)
            {
                _array.Add(row[0]);
            }
            string[] nameArr = (string[])_array.ToArray(typeof(string));
            dt.Clear();
            dt.Dispose();
            return(SmString.FindFormStringArray(nameArr, username));
        }
示例#7
0
        /// <summary>
        /// 检查数据库是否存在
        /// </summary>
        /// <param name="database">要检查的数据库</param>
        /// <returns></returns>
        public bool IsExistDatabase(string database)
        {
            DataTable dt     = _odbc.GetDataTable("SHOW DATABASES");
            ArrayList _array = new ArrayList();

            foreach (DataRow row in dt.Rows)
            {
                _array.Add(row[0]);
            }
            string[] nameArr = (string[])_array.ToArray(typeof(string));
            dt.Clear();
            dt.Dispose();
            return(SmString.FindFormStringArray(nameArr, database));
        }
示例#8
0
        /// <summary>
        /// 检查一个用户名是否存在
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool IsExistUser(string username)
        {
            DataTable dt     = _mssql.GetDataTable("select Name from Master..syslogins where isntname=0");
            ArrayList _array = new ArrayList();

            foreach (DataRow row in dt.Rows)
            {
                _array.Add(row[0]);
            }
            string[] nameArr = (string[])_array.ToArray(typeof(string));
            dt.Clear();
            dt.Dispose();
            return(SmString.FindFormStringArray(nameArr, username));
        }
示例#9
0
        /// <summary>
        /// 检查数据库是否存在
        /// </summary>
        /// <param name="database">要检查的数据库</param>
        /// <returns></returns>
        public bool IsExistDatabase(string database)
        {
            DataTable dt     = _mssql.GetDataTable("Select Name From Master..SysDatabases");
            ArrayList _array = new ArrayList();

            foreach (DataRow row in dt.Rows)
            {
                _array.Add(row[0]);
            }
            string[] nameArr = (string[])_array.ToArray(typeof(string));
            dt.Clear();
            dt.Dispose();
            return(SmString.FindFormStringArray(nameArr, database));
        }
示例#10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="port"></param>
        /// <param name="protocol"></param>
        /// <param name="enable"></param>
        /// <param name="name"></param>
        public static void AddSharedAccessFirewallPort(int port, InternetProtocol protocol, bool enable, string name)
        {
            string protocolStr = "";
            string enableStr   = "";

            if (protocol == InternetProtocol.Tcp)
            {
                protocolStr = "TCP";
            }
            else if (protocol == InternetProtocol.Udp)
            {
                protocolStr = "UDP";
            }

            if (enable)
            {
                enableStr = "Enabled";
            }
            else
            {
                enableStr = "Disabled";
            }

            string portStr = port.ToString();


            RegistryKey k1 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile", true);

            if (!SmString.FindFormStringArray(k1.GetSubKeyNames(), "GloballyOpenPorts"))
            {
                k1.CreateSubKey("GloballyOpenPorts");
            }
            k1.Close();

            RegistryKey k2 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts", true);

            if (!SmString.FindFormStringArray(k2.GetSubKeyNames(), "List"))
            {
                k2.CreateSubKey("List");
            }
            k2.Close();

            RegistryKey k3 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List", true);

            k3.SetValue(portStr + ":" + protocolStr, portStr + ":" + protocolStr + ":*:" + enableStr + ":" + name, RegistryValueKind.String);
            k3.Close();
        }
示例#11
0
        public string SqlSelectCommandString(string tableName, string[] selectingFields)
        {
            string result = "SELECT";

            if (SelectTopN > 0)
            {
                result += " TOP " + SelectTopN;
            }
            if (SelectingFields == null || result.Length == 0)
            {
                result += " *";
            }
            result += SmString.MergeStringArray(SelectingFields, ",", true, "", "");
            result += " FROM " + tableName;

            return(result);
        }