zoukankan      html  css  js  c++  java
  • 登录SQL SERVER的WINDOWS和SQL SERVER身份验证的两种连接字符串

    自己代码中的配置信息

    //windows身份验证使用的

    <appSettings>
    <add key="ConnctionStr" value="server=1.1.0.1;database=1;integrated security=true"/>
    </appSettings>
    

    //sql server登陆验证所需要的

    <appSettings>
    <add key="ConnctionStr" value="server=1.1.0.1;database=1;integrated security=false;uid=sa;pwd=123"/>
    </appSettings
    

      

    Windows身份验证使用Windows登录用户身份连接数据库,而SQL身份验证要求显式地指定SQL Server用户ID和密码。

    使用Windows身份验证,必须在连接字符串中包括 Integrated Security 属性:

    Data Source=Server;Integrated Security=True;

    Integrated Security 身份验证方式可识别的值为true、false、yes、no以及与true等效的SSPI。

    指使用windows自带的安全验证机制,不用加uid和password也可以打开数据库,如果没有那一句,就必须在连接字符串里写上uid=sa;password=00; 否则不能打开数据库

    默认情况下,Integrated Security 属性为 False ,这意味着将禁用Windows身份验证。如果没有把这个属性的值设置为True,连接将使用SQL Server身份验证,因此,必须提供SQL Server用户ID和密码。Integrated Security属性还能识别的其他值只有SSPI(Security Support Provider Interface,安全性支持提供者接口).在所有的Windows NT操作系统上,其中包括Windows NT 4.0、2000、XP,都支持值SSPI。它是使用Windows身份验证时可以使用的惟一接口,相当于把Integrated Security 属性值设置为True。

    在Windows身份验证模式中,SQL Server使用Windows的安全子系统对用户连接进行有效性验证。即使显示地指定用户ID和密码,SQL Server也不检查连接字符串中的用户ID和密码。因为只有Windows NT、2000、XP支持SSPI,因此如果正使用的是这些操作系统,则只能使用Windows集成的安全策略去连接SQL Server。不论使用哪一个操作系统,当使用SQL Server身份验证时,必须在连接字符串中指定用户ID和密码:

       Data Source=ServerName;User ID=aa;Password=aa

    默认情况下,SQL Server .NET Data Provider连接指定用户的默认数据库,当在数据库中创建用户时,可以设置用户的默认数据库。此外,也可以在任意时间更改用户的默认数据库。例如,系统管理员的默认数据库是master。如果想要连接不同的数据库,应该指定数据库的名称:

       Data Source=Server;Integrated Security=SSPI;Initial Catalog=databse

    Microsoft安全支持提供器接口(SSPI)是定义得较全面的公用API,用来获得验证、信息完整性、信息隐私等集成安全服务,以及用于所有分布式应用程序协议的安全方面的服务。应用程序协议设计者能够利用该接口获得不同的安全性服务而不必修改协议本身。

  • 相关阅读:
    使用VideoView开发视频总结
    后台接口向数据库录入汉字时乱码以及自动过滤文字经验总结
    8 Crash Reporting Tools For iOS And Android Apps
    Best Mobile Crash Reporting Software
    How do I obtain crash-data from my Android application?
    ACRA (Automated Crash Reporting for Android)
    Debugging Neural Networks with PyTorch and W&B
    OpenPose MobileNet V1
    Real-time-human-pose-estimation-by-pytorch
    openpose-pytorch
  • 原文地址:https://www.cnblogs.com/wzihan/p/14744442.html
Copyright © 2011-2022 走看看