pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

      <bdo id='A6euh'></bdo><ul id='A6euh'></ul>

        <tfoot id='A6euh'></tfoot>
        <i id='A6euh'><tr id='A6euh'><dt id='A6euh'><q id='A6euh'><span id='A6euh'><b id='A6euh'><form id='A6euh'><ins id='A6euh'></ins><ul id='A6euh'></ul><sub id='A6euh'></sub></form><legend id='A6euh'></legend><bdo id='A6euh'><pre id='A6euh'><center id='A6euh'></center></pre></bdo></b><th id='A6euh'></th></span></q></dt></tr></i><div class="mosmsuo" id='A6euh'><tfoot id='A6euh'></tfoot><dl id='A6euh'><fieldset id='A6euh'></fieldset></dl></div>
        <legend id='A6euh'><style id='A6euh'><dir id='A6euh'><q id='A6euh'></q></dir></style></legend>
      1. <small id='A6euh'></small><noframes id='A6euh'>

      2. ADO.NET - 使用應用程序提供的登錄名和密碼通過

        ADO.NET - Connect to SQL Server with Windows Login with login and password supplied by the application(ADO.NET - 使用應用程序提供的登錄名和密碼通過 Windows 登錄連接到 SQL Server) - IT屋-程序員軟件開發技術分享社
      3. <small id='CubaY'></small><noframes id='CubaY'>

            <tbody id='CubaY'></tbody>
              <tfoot id='CubaY'></tfoot>
            1. <legend id='CubaY'><style id='CubaY'><dir id='CubaY'><q id='CubaY'></q></dir></style></legend>

              • <i id='CubaY'><tr id='CubaY'><dt id='CubaY'><q id='CubaY'><span id='CubaY'><b id='CubaY'><form id='CubaY'><ins id='CubaY'></ins><ul id='CubaY'></ul><sub id='CubaY'></sub></form><legend id='CubaY'></legend><bdo id='CubaY'><pre id='CubaY'><center id='CubaY'></center></pre></bdo></b><th id='CubaY'></th></span></q></dt></tr></i><div class="uy2o22q" id='CubaY'><tfoot id='CubaY'></tfoot><dl id='CubaY'><fieldset id='CubaY'></fieldset></dl></div>

                  <bdo id='CubaY'></bdo><ul id='CubaY'></ul>

                  本文介紹了ADO.NET - 使用應用程序提供的登錄名和密碼通過 Windows 登錄連接到 SQL Server的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  這是 SQL Server 2008 R2,.NET 4.0.

                  This is SQL Server 2008 R2, .NET 4.0.

                  在我的 SQL Server 中,有一個使用Windows 身份驗證"創建的用戶.用戶存在于 Active Directory 域中.

                  In my SQL Server there is a user created with "Windows Authentication". The user exists in a Active Directory domain.

                  我想讓一個 .NET 應用程序以這個用戶的身份連接到 SQL Server.在應用程序內部,我知道用戶的域、登錄名和密碼,并且應用程序可以訪問 AD 服務器.

                  I want to make a .NET application connect to the SQL Server as this user. Inside the application, I know the user's domain, login and password, and the application has network access to the AD server.

                  我怎樣才能做到這一點?

                  How can I accomplish this?

                  我知道 ASP.NET 有它的 AD 提供程序和模擬.但我正在尋找的是一個真正通用的解決方案,它應該適用于普通的控制臺應用程序.我可以在控制臺應用、Windows 窗體、asp.net 或通用業務類庫上使用的東西.

                  I know that ASP.NET has it's AD provider and impersonation. But what I'm looking for is a really generic solution, one that should work on a plain console application. Something that I could use on console app, windows forms, asp.net, or a common business class library.

                  感謝您的幫助!

                  推薦答案

                  我已經使用這個類完成了:

                  I've done it using this class:

                  https://platinumdogs.me/2008/10/30/net-c-impersonation-with-network-credentials/

                  如果計算機不屬于域,您必須使用 LOGON32_LOGON_NEW_CREDENTIALS = 9 進行模擬.

                  You must impersonate using LOGON32_LOGON_NEW_CREDENTIALS = 9 if the computer does not belong to the domain.

                  一旦被模擬,然后使用 SQL 連接字符串上的Integrated Security=true"連接到 SQL.

                  Once impersonated, then connect to SQL using "Integrated Security=true" on the SQL Connection String.

                  SqlConnection conn;
                  using (new Impersonator("myUserName", "myDomain", "myPassword", LogonType.LOGON32_LOGON_NEW_CREDENTIALS, LogonProvider.LOGON32_PROVIDER_DEFAULT))
                  {
                      conn = new SqlConnection("Data Source=databaseIp;Initial Catalog=databaseName;Integrated Security=true;");
                      conn.Open();
                  }
                  //(...) use the connection at your will.
                  //Even after the impersonation context ended, the connection remains usable.
                  

                  警告:注意連接池.該池與運行應用程序的實際用戶相關聯,而不是與模擬的網絡憑據相關聯.因此,在使用相同的連接字符串進行后續訪問時,池可能會返回先前模擬的用戶建立的連接,即使您通過網絡模擬第二個用戶.如果您不知道自己在做什么,請在使用它時禁用連接池.

                  ALERT: Beware of connection pooling. The pool is associated with the actual user running the application, not with the network credentials that were impersonated. So on subsequent access using the same connection string, the pool may return a connection made by a previously impersonated user, even if you netorkly-impersonate a second user. If you don't know what you're doing, disable connection pooling when using this.

                  這篇關于ADO.NET - 使用應用程序提供的登錄名和密碼通過 Windows 登錄連接到 SQL Server的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                  How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                  Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 ExecuteNonQuery()?)
                  How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                  WinForms application design - moving documents from SQL Server to file storage(WinForms 應用程序設計——將文檔從 SQL Server 移動到文件存儲)

                • <tfoot id='Ahps2'></tfoot>

                          <tbody id='Ahps2'></tbody>

                          <small id='Ahps2'></small><noframes id='Ahps2'>

                          <i id='Ahps2'><tr id='Ahps2'><dt id='Ahps2'><q id='Ahps2'><span id='Ahps2'><b id='Ahps2'><form id='Ahps2'><ins id='Ahps2'></ins><ul id='Ahps2'></ul><sub id='Ahps2'></sub></form><legend id='Ahps2'></legend><bdo id='Ahps2'><pre id='Ahps2'><center id='Ahps2'></center></pre></bdo></b><th id='Ahps2'></th></span></q></dt></tr></i><div class="oi0u22s" id='Ahps2'><tfoot id='Ahps2'></tfoot><dl id='Ahps2'><fieldset id='Ahps2'></fieldset></dl></div>
                            <bdo id='Ahps2'></bdo><ul id='Ahps2'></ul>
                            <legend id='Ahps2'><style id='Ahps2'><dir id='Ahps2'><q id='Ahps2'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 深圳律师咨询_深圳律师事务所_华荣【免费在线法律咨询】网 | 中矗模型-深圳中矗模型设计有限公司 | 节流截止放空阀-不锈钢阀门-气动|电动截止阀-鸿华阀门有限公司 | 北京办公室装修,办公室设计,写字楼装修-北京金视觉装饰工程公司 北京成考网-北京成人高考网 | 找培训机构_找学习课程_励普教育| 汽车整车综合环境舱_军标砂尘_盐雾试验室试验箱-无锡苏南试验设备有限公司 | 柔性输送线|柔性链板|齿形链-上海赫勒输送设备有限公司首页[输送机] | Maneurop/美优乐压缩机,活塞压缩机,型号规格,技术参数,尺寸图片,价格经销商 | 郑州巴特熔体泵有限公司专业的熔体泵,熔体齿轮泵与换网器生产厂家 | 天助网 - 中小企业全网推广平台_生态整合营销知名服务商_天助网采购优选 | 哈尔滨发电机,黑龙江柴油发电机组-北方星光 | 金联宇电缆总代理-金联宇集团-广东金联宇电缆实业有限公司 | 全自动实验室洗瓶机,移液管|培养皿|进样瓶清洗机,清洗剂-广州摩特伟希尔机械设备有限责任公司 | 翻斗式矿车|固定式矿车|曲轨侧卸式矿车|梭式矿车|矿车配件-山东卓力矿车生产厂家 | 衡阳耐适防护科技有限公司——威仕盾焊接防护用品官网/焊工手套/焊接防护服/皮革防护手套 | POM塑料_PBT材料「进口」聚甲醛POM杜邦原料、加纤PBT塑料报价格找利隆塑料 | 内六角扳手「厂家」-温州市威豪五金工具有限公司 | 冷凝水循环试验箱-冷凝水试验箱-可编程高低温试验箱厂家-上海巨为(www.juweigroup.com) | 武汉高温老化房,恒温恒湿试验箱,冷热冲击试验箱-武汉安德信检测设备有限公司 | 北京宣传片拍摄_产品宣传片拍摄_宣传片制作公司-现像传媒 | 臭氧老化试验箱,高低温试验箱,恒温恒湿试验箱,防水试验设备-苏州亚诺天下仪器有限公司 | 冷水机-工业冷水机-冷水机组-欧科隆品牌保障 | 轻型地埋电缆故障测试仪,频响法绕组变形测试仪,静荷式卧式拉力试验机-扬州苏电 | 法兰连接型电磁流量计-蒸汽孔板节流装置流量计-北京凯安达仪器仪表有限公司 | 塑木弯曲试验机_铜带拉伸强度试验机_拉压力测试台-倾技百科 | 北京模型公司-军事模型-工业模型制作-北京百艺模型沙盘公司 | 小型手持气象站-空气负氧离子监测站-多要素微气象传感器-山东天合环境科技有限公司 | 道达尔润滑油-食品级润滑油-道达尔导热油-合成导热油,深圳道达尔代理商合-深圳浩方正大官网 | 动库网动库商城-体育用品专卖店:羽毛球,乒乓球拍,网球,户外装备,运动鞋,运动包,运动服饰专卖店-正品运动品网上商城动库商城网 - 动库商城 | 消防泵-XBD单级卧式/立式消防泵-上海塑泉泵阀(集团)有限公司 | 企业微信scrm管理系统_客户关系管理平台_私域流量运营工具_CRM、ERP、OA软件-腾辉网络 | 莱州网络公司|莱州网站建设|莱州网站优化|莱州阿里巴巴-莱州唯佳网络科技有限公司 | 全自动包装机_灌装机生产厂家-迈驰包装设备有限公司 | 电子万能试验机_液压拉力试验机_冲击疲劳试验机_材料试验机厂家-济南众标仪器设备有限公司 | 压力控制器,差压控制器,温度控制器,防爆压力控制器,防爆温度控制器,防爆差压控制器-常州天利智能控制股份有限公司 | 工装定制/做厂家/公司_工装订做/制价格/费用-北京圣达信工装 | 运动木地板厂家,篮球场木地板品牌,体育场馆木地板安装 - 欧氏运动地板 | TMT观察网_独特视角观察TMT行业 派财经_聚焦数字经济内容服务平台 | 不锈钢监控杆_监控立杆厂家-廊坊耀星光电科技有限公司 | led太阳能路灯厂家价格_风光互补庭院灯_农村市政工程路灯-中山华可路灯品牌 | 酒吧霸屏软件_酒吧霸屏系统,酒吧微上墙,夜场霸屏软件,酒吧点歌软件,酒吧互动游戏,酒吧大屏幕软件系统下载 |