zoukankan      html  css  js  c++  java
  • 取得connectionStrings属性

    取得Web config文件连接数据库字符各个属性。

    代码
     public string GetConnectionValue(string Keyword,string connectionString)
            {
                
    string[] aa = Keyword.Split(',');           
                
    string[] bb = connectionString.Split(';');
                
    string strTempValue = string.Empty;
                
    foreach (string b in bb)
                {
                    
    foreach (string a in aa)
                    {
                        
    if (b.IndexOf("="< 0continue;  
                        
    if (b.StartsWith(a, StringComparison.OrdinalIgnoreCase))
                            strTempValue 
    = b.Substring(b.IndexOf("="+ 1);
                    }
                }
                
    return strTempValue;
            }
    代码
            public string GetServerName()
            {
                
    string key = "Data Source,Server,Address,Addr,Network Address";
                
    return GetConnectionValue(key);
            }

            
    public string GetDataBaseName()
            {
                
    string key = "Initial Catalog,Database";
                
    return GetConnectionValue(key);
            }

            
    public string GetPassword()
            {
                
    string key = "Password,Pwd";
                
    return GetConnectionValue(key);
            }

            
    public string GetUserId()
            {
                
    string key = "User ID,uid";
                
    return GetConnectionValue(key);
            }

            
    public string GetPacketSize()
            {
                
    string key = "Packet Size";
                
    return GetConnectionValue(key);
            }

            
    public string GetPooling()
            {
                
    string key = "Pooling";
                
    return GetConnectionValue(key);
            }

            
    public string GetMaxPoolSize()
            {
                
    string key = "Max Pool Size";
                
    return GetConnectionValue(key);
            }

            
    public string GetTrustedSecurity()
            {
                
    string key = "Integrated Security,Trusted_Connection";
                
    return GetConnectionValue(key);
            }

            
    public bool IsTrustedSecurityConnection()
            {
                
    string sScty = GetTrustedSecurity();
                
    return (sScty == "SSPI" || sScty == "True");
            }

            
    public bool IsAtLocalMachine()
            {
                
    string sName = GetServerName();
                
    return (sName == "127.0.0.1" || sName == "localhost");
            }
  • 相关阅读:
    Kali渗透测试工具-netcat
    信息收集工具-dimtry
    Beef xss神器
    Scapy编写ICMP扫描脚本
    全国职业技能大赛信息安全管理与评估-MySQL弱口令利用
    crawler 听课笔记 碎碎念 2 一些爬虫须知的基本常识和流程
    crawler 听课笔记 碎碎念 3 关于python的细枝末节的回顾复习
    关于互信息(Mutual Information),我有些话要说
    最让人头疼的清洗数据过程----选择合适的方式快速命中所需的数据
    利用小虫虫做一枚合格宅男,果然牡丹花下做鬼也风流
  • 原文地址:https://www.cnblogs.com/insus/p/1909154.html
Copyright © 2011-2022 走看看