久久久久久久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 - 使用應(yīng)用程序提供的登錄名和密碼通過(guò)

        ADO.NET - Connect to SQL Server with Windows Login with login and password supplied by the application(ADO.NET - 使用應(yīng)用程序提供的登錄名和密碼通過(guò) Windows 登錄連接到 SQL Server) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)分享社
      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 - 使用應(yīng)用程序提供的登錄名和密碼通過(guò) Windows 登錄連接到 SQL Server的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  這是 SQL Server 2008 R2,.NET 4.0.

                  This is SQL Server 2008 R2, .NET 4.0.

                  在我的 SQL Server 中,有一個(gè)使用Windows 身份驗(yàn)證"創(chuàng)建的用戶(hù).用戶(hù)存在于 Active Directory 域中.

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

                  我想讓一個(gè) .NET 應(yīng)用程序以這個(gè)用戶(hù)的身份連接到 SQL Server.在應(yīng)用程序內(nèi)部,我知道用戶(hù)的域、登錄名和密碼,并且應(yīng)用程序可以訪問(wèn) AD 服務(wù)器.

                  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.

                  我怎樣才能做到這一點(diǎn)?

                  How can I accomplish this?

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

                  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.

                  感謝您的幫助!

                  推薦答案

                  我已經(jīng)使用這個(gè)類(lèi)完成了:

                  I've done it using this class:

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

                  如果計(jì)算機(jī)不屬于域,您必須使用 LOGON32_LOGON_NEW_CREDENTIALS = 9 進(jìn)行模擬.

                  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.
                  

                  警告:注意連接池.該池與運(yùn)行應(yīng)用程序的實(shí)際用戶(hù)相關(guān)聯(lián),而不是與模擬的網(wǎng)絡(luò)憑據(jù)相關(guān)聯(lián).因此,在使用相同的連接字符串進(jìn)行后續(xù)訪問(wèn)時(shí),池可能會(huì)返回先前模擬的用戶(hù)建立的連接,即使您通過(guò)網(wǎng)絡(luò)模擬第二個(gè)用戶(hù).如果您不知道自己在做什么,請(qǐng)?jiān)谑褂盟鼤r(shí)禁用連接池.

                  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.

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

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

                  相關(guān)文檔推薦

                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫(xiě) SQL 查詢(xún)的情況下找出數(shù)據(jù)庫(kù)列表和 SQL Server 實(shí)例使用的空間嗎?) - IT屋-程序員軟件開(kāi)發(fā)
                  How to create a login to a SQL Server instance?(如何創(chuàng)建對(duì) SQL Server 實(shí)例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過(guò)注冊(cè)表搜索知道SQL Server的版本和版本)
                  Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會(huì)出現(xiàn)“數(shù)據(jù)類(lèi)型轉(zhuǎn)換錯(cuò)誤?使用 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 應(yīng)用程序設(shè)計(jì)——將文檔從 SQL Server 移動(dòng)到文件存儲(chǔ))

                • <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>
                          • 主站蜘蛛池模板: 日本在线网站 | 午夜精品福利视频 | 在线播放91| 欧美日韩综合 | 亚洲一区二区三区 | 日日干日日操 | av中文字幕在线观看 | 亚洲视频区 | 日韩视频在线观看一区二区 | 日韩免费| 日本不卡免费新一二三区 | 91资源在线 | 国产成人一区二区三区 | 91精品国产乱码久久久久久久久 | 天天av天天好逼 | 韩国av一区二区 | 日韩av在线一区二区三区 | 欧美激情 一区 | 国产第一页在线观看 | 九九色综合 | 精品一区在线免费观看 | 在线精品亚洲欧美日韩国产 | 国产在线高清 | 天堂色区 | 久久久久久久久久久久久久国产 | 日日操av| 成人午夜视频在线观看 | 国产精品成人在线 | 国产免费人成xvideos视频 | 日韩在线不卡 | 亚洲性视频| 亚洲国产中文字幕 | 欧美日韩不卡 | 天天干免费视频 | 日本午夜网 | 国产精品免费高清 | 成人午夜精品一区二区三区 | 成人在线视频网 | 亚洲综合色视频在线观看 | 国产高清视频 | 亚洲三级免费看 |