IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類|軟件專題|手機(jī)版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當(dāng)前所在位置: 首頁(yè)網(wǎng)絡(luò)編程.Net編程 → asp.net獲得客戶端域賬號(hào)

asp.net獲得客戶端域賬號(hào)

時(shí)間:2015-06-28 00:00:00 來(lái)源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(0)

  To get the windows user name through programatically. Compulsary we need to set the web server.

  Open the Internet Infomation Services(IIS), Select your ASP.NET Virtual Directory, right click, go to the Properties, In Properties window go to Directory Security Tab, Here You Find the "Edit" button in Anonymous access and Authentication Control. Press Edit Button. Now Authentication Methods dialogbox will appear.

  In this dialog box by default it is set(checked) Anonymous Access. uncheck this checkbox and go to botom of this dialog box check the Integrated windows authentication. Here why we are selecting this Default web server is logged by ISUER_MachineName so if it is window authentication web server will take the credentials from windows logged user.

  Getting the User Name :

  using three ways we can get the User Name using C#

  1) System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;

  string strName = p.Identity.Name;

  [ OR ]

  2) string strName = HttpContext.Current.User.Identity.Name.ToString();

  [ OR ]

  3) string strName = Request.ServerVariables["AUTH_USER"]; //Finding with name

  string strName = Request.ServerVariables[5]; //Finding with index

  In Above 3 Cases returnin string contains DomainName\WinNTLoggedUserName

  (for Ex: Microsoft\Bill.Gates. Here Microsoft is domain Bill.Gates is Logger User Name )

  Using string operations seperate the DomainName and UserName.

關(guān)鍵詞標(biāo)簽:asp.net

相關(guān)閱讀

文章評(píng)論
發(fā)表評(píng)論

熱門文章 誅仙3飛升任務(wù)怎么做-誅仙3飛升任務(wù)流程最新2022 誅仙3飛升任務(wù)怎么做-誅仙3飛升任務(wù)流程最新2022 鐘離圣遺物推薦-原神鐘離圣遺物詞條 鐘離圣遺物推薦-原神鐘離圣遺物詞條 解決方法:應(yīng)用程序“DEFAULT WEB SITE”中的服務(wù)器錯(cuò)誤 解決方法:應(yīng)用程序“DEFAULT WEB SITE”中的服務(wù)器錯(cuò)誤 使用aspnet_regiis.exe 重新注冊(cè).NET Framework 使用aspnet_regiis.exe 重新注冊(cè).NET Framework

相關(guān)下載

    人氣排行 誅仙3飛升任務(wù)怎么做-誅仙3飛升任務(wù)流程最新2022 asp.net表單提交方法GET\POST 在ASP.NET中如何判斷用戶IE瀏覽器的版本 Asp.net中messagebox的實(shí)現(xiàn)方法 Asp.net中的web.config配置 在ASP.NET MVC中實(shí)現(xiàn)大文件異步上傳 asp.net獲取URL和IP地址 FileUpload上傳多文件出現(xiàn)錯(cuò)誤的解決方法