久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" 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>
                          • 主站蜘蛛池模板: 久久一 | 五月天婷婷综合 | 一级全黄少妇性色生活免费看 | 欧美影院| 日本精品视频一区二区 | 日本精品一区二区 | 亚洲美乳中文字幕 | 国产69精品久久99不卡免费版 | 在线成人 | 欧美日韩黄色一级片 | 亚洲一区中文字幕在线观看 | 亚洲一区二区三区在线视频 | 欧美激情在线播放 | 日韩在线中文字幕 | 中文字幕在线观看视频网站 | 一区二区三区不卡视频 | 日韩一区二区在线视频 | 成人欧美一区二区三区黑人孕妇 | 日本在线免费 | 视频一区二区在线观看 | 中文字幕免费在线 | 国产精品一区二区av | 久久综合色综合 | 国产精品色哟哟网站 | av毛片在线| 久久久久精 | 亚洲精品在线视频 | 国产日韩欧美一区 | 国产精品一区一区 | 久久精品日产第一区二区三区 | 91欧美激情一区二区三区成人 | 亚洲97| 久久涩涩 | 欧美色性 | 中国大陆高清aⅴ毛片 | 亚洲高清在线 | 亚洲一区中文字幕在线观看 | 亚洲a视频 | 中文亚洲字幕 | 日韩精品一区二区三区中文字幕 | 91精品国产手机 |